13 #ifndef KRATOS_TRILINOS_MIXED_GENERIC_CRITERIA_H
14 #define KRATOS_TRILINOS_MIXED_GENERIC_CRITERIA_H
41 template<
class TSparseSpace,
class TDenseSpace >
110 if(!mEpetraImportIsInitialized) {
111 InitializeEpetraImport(rDofSet, Dx);
143 bool mEpetraImportIsInitialized =
false;
144 std::unique_ptr<Epetra_Import> mpDofImport =
nullptr;
159 std::vector<int>& rDofsCount,
160 std::vector<TDataType>& rSolutionNormsVector,
161 std::vector<TDataType>& rIncreaseNormsVector)
const override
163 int n_dofs = rDofSet.size();
165 const int rank = r_data_comm.
Rank();
168 Epetra_Vector local_dx(mpDofImport->TargetMap());
169 int i_err = local_dx.Import(rDx, *mpDofImport, Insert);
178 auto it_dof = rDofSet.begin() +
i;
179 if (it_dof->IsFree() && it_dof->GetSolutionStepValue(PARTITION_INDEX) == rank) {
180 dof_id = it_dof->EquationId();
181 const TDataType& r_dof_value = it_dof->GetSolutionStepValue(0);
182 dof_dx = local_dx[mpDofImport->TargetMap().LID(dof_id)];
192 rSolutionNormsVector[var_local_key] += r_dof_value * r_dof_value;
193 rIncreaseNormsVector[var_local_key] += dof_dx * dof_dx;
194 rDofsCount[var_local_key]++;
212 void InitializeEpetraImport(
216 int number_of_dofs = rDofSet.size();
218 std::vector<int> index_array(number_of_dofs);
223 const int id = i_dof->EquationId();
224 if (
id < system_size) {
229 std::sort(index_array.begin(), index_array.end());
230 std::vector<int>::iterator new_end = std::unique(index_array.begin(), index_array.end());
231 index_array.resize(new_end - index_array.begin());
234 int tot_update_dofs = index_array.size();
235 rDx.Comm().SumAll(&tot_update_dofs, &check_size, 1);
237 <<
"DOF count is not correct. There are less dofs then expected.\n"
238 <<
"Expected number of active dofs: " << system_size <<
", DOFs found: " << check_size << std::endl;
241 Epetra_Map dof_update_map(-1, index_array.size(), &(*(index_array.begin())), 0, rDx.Comm());
244 std::unique_ptr<Epetra_Import> p_dof_import(
new Epetra_Import(dof_update_map, rDx.Map()));
245 mpDofImport.swap(p_dof_import);
247 mEpetraImportIsInitialized =
true;
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: convergence_criteria.h:72
TSparseSpace::DataType TDataType
Data type definition.
Definition: convergence_criteria.h:70
TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: convergence_criteria.h:74
virtual int Rank() const
Get the parallel rank for this DataCommunicator.
Definition: data_communicator.h:587
Convergence criteria for mixed vector-scalar problems.
Definition: mixed_generic_criteria.h:42
bool FindVarLocalKey(typename DofsArrayType::const_iterator itDof, int &rVarLocalKey) const
Finds the var local key in the mLocalKeyMap for a gifen DOF. If the variable does not exist in mLocal...
Definition: mixed_generic_criteria.h:415
std::vector< std::tuple< const VariableData *, TDataType, TDataType > > ConvergenceVariableListType
Definition: mixed_generic_criteria.h:61
std::size_t KeyType
Definition: mixed_generic_criteria.h:63
bool PostCriteria(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &A, const TSystemVectorType &Dx, const TSystemVectorType &b) override
Compute relative and absolute error.
Definition: mixed_generic_criteria.h:166
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Communicator & GetCommunicator()
Definition: model_part.h:1821
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
boost::indirect_iterator< typename TContainerType::const_iterator > const_iterator
Definition: pointer_vector_set.h:96
Convergence criteria for mixed vector-scalar problems.
Definition: trilinos_mixed_generic_criteria.h:43
BaseType::DofsArrayType DofsArrayType
Definition: trilinos_mixed_generic_criteria.h:54
bool PostCriteria(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &A, const TSystemVectorType &Dx, const TSystemVectorType &b) override
Compute relative and absoute error.
Definition: trilinos_mixed_generic_criteria.h:102
BaseType::ConvergenceVariableListType ConvergenceVariableListType
Definition: trilinos_mixed_generic_criteria.h:60
MixedGenericCriteria< TSparseSpace, TDenseSpace > BaseType
Definition: trilinos_mixed_generic_criteria.h:50
KRATOS_CLASS_POINTER_DEFINITION(TrilinosMixedGenericCriteria)
BaseType::TDataType TDataType
Definition: trilinos_mixed_generic_criteria.h:52
BaseType::TSystemMatrixType TSystemMatrixType
Definition: trilinos_mixed_generic_criteria.h:56
TrilinosMixedGenericCriteria(const ConvergenceVariableListType &rConvergenceVariablesList)
Constructor.
Definition: trilinos_mixed_generic_criteria.h:76
BaseType::TSystemVectorType TSystemVectorType
Definition: trilinos_mixed_generic_criteria.h:58
~TrilinosMixedGenericCriteria() override
Destructor.
Definition: trilinos_mixed_generic_criteria.h:81
BaseType::KeyType KeyType
Definition: trilinos_mixed_generic_criteria.h:62
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#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
n_dofs
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:151
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int counter
Definition: script_THERMAL_CORRECT.py:218
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17