10 #if !defined(KRATOS_EXPLICIT_BUILDER_AND_SOLVER_H_INCLUDED)
11 #define KRATOS_EXPLICIT_BUILDER_AND_SOLVER_H_INCLUDED
45 template<
class TSparseSpace,
112 int number_of_threads = omp_get_max_threads();
114 int number_of_threads = 1;
117 vector<unsigned int> node_partition;
118 OpenMPUtils::CreatePartition(number_of_threads, pNodes.size(), node_partition);
120 vector<unsigned int> element_partition;
121 OpenMPUtils::CreatePartition(number_of_threads, pElements.size(), element_partition);
127 for(
int k=0;
k<number_of_threads;
k++)
129 typename NodesContainerType::iterator i_begin=pNodes.ptr_begin()+node_partition[
k];
130 typename NodesContainerType::iterator i_end=pNodes.ptr_begin()+node_partition[
k+1];
134 double& nodal_mass =
i->FastGetSolutionStepValue(NODAL_MASS);
143 bool CalculateLumpedMassMatrix =
false;
144 if( rCurrentProcessInfo.
Has(COMPUTE_LUMPED_MASS_MATRIX) ){
145 CalculateLumpedMassMatrix = rCurrentProcessInfo[COMPUTE_LUMPED_MASS_MATRIX];
151 typename ElementsContainerType::iterator ElemBegin = pElements.begin() + element_partition[
k];
152 typename ElementsContainerType::iterator ElemEnd = pElements.begin() + element_partition[
k + 1];
154 for (
typename ElementsContainerType::iterator itElem = ElemBegin; itElem != ElemEnd; ++itElem)
160 (itElem)->CalculateMassMatrix(MassMatrix, rCurrentProcessInfo);
164 unsigned int index = 0;
165 for (
unsigned int i = 0;
i <geometry.
size();
i++)
169 double& mass = geometry(
i)->FastGetSolutionStepValue(NODAL_MASS);
171 geometry(
i)->SetLock();
173 if(!CalculateLumpedMassMatrix){
174 for (
unsigned int j = 0;
j <MassMatrix.size2();
j++)
176 mass += MassMatrix(index,
j);
180 mass += MassMatrix(index,index);
183 geometry(
i)->UnSetLock();
188 rCurrentProcessInfo[COMPUTE_LUMPED_MASS_MATRIX] = CalculateLumpedMassMatrix;
225 int number_of_threads = omp_get_max_threads();
227 int number_of_threads = 1;
230 vector<unsigned int> condition_partition;
231 OpenMPUtils::CreatePartition(number_of_threads, rConditions.size(), condition_partition);
234 #pragma omp parallel for
235 for(
int k=0;
k<number_of_threads;
k++)
237 typename ConditionsContainerType::ptr_iterator it_begin=rConditions.ptr_begin()+condition_partition[
k];
238 typename ConditionsContainerType::ptr_iterator it_end=rConditions.ptr_begin()+condition_partition[
k+1];
240 for (
typename ConditionsContainerType::ptr_iterator it= it_begin; it!=it_end; ++it)
247 pScheme->Condition_Calculate_RHS_Contribution(*it, RHS_Condition_Contribution, EquationId, rCurrentProcessInfo);
266 int number_of_threads = omp_get_max_threads();
268 int number_of_threads = 1;
271 vector<unsigned int> element_partition;
272 OpenMPUtils::CreatePartition(number_of_threads, pElements.size(), element_partition);
274 #pragma omp parallel for
275 for(
int k=0;
k<number_of_threads;
k++)
277 typename ElementsContainerType::ptr_iterator it_begin=pElements.ptr_begin()+element_partition[
k];
278 typename ElementsContainerType::ptr_iterator it_end=pElements.ptr_begin()+element_partition[
k+1];
279 for (
typename ElementsContainerType::ptr_iterator it= it_begin; it!=it_end; ++it)
285 pScheme->Calculate_RHS_Contribution(*it, RHS_Contribution, EquationId, rCurrentProcessInfo);
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
Explicit Solution Buider and Solver base class.
Definition: explicit_builder_and_solver.hpp:50
ModelPart::ElementsContainerType ElementsContainerType
Definition: explicit_builder_and_solver.hpp:73
BaseType::SchemePointerType SchemePointerType
Definition: explicit_builder_and_solver.hpp:76
ExplicitBuilderAndSolver()
Default Constructor.
Definition: explicit_builder_and_solver.hpp:83
void CalculateAndAddElementsRHS(SchemePointerType pScheme, ModelPart &rModelPart)
Definition: explicit_builder_and_solver.hpp:256
void BuildLHS(SchemePointerType pScheme, ModelPart &rModelPart, SystemMatrixType &rA) override
Function to perform the building of the LHS,.
Definition: explicit_builder_and_solver.hpp:100
BaseType::SystemVectorType SystemVectorType
Definition: explicit_builder_and_solver.hpp:66
BaseType::SystemVectorPointerType SystemVectorPointerType
Definition: explicit_builder_and_solver.hpp:68
void BuildRHS(SchemePointerType pScheme, ModelPart &rModelPart, SystemVectorType &rb) override
Function to perform the build of the RHS.
Definition: explicit_builder_and_solver.hpp:197
SolutionBuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: explicit_builder_and_solver.hpp:60
ModelPart::NodesContainerType NodesContainerType
Definition: explicit_builder_and_solver.hpp:72
void Clear() override
This function is intended to be called at the end of the solution step to clean up memory storage not...
Definition: explicit_builder_and_solver.hpp:297
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: explicit_builder_and_solver.hpp:69
BaseType::SystemMatrixPointerType SystemMatrixPointerType
Definition: explicit_builder_and_solver.hpp:67
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: explicit_builder_and_solver.hpp:70
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: explicit_builder_and_solver.hpp:74
int Check(ModelPart &rModelPart) override
Definition: explicit_builder_and_solver.hpp:309
KRATOS_CLASS_POINTER_DEFINITION(ExplicitBuilderAndSolver)
Pointer definition of ExplicitBuilderAndSolver.
BaseType::LocalFlagType LocalFlagType
Definition: explicit_builder_and_solver.hpp:62
BaseType::SystemMatrixType SystemMatrixType
Definition: explicit_builder_and_solver.hpp:65
~ExplicitBuilderAndSolver() override
Destructor.
Definition: explicit_builder_and_solver.hpp:89
BaseType::DofsArrayType DofsArrayType
Definition: explicit_builder_and_solver.hpp:63
void CalculateAndAddConditionsRHS(SchemePointerType pScheme, ModelPart &rModelPart)
Definition: explicit_builder_and_solver.hpp:215
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
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
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Solution Buider and Solver base class.
Definition: solution_builder_and_solver.hpp:63
virtual void Clear()
This function is intended to be called at the end of the solution step to clean up memory storage not...
Definition: solution_builder_and_solver.hpp:305
TSparseSpace::MatrixPointerType SystemMatrixPointerType
Definition: solution_builder_and_solver.hpp:78
TSparseSpace::VectorType SystemVectorType
Definition: solution_builder_and_solver.hpp:76
TDenseSpace::VectorType LocalSystemVectorType
Definition: solution_builder_and_solver.hpp:82
TSparseSpace::MatrixType SystemMatrixType
Definition: solution_builder_and_solver.hpp:75
TDenseSpace::MatrixType LocalSystemMatrixType
Definition: solution_builder_and_solver.hpp:81
TSparseSpace::VectorPointerType SystemVectorPointerType
Definition: solution_builder_and_solver.hpp:79
SchemeType::Pointer SchemePointerType
Definition: solution_builder_and_solver.hpp:85
Solver local flags class definition.
Definition: solution_local_flags.hpp:48
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17