13 #if !defined(KRATOS_TRILINOS_DOF_UPDATER_H_INCLUDED )
14 #define KRATOS_TRILINOS_DOF_UPDATER_H_INCLUDED
37 template<
class TSparseSpace >
80 typename BaseType::UniquePointer
Create()
const override
82 return Kratos::make_unique<TrilinosDofUpdater>();
102 int number_of_dofs = rDofSet.
size();
103 std::vector< int > index_array(number_of_dofs);
109 int id = i_dof->EquationId();
110 if(
id < system_size )
116 std::sort(index_array.begin(),index_array.end());
117 std::vector<int>::iterator new_end = std::unique(index_array.begin(),index_array.end());
118 index_array.resize(new_end - index_array.begin());
121 int tot_update_dofs = index_array.size();
122 rDx.Comm().SumAll(&tot_update_dofs,&check_size,1);
123 if ( (check_size < system_size) && (rDx.Comm().MyPID() == 0) )
125 std::stringstream msg;
126 msg <<
"Dof count is not correct. There are less dofs then expected." << std::endl;
127 msg <<
"Expected number of active dofs: " << system_size <<
", dofs found: " << check_size << std::endl;
132 Epetra_Map dof_update_map(-1,index_array.size(), &(*(index_array.begin())),0,rDx.Comm() );
135 std::unique_ptr<Epetra_Import> p_dof_import(
new Epetra_Import(dof_update_map,rDx.Map()));
136 mpDofImport.swap(p_dof_import);
138 mImportIsInitialized =
true;
145 mImportIsInitialized =
false;
161 if (!mImportIsInitialized)
167 Epetra_Vector local_dx( mpDofImport->TargetMap() );
170 int ierr = local_dx.Import(rDx,*mpDofImport,Insert) ;
171 KRATOS_ERROR_IF(ierr != 0) <<
"Epetra failure found while trying to import Dx." << std::endl;
173 int num_dof = rDofSet.
size();
176 #pragma omp parallel for
177 for(
int i = 0;
i < num_dof; ++
i) {
178 auto it_dof = rDofSet.
begin() +
i;
180 if (it_dof->IsFree()) {
181 int global_id = it_dof->EquationId();
182 if(global_id < system_size) {
183 double dx_i = local_dx[mpDofImport->TargetMap().LID(global_id)];
184 it_dof->GetSolutionStepValue() += dx_i;
197 std::string
Info()
const override
199 std::stringstream buffer;
200 buffer <<
"TrilinosDofUpdater" ;
207 rOStream << this->
Info() << std::endl;
213 rOStream << this->
Info() << std::endl;
224 bool mImportIsInitialized =
false;
227 std::unique_ptr<Epetra_Import> mpDofImport =
nullptr;
238 template<
class TSparseSpace >
240 std::istream& rIStream,
247 template<
class TSparseSpace >
249 std::ostream& rOStream,
253 rOStream << std::endl;
Utility class to update the values of degree of freedom (Dof) variables after solving the system.
Definition: dof_updater.h:40
typename TSparseSpace::VectorType SystemVectorType
Definition: dof_updater.h:51
PointerVectorSet< DofType > DofsArrayType
Definition: dof_updater.h:49
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
boost::indirect_iterator< typename TContainerType::const_iterator > const_iterator
Definition: pointer_vector_set.h:96
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
Utility class to update the values of degree of freedom (Dof) variables after solving the system.
Definition: trilinos_dof_updater.h:39
TrilinosDofUpdater()
Default constructor.
Definition: trilinos_dof_updater.h:56
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: trilinos_dof_updater.h:205
std::string Info() const override
Turn back information as a string.
Definition: trilinos_dof_updater.h:197
void UpdateDofs(DofsArrayType &rDofSet, const SystemVectorType &rDx) override
Calculate new values for the problem's degrees of freedom using the update vector rDx.
Definition: trilinos_dof_updater.h:155
TrilinosDofUpdater & operator=(TrilinosDofUpdater const &rOther)=delete
Deleted assignment operator.
~TrilinosDofUpdater() override
Destructor.
Definition: trilinos_dof_updater.h:64
TrilinosDofUpdater(TrilinosDofUpdater const &rOther)=delete
Deleted copy constructor.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: trilinos_dof_updater.h:211
BaseType::UniquePointer Create() const override
Create a new instance of this class.
Definition: trilinos_dof_updater.h:80
KRATOS_CLASS_POINTER_DEFINITION(TrilinosDofUpdater)
Pointer definition of TrilinosDofUpdater.
void Initialize(const DofsArrayType &rDofSet, const SystemVectorType &rDx) override
Initialize the DofUpdater in preparation for a subsequent UpdateDofs call.
Definition: trilinos_dof_updater.h:97
void Clear() override
Free internal storage to reset the instance and/or optimize memory consumption.
Definition: trilinos_dof_updater.h:142
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17