14 #ifndef KRATOS_TRILINOS_RESIDUALBASED_INCREMENTAL_AITKEN_STATIC_SCHEME_H
15 #define KRATOS_TRILINOS_RESIDUALBASED_INCREMENTAL_AITKEN_STATIC_SCHEME_H
52 template<
class TSparseSpace,
class TDenseSpace >
86 mDefaultOmega(DefaultOmega),
87 mOldOmega(DefaultOmega)
116 mIterationCounter = 0;
137 if (mIterationCounter > 1)
145 if (mOldOmega < mDefaultOmega)
148 Omega = mDefaultOmega;
158 mpPreviousDx.swap(Tmp);
166 mpDofImporter.reset();
167 mImporterIsInitialized =
false;
219 int MyLength = Dx.MyLength();
222 if (MyLength != mpPreviousDx->MyLength())
224 KRATOS_THROW_ERROR(std::runtime_error,
"Unexpected error in Trilinos Aitken iterations: the Dx vector has a different size than in previous iteration.",
"");
232 double* pOldDxValues;
235 Dx.ExtractView(&pDxValues,&DxLDA);
236 mpPreviousDx->ExtractView(&pOldDxValues,&OldDxLDA);
238 for (
int i = 0;
i < MyLength;
i++)
240 double Diff = pDxValues[
i] - pOldDxValues[
i];
241 Num += pOldDxValues[
i] * Diff;
248 double SendBuff[2] = {Num,Den};
251 Dx.Comm().SumAll(&SendBuff[0],&RecvBuff[0],2);
256 double Omega = - mOldOmega * Num / Den;
276 Epetra_Vector
temp( pImporter->TargetMap() );
279 int ierr =
temp.Import(Dx,*pImporter,Insert);
283 temp.ExtractView( &temp_values );
288 auto dof_begin = rDofSet.
begin();
289 for(
unsigned int iii=0; iii<rDofSet.
size(); iii++)
291 int global_id = (dof_begin+iii)->
EquationId();
292 if(global_id < system_size)
294 double aaa =
temp[pImporter->TargetMap().LID(global_id)];
307 int number_of_dofs = rDofSet.
size();
308 std::vector< int > index_array(number_of_dofs);
312 for(
auto i_dof = rDofSet.
begin() ; i_dof != rDofSet.
end() ; ++i_dof)
314 int id = i_dof->EquationId();
315 if(
id < system_size )
322 std::sort(index_array.begin(),index_array.end());
323 std::vector<int>::iterator NewEnd = std::unique(index_array.begin(),index_array.end());
324 index_array.resize(NewEnd-index_array.begin());
327 int tot_update_dofs = index_array.size();
328 Dx.Comm().SumAll(&tot_update_dofs,&check_size,1);
329 KRATOS_ERROR_IF( (check_size < system_size) && (Dx.Comm().MyPID() == 0) )
330 <<
"Dof count is not correct. There are less dofs then expected." << std::endl
331 <<
"Expected number of active dofs = " << system_size <<
" dofs found = " << check_size << std::endl;
334 Epetra_Map dof_update_map(-1,index_array.size(), &(*(index_array.begin())),0,Dx.Comm() );
338 mpDofImporter.swap(pDofImporter);
340 mImporterIsInitialized =
true;
355 return mpDofImporter;
364 return mImporterIsInitialized;
384 unsigned int mIterationCounter;
390 const double mDefaultOmega;
398 bool mImporterIsInitialized =
false;
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
This class provides the implementation of a static scheme.
Definition: residualbased_incrementalupdate_static_scheme.h:57
BaseType::TSystemMatrixType TSystemMatrixType
Matrix type definition.
Definition: residualbased_incrementalupdate_static_scheme.h:78
BaseType::TSystemVectorType TSystemVectorType
Vector type definition.
Definition: residualbased_incrementalupdate_static_scheme.h:80
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
virtual void EquationId(const Element &rElement, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo)
This method gets the eqaution id corresponding to the current element.
Definition: scheme.h:636
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
virtual void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the beginning of each solution step.
Definition: scheme.h:272
typename TSparseSpace::DataType TDataType
Data type definition.
Definition: scheme.h:68
A scheme for the solution of a problem using Aitken iterations.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:54
void InitializeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Initialize the iteration counter at the begining of each solution step.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:110
BaseType::TDataType TDataType
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:64
ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > BaseType
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:62
BaseType::TSystemVectorType TSystemVectorType
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:70
Kratos::shared_ptr< TSystemVectorType > SystemVectorPointerType
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:72
BaseType::TSystemMatrixType TSystemMatrixType
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:68
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Update the degrees of freedom of the problem using Aitken's accelerator.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:126
void UpdateWithRelaxation(DofsArrayType &rDofSet, TSystemVectorType &Dx, const double Omega)
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:262
bool DofImporterIsInitialized() const
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:362
TrilinosResidualBasedIncrementalAitkenStaticScheme(double DefaultOmega)
Default constructor.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:84
Kratos::shared_ptr< Epetra_Import > pGetImporter()
Get pointer Epetra_Import instance that can be used to import values from Dx to the owner of each Dof...
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:353
KRATOS_CLASS_POINTER_DEFINITION(TrilinosResidualBasedIncrementalAitkenStaticScheme)
Pointer definition of TrilinosResidualBasedIncrementalAitkenStaticScheme.
virtual void InitializeDofImporter(DofsArrayType &rDofSet, TSystemVectorType &Dx)
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:303
virtual ~TrilinosResidualBasedIncrementalAitkenStaticScheme()
Destructor.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:91
BaseType::DofsArrayType DofsArrayType
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:66
double CalculateOmega(TSystemVectorType &Dx)
Calculate the value of the Aitken relaxation factor for the current iteration.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:212
void Clear() override
Liberate internal storage.
Definition: trilinos_residualbased_incremental_aitken_static_scheme.h:164
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#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::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
def GetSolutionStepValue(entity, variable, solution_step_index)
Definition: coupling_interface_data.py:253
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
float temp
Definition: rotating_cone.py:85
int counter
Definition: script_THERMAL_CORRECT.py:218
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17