10 #if !defined(KRATOS_SOLUTION_SCHEME_H_INCLUDED)
11 #define KRATOS_SOLUTION_SCHEME_H_INCLUDED
50 template<
class TSparseSpace,
160 mOptions.
Set(LocalFlagType::UPDATE_VARIABLES,
true);
163 mOptions.
Set(LocalFlagType::INCREMENTAL_SOLUTION,
true);
188 this->
Set(LocalFlagType::INITIALIZED,
true);
203 for(
typename ProcessPointerVectorType::iterator it=
mProcesses.begin(); it!=
mProcesses.end(); ++it)
204 (*it)->ExecuteInitializeSolutionStep();
206 #pragma omp parallel for
207 for(
int i=0; i<static_cast<int>(rModelPart.
Elements().size());
i++)
210 itElem->InitializeSolutionStep(rCurrentProcessInfo);
213 #pragma omp parallel for
214 for(
int i=0; i<static_cast<int>(rModelPart.
Conditions().size());
i++)
217 itCond->InitializeSolutionStep(rCurrentProcessInfo);
235 for(
typename ProcessPointerVectorType::iterator it=
mProcesses.begin(); it!=
mProcesses.end(); ++it)
236 (*it)->ExecuteFinalizeSolutionStep();
239 #pragma omp parallel for
240 for(
int i=0; i<static_cast<int>(rModelPart.
Elements().size());
i++)
243 itElem->FinalizeSolutionStep(rCurrentProcessInfo);
247 #pragma omp parallel for
248 for(
int i=0; i<static_cast<int>(rModelPart.
Conditions().size());
i++)
251 itCond->FinalizeSolutionStep(rCurrentProcessInfo);
267 for(
typename ProcessPointerVectorType::iterator it=
mProcesses.begin(); it!=
mProcesses.end(); ++it)
268 (*it)->ExecuteInitialize();
270 #pragma omp parallel for
271 for(
int i=0; i<static_cast<int>(rModelPart.
Elements().size());
i++)
274 itElem->InitializeNonLinearIteration(rCurrentProcessInfo);
278 #pragma omp parallel for
279 for(
int i=0; i<static_cast<int>(rModelPart.
Conditions().size());
i++)
282 itCond->InitializeNonLinearIteration(rCurrentProcessInfo);
298 for(
typename ProcessPointerVectorType::iterator it=
mProcesses.begin(); it!=
mProcesses.end(); ++it)
299 (*it)->ExecuteFinalize();
303 #pragma omp parallel for
304 for(
int i=0; i<static_cast<int>(rModelPart.
Elements().size());
i++)
307 itElem->FinalizeNonLinearIteration(rCurrentProcessInfo);
311 #pragma omp parallel for
312 for(
int i=0; i<static_cast<int>(rModelPart.
Conditions().size());
i++)
315 itCond->FinalizeNonLinearIteration(rCurrentProcessInfo);
366 const int ndof =
static_cast<int>(rDofSet.
size());
369 #pragma omp parallel for firstprivate(DofBegin)
370 for(
int i = 0;
i < ndof;
i++)
374 if (itDof->IsFree() )
400 const int ndof =
static_cast<int>(rDofSet.
size());
403 #pragma omp parallel for firstprivate(DofBegin)
404 for(
int i = 0;
i < ndof;
i++)
408 if (itDof->IsFree() )
427 if(
mOptions.
Is(LocalFlagType::INCREMENTAL_SOLUTION) )
445 if( this->
mOptions.
Is(LocalFlagType::UPDATE_VARIABLES) ){
452 const int nnodes =
static_cast<int>(rModelPart.
Nodes().size());
453 NodesContainerType::iterator NodeBegin = rModelPart.
Nodes().begin();
455 #pragma omp parallel for firstprivate(NodeBegin)
458 NodesContainerType::iterator itNode = NodeBegin +
i;
480 const int nnodes =
static_cast<int>(rModelPart.
Nodes().size());
481 NodesContainerType::iterator NodeBegin = rModelPart.
Nodes().begin();
483 #pragma omp parallel for firstprivate(NodeBegin)
486 NodesContainerType::iterator itNode = NodeBegin +
i;
503 if( this->
mOptions.
Is(LocalFlagType::MOVE_MESH) ){
505 if (rModelPart.
NodesBegin()->SolutionStepsDataHas(DISPLACEMENT_X) ==
false)
507 KRATOS_ERROR <<
"It is impossible to move the mesh since the DISPLACEMENT variable is not in the Model Part. Add DISPLACEMENT to the list of variables" << std::endl;
510 bool DisplacementIntegration =
false;
514 if(
"DISPLACEMENT" == (*it)->GetVariableName() ){
515 DisplacementIntegration =
true;
520 if(DisplacementIntegration ==
true){
524 ModelPart::NodesContainerType::iterator it_begin = rModelPart.
NodesBegin();
526 #pragma omp parallel for
529 ModelPart::NodesContainerType::iterator it_node = it_begin +
i;
531 noalias(it_node->Coordinates()) = it_node->GetInitialPosition().Coordinates();
532 noalias(it_node->Coordinates()) += it_node->FastGetSolutionStepValue(DISPLACEMENT);
545 virtual void Clear(Element::Pointer rCurrentElement)
552 virtual void Clear(Condition::Pointer rCurrentCondition)
569 for(ModelPart::ElementsContainerType::iterator it=rModelPart.
ElementsBegin();
575 for(ModelPart::ConditionsContainerType::iterator it=rModelPart.
ConditionsBegin();
615 pCurrentElement->CalculateLocalSystem(rLHS_Contribution, rRHS_Contribution, rCurrentProcessInfo);
616 pCurrentElement->EquationIdVector(rEquationId, rCurrentProcessInfo);
631 pCurrentElement->CalculateRightHandSide(rRHS_Contribution, rCurrentProcessInfo);
632 pCurrentElement->EquationIdVector(rEquationId, rCurrentProcessInfo);
646 std::cout<<
" it is C_LHS "<<std::endl;
647 pCurrentElement->CalculateLeftHandSide(rLHS_Contribution, rCurrentProcessInfo);
648 pCurrentElement->EquationIdVector(rEquationId, rCurrentProcessInfo);
655 (pCurrentElement)->EquationIdVector(rEquationId, rCurrentProcessInfo);
672 pCurrentCondition->CalculateLocalSystem(rLHS_Contribution, rRHS_Contribution, rCurrentProcessInfo);
673 pCurrentCondition->EquationIdVector(rEquationId, rCurrentProcessInfo);
688 pCurrentCondition->CalculateRightHandSide(rRHS_Contribution, rCurrentProcessInfo);
689 pCurrentCondition->EquationIdVector(rEquationId, rCurrentProcessInfo);
704 pCurrentCondition->CalculateLeftHandSide(rLHS_Contribution, rCurrentProcessInfo);
705 pCurrentCondition->EquationIdVector(rEquationId, rCurrentProcessInfo);
712 (pCurrentCondition)->EquationIdVector(rEquationId, rCurrentProcessInfo);
725 pCurrentElement->GetDofList(rElementalDofList, rCurrentProcessInfo);
738 pCurrentCondition->GetDofList(rConditionDofList, rCurrentProcessInfo);
822 if( this->
IsNot(LocalFlagType::ELEMENTS_INITIALIZED) ){
824 #pragma omp parallel for
825 for(
int i=0; i<static_cast<int>(rModelPart.
Elements().size());
i++)
831 this->
Set(LocalFlagType::ELEMENTS_INITIALIZED,
true);
846 if( this->
IsNot(LocalFlagType::ELEMENTS_INITIALIZED) )
847 KRATOS_ERROR <<
"Before initilizing Conditions, initialize Elements FIRST" << std::endl;
849 if( this->
IsNot(LocalFlagType::CONDITIONS_INITIALIZED) ){
851 #pragma omp parallel for
852 for(
int i=0; i<static_cast<int>(rModelPart.
Conditions().size());
i++)
858 this->
Set(LocalFlagType::CONDITIONS_INITIALIZED,
true);
873 rCurrentCondition->InitializeNonLinearIteration(rCurrentProcessInfo);
887 rCurrentElement->InitializeNonLinearIteration(rCurrentProcessInfo);
897 (*it)->Update(rNode);
900 (*it)->Update(rNode);
907 (*it)->Predict(rNode);
910 (*it)->Predict(rNode);
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
bool IsNotDefined(Flags const &rOther) const
Definition: flags.h:296
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
This class defines the node.
Definition: node.h:65
static void DivideInPartitions(const int NumTerms, const int NumThreads, PartitionVector &Partitions)
Divide an array of length NumTerms between NumThreads threads.
Definition: openmp_utils.h:158
std::vector< int > PartitionVector
Vector type for the output of DivideInPartitions method.
Definition: openmp_utils.h:53
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
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::iterator > iterator
Definition: pointer_vector_set.h:95
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
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Solution scheme base class.
Definition: solution_scheme.hpp:54
virtual void InitializeConditions(ModelPart &rModelPart)
Initialize the conditions.
Definition: solution_scheme.hpp:842
virtual void Condition_Calculate_RHS_Contribution(Condition::Pointer pCurrentCondition, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:683
SolutionScheme(IntegrationMethodsScalarType &rTimeScalarIntegrationMethods)
Constructor.
Definition: solution_scheme.hpp:111
SolutionScheme(IntegrationMethodsVectorType &rTimeVectorIntegrationMethods, Flags &rOptions)
Constructor.
Definition: solution_scheme.hpp:102
virtual void UpdateDofs(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemVectorType &rDx)
Performing the update of the solution Dofs.
Definition: solution_scheme.hpp:421
IntegrationVectorType::Pointer IntegrationVectorPointerType
Definition: solution_scheme.hpp:77
virtual void InitializeNonLinearIteration(Condition::Pointer rCurrentCondition, ProcessInfo &rCurrentProcessInfo)
Initialize the conditions.
Definition: solution_scheme.hpp:868
std::vector< IntegrationScalarPointerType > IntegrationMethodsScalarType
Definition: solution_scheme.hpp:83
virtual int Check(ModelPart &rModelPart)
This function is designed to be called once to perform all the checks needed.
Definition: solution_scheme.hpp:565
Flags & GetOptions()
Get strategy options.
Definition: solution_scheme.hpp:758
virtual void Clear()
Liberates internal storage.
Definition: solution_scheme.hpp:559
KRATOS_CLASS_POINTER_DEFINITION(SolutionScheme)
Pointer definition of SolutionScheme.
ProcessPointerVectorType mProcesses
Definition: solution_scheme.hpp:804
SolutionScheme(SolutionScheme &rOther)
Copy contructor.
Definition: solution_scheme.hpp:125
virtual void Clear(Condition::Pointer rCurrentCondition)
Liberates internal storage for a condition.
Definition: solution_scheme.hpp:552
array_1d< double, 3 > VectorType
Definition: solution_scheme.hpp:74
virtual void FinalizeNonLinearIteration(ModelPart &rModelPart)
Performs all the required operations that should be done (for each iteration) after solving a solutio...
Definition: solution_scheme.hpp:294
virtual void Predict(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemVectorType &rDx)
Performing the prediction of the solution.
Definition: solution_scheme.hpp:326
virtual void IntegrationMethodPredict(NodeType &rNode)
Definition: solution_scheme.hpp:903
SolutionSchemeType::Pointer SolutionSchemePointerType
Definition: solution_scheme.hpp:60
virtual void MoveMesh(ModelPart &rModelPart)
This function is designed to move the mesh.
Definition: solution_scheme.hpp:499
void SetProcess(ProcessPointerType pProcess)
Set process to execute after move_mesh.
Definition: solution_scheme.hpp:766
void SetOptions(Flags &rOptions)
Sets strategy options.
Definition: solution_scheme.hpp:749
virtual void Calculate_LHS_Contribution(Element::Pointer pCurrentElement, LocalSystemMatrixType &rLHS_Contribution, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:641
SolutionScheme(IntegrationMethodsVectorType &rTimeVectorIntegrationMethods)
Constructor.
Definition: solution_scheme.hpp:105
TDenseSpace::MatrixType LocalSystemMatrixType
Definition: solution_scheme.hpp:66
virtual void Initialize(ModelPart &rModelPart)
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: solution_scheme.hpp:172
void SetProcessVector(ProcessPointerVectorType &rProcessVector)
Set list of processes to execute after move_mesh.
Definition: solution_scheme.hpp:774
ModelPart::ElementsContainerType ElementsContainerType
Definition: solution_scheme.hpp:70
virtual void PredictVariables(ModelPart &rModelPart)
Performing the prediction of the solution variables.
Definition: solution_scheme.hpp:471
virtual void InitializeNonLinearIteration(Element::Pointer rCurrentElement, ProcessInfo &rCurrentProcessInfo)
Initialize the elements.
Definition: solution_scheme.hpp:882
SolutionScheme(IntegrationMethodsScalarType &rTimeScalarIntegrationMethods, Flags &rOptions)
Constructor.
Definition: solution_scheme.hpp:108
TDenseSpace::VectorType LocalSystemVectorType
Definition: solution_scheme.hpp:67
std::vector< ProcessPointerType > ProcessPointerVectorType
Definition: solution_scheme.hpp:86
TSparseSpace::MatrixType SystemMatrixType
Definition: solution_scheme.hpp:64
Variable< VectorType > VariableVectorType
Definition: solution_scheme.hpp:75
SolutionScheme(Flags &rOptions)
Constructor.
Definition: solution_scheme.hpp:99
void SetDefaultFlags()
SetDefaultSchemeFlags.
Definition: solution_scheme.hpp:152
ModelPart::NodeType NodeType
Definition: solution_scheme.hpp:73
virtual void Condition_Calculate_LHS_Contribution(Condition::Pointer pCurrentCondition, LocalSystemMatrixType &rLHS_Contribution, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:699
ModelPart::NodesContainerType NodesContainerType
Definition: solution_scheme.hpp:69
SolverProcess::Pointer ProcessPointerType
Definition: solution_scheme.hpp:85
static void SetSolution(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemVectorType &rDx)
Performing the update of the solution Dofs (total solution)
Definition: solution_scheme.hpp:354
virtual void GetElementalDofList(Element::Pointer pCurrentElement, Element::DofsVectorType &rElementalDofList, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:721
virtual void InitializeElements(ModelPart &rModelPart)
Initialize the elements.
Definition: solution_scheme.hpp:818
ModelPart::DofsArrayType DofsArrayType
Definition: solution_scheme.hpp:62
static void AddSolution(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemVectorType &rDx)
Performing the update of the solution Dofs (incremental solution)
Definition: solution_scheme.hpp:388
TimeIntegrationMethod< VariableVectorType, VectorType > IntegrationVectorType
Definition: solution_scheme.hpp:76
SolutionScheme< TSparseSpace, TDenseSpace > SolutionSchemeType
Definition: solution_scheme.hpp:59
virtual void GetConditionDofList(Condition::Pointer pCurrentCondition, Element::DofsVectorType &rConditionDofList, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:734
virtual SolutionSchemePointerType Clone()
Clone.
Definition: solution_scheme.hpp:132
virtual void InitializeSolutionStep(ModelPart &rModelPart)
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: solution_scheme.hpp:197
Flags mOptions
Definition: solution_scheme.hpp:797
virtual void Condition_EquationId(Condition::Pointer pCurrentCondition, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:708
IntegrationMethodsVectorType mTimeVectorIntegrationMethods
Definition: solution_scheme.hpp:800
virtual void Condition_CalculateSystemContributions(Condition::Pointer pCurrentCondition, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:666
IntegrationScalarType::Pointer IntegrationScalarPointerType
Definition: solution_scheme.hpp:82
SolutionScheme(IntegrationMethodsVectorType &rTimeVectorIntegrationMethods, IntegrationMethodsScalarType &rTimeScalarIntegrationMethods, Flags &rOptions)
Constructor.
Definition: solution_scheme.hpp:114
IntegrationMethodsScalarType mTimeScalarIntegrationMethods
Definition: solution_scheme.hpp:801
virtual void FinalizeSolutionStep(ModelPart &rModelPart)
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: solution_scheme.hpp:229
virtual void EquationId(Element::Pointer pCurrentElement, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:651
virtual void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemVectorType &rDx)
Performing the update of the solution.
Definition: solution_scheme.hpp:339
TSparseSpace::VectorType SystemVectorType
Definition: solution_scheme.hpp:65
virtual void UpdateVariables(ModelPart &rModelPart)
Performing the update of the solution variables.
Definition: solution_scheme.hpp:441
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: solution_scheme.hpp:71
virtual void IntegrationMethodUpdate(NodeType &rNode)
Definition: solution_scheme.hpp:893
virtual void Calculate_RHS_Contribution(Element::Pointer pCurrentElement, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:626
SolutionScheme()
Default Constructor.
Definition: solution_scheme.hpp:96
~SolutionScheme() override
Destructor.
Definition: solution_scheme.hpp:138
SolverLocalFlags LocalFlagType
Definition: solution_scheme.hpp:61
TimeIntegrationMethod< VariableScalarType, double > IntegrationScalarType
Definition: solution_scheme.hpp:81
virtual void CalculateSystemContributions(Element::Pointer pCurrentElement, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, ProcessInfo &rCurrentProcessInfo)
Definition: solution_scheme.hpp:609
virtual void InitializeNonLinearIteration(ModelPart &rModelPart)
Performs all the required operations that should be done (for each iteration) before solving a soluti...
Definition: solution_scheme.hpp:261
Variable< double > VariableScalarType
Definition: solution_scheme.hpp:80
SolutionScheme(IntegrationMethodsVectorType &rTimeVectorIntegrationMethods, IntegrationMethodsScalarType &rTimeScalarIntegrationMethods)
Constructor.
Definition: solution_scheme.hpp:120
std::vector< IntegrationVectorPointerType > IntegrationMethodsVectorType
Definition: solution_scheme.hpp:78
virtual void Clear(Element::Pointer rCurrentElement)
Liberates internal storage for an element.
Definition: solution_scheme.hpp:545
Solver local flags class definition.
Definition: solution_local_flags.hpp:48
Short class definition.
Definition: time_integration_method.hpp:55
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
end
Definition: DEM_benchmarks.py:180
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17