14 #if !defined(KRATOS_EXPLICIT_BUILDER)
15 #define KRATOS_EXPLICIT_BUILDER
19 #include <unordered_set>
66 template<
class TSparseSpace,
class TDenseSpace >
110 typedef typename std::unordered_set<DofType::Pointer, DofPointerHasher>
DofSetType;
161 return Kratos::make_shared<ClassType>(ThisParameters);
321 const auto &r_elements_array = rModelPart.
Elements();
322 const auto &r_conditions_array = rModelPart.
Conditions();
323 const int n_elems =
static_cast<int>(r_elements_array.size());
324 const int n_conds =
static_cast<int>(r_conditions_array.size());
328 #pragma omp parallel firstprivate(n_elems, n_conds)
330 #pragma omp for schedule(guided, 512) nowait
332 for (
int i_elem = 0; i_elem < n_elems; ++i_elem) {
333 auto it_elem = r_elements_array.
begin() + i_elem;
335 if (it_elem->IsActive()) {
338 it_elem->AddExplicitContribution(r_process_info);
343 #pragma omp for schedule(guided, 512)
344 for (
int i_cond = 0; i_cond < n_conds; ++i_cond) {
345 auto it_cond = r_conditions_array.begin() + i_cond;
347 if (it_cond->IsActive()) {
350 it_cond->AddExplicitContribution(r_process_info);
386 KRATOS_WARNING(
"ExplicitBuilder") <<
"Calling Initialize() with already initialized DOF set. Initializing lumped mass vector." << std::endl;;
390 KRATOS_WARNING(
"ExplicitBuilder") <<
"Calling Initialize() with already initialized DOF set and lumped mass vector." << std::endl;;
464 "name" : "explicit_builder"
466 return default_parameters;
475 return "explicit_builder";
517 virtual std::string
Info()
const
519 return "ExplicitBuilder";
588 const auto &r_elements_array = rModelPart.
Elements();
589 const auto &r_conditions_array = rModelPart.
Conditions();
591 const int n_elems =
static_cast<int>(r_elements_array.size());
592 const int n_conds =
static_cast<int>(r_conditions_array.size());
593 const int n_constraints =
static_cast<int>(r_constraints_array.size());
597 dof_global_set.reserve(n_elems*20);
603 #pragma omp parallel firstprivate(dof_list, second_dof_list)
609 dofs_tmp_set.reserve(20000);
612 #pragma omp for schedule(guided, 512) nowait
613 for (
int i_elem = 0; i_elem < n_elems; ++i_elem) {
614 const auto it_elem = r_elements_array.
begin() + i_elem;
615 it_elem->GetDofList(dof_list, r_process_info);
616 dofs_tmp_set.insert(dof_list.begin(), dof_list.end());
620 #pragma omp for schedule(guided, 512) nowait
621 for (
int i_cond = 0; i_cond < n_conds; ++i_cond) {
622 const auto it_cond = r_conditions_array.begin() + i_cond;
623 it_cond->GetDofList(dof_list, r_process_info);
624 dofs_tmp_set.insert(dof_list.begin(), dof_list.end());
628 #pragma omp for schedule(guided, 512) nowait
629 for (
int i_const = 0; i_const < n_constraints; ++i_const) {
630 auto it_const = r_constraints_array.begin() + i_const;
631 it_const->GetDofList(dof_list, second_dof_list, r_process_info);
632 dofs_tmp_set.insert(dof_list.begin(), dof_list.end());
633 dofs_tmp_set.insert(second_dof_list.begin(), second_dof_list.end());
639 dof_global_set.insert(dofs_tmp_set.begin(), dofs_tmp_set.end());
648 temp_dof_set.
reserve(dof_global_set.size());
649 for (
auto it_dof = dof_global_set.begin(); it_dof != dof_global_set.end(); ++it_dof) {
662 KRATOS_ERROR_IF_NOT(it_dof->HasReaction()) <<
"Reaction variable not set for the following : " << std::endl
663 <<
"Node : " << it_dof->Id() << std::endl
664 <<
"Dof : " << (*it_dof) << std::endl <<
"Not possible to calculate reactions." << std::endl;
690 it_dof->SetEquationId(i_dof);
716 std::vector<std::size_t> elem_equation_id;
717 const auto &r_elements_array = rModelPart.
Elements();
719 const int n_elems =
static_cast<int>(r_elements_array.size());
721 #pragma omp for private(elem_mass_vector) schedule(guided, 512) nowait
722 for (
int i_elem = 0; i_elem < n_elems; ++i_elem) {
723 const auto it_elem = r_elements_array.
begin() + i_elem;
726 it_elem->CalculateLumpedMassVector(elem_mass_vector, r_process_info);
727 it_elem->EquationIdVector(elem_equation_id, r_process_info);
730 for (
IndexType i = 0;
i < elem_equation_id.size(); ++
i) {
781 r_reaction_value *= -1.0;
799 return ThisParameters;
830 static std::vector<Internals::RegisteredPrototypeBase<ClassType>> msPrototypes;
virtual int MyPID() const
Definition: communicator.cpp:91
iterator begin()
Iterator pointing to the beginning of the container.
Definition: data_value_container.h:209
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
TDataType & GetSolutionStepReactionValue(IndexType SolutionStepIndex=0)
Definition: dof.h:278
Current class provides an implementation for the base explicit builder and solving operations.
Definition: explicit_builder.h:68
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: explicit_builder.h:115
std::size_t IndexType
Definition of the index type.
Definition: explicit_builder.h:77
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: explicit_builder.h:793
ModelPart::DofsVectorType DofsVectorType
Definition of the DoF vector type.
Definition: explicit_builder.h:107
KRATOS_CLASS_POINTER_DEFINITION(ExplicitBuilder)
Pointer definition of ExplicitBuilder.
TDenseSpace::VectorType LocalSystemVectorType
The local vector definition.
Definition: explicit_builder.h:98
PointerVectorSet< Element, IndexedObject > ElementsContainerType
The definition of the element container type.
Definition: explicit_builder.h:118
virtual void Initialize(ModelPart &rModelPart)
It applied those operations that are expected to be executed once.
Definition: explicit_builder.h:377
bool GetCalculateReactionsFlag() const
This method returns the flag mCalculateReactionsFlag.
Definition: explicit_builder.h:177
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: explicit_builder.h:473
unsigned int mEquationSystemSize
Flag taking in account if it is needed or not to calculate the reactions.
Definition: explicit_builder.h:563
virtual int Check(const ModelPart &rModelPart) const
This function is designed to be called once to perform all the checks needed on the input provided....
Definition: explicit_builder.h:447
bool mResetDofSetFlag
Definition: explicit_builder.h:553
bool GetResetLumpedMassVectorFlag() const
This method returns the flag GetResetLumpedMassVectorFlag.
Definition: explicit_builder.h:231
virtual void ApplyConstraints(ModelPart &rModelPart)
Applies the constraints.
Definition: explicit_builder.h:364
virtual void FinalizeSolutionStep(ModelPart &rModelPart)
It applies certain operations at the system of equations at the end of the solution step.
Definition: explicit_builder.h:420
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: explicit_builder.h:523
DofsArrayType & GetDofSet()
It allows to get the list of Dofs from the element.
Definition: explicit_builder.h:257
ExplicitBuilder()=default
Construct a new Explicit Builder object Default empty constructor.
TSparseSpace::MatrixType TSystemMatrixType
Definition of the sparse matrix.
Definition: explicit_builder.h:83
void SetResetLumpedMassVectorFlag(bool ResetLumpedMassVectorFlag)
This method sets the flag mResetLumpedMassVectorFlag.
Definition: explicit_builder.h:240
ModelPart::NodesContainerType NodesArrayType
The containers of the entities.
Definition: explicit_builder.h:113
virtual void SetUpDofSet(const ModelPart &rModelPart)
Builds the list of the DofSets involved in the problem by "asking" to each element and condition its ...
Definition: explicit_builder.h:581
virtual void SetUpDofSetEquationIds()
Set the Up Dof Set Equation Ids object Set up the DOF set equation ids.
Definition: explicit_builder.h:680
virtual std::string Info() const
Turn back information as a string.
Definition: explicit_builder.h:517
virtual ~ExplicitBuilder()=default
Destroy the Explicit Builder object Default destructor.
TSparseSpace::MatrixPointerType TSystemMatrixPointerType
Definition of the pointer to the sparse matrix.
Definition: explicit_builder.h:89
bool mCalculateReactionsFlag
Flag taking care if the lumped mass vector was initialized or not.
Definition: explicit_builder.h:561
DofsArrayType mDofSet
Definition: explicit_builder.h:549
std::unordered_set< DofType::Pointer, DofPointerHasher > DofSetType
The definition of the DoF set type.
Definition: explicit_builder.h:110
ModelPart::DofsArrayType DofsArrayType
Definition of the DoF array type.
Definition: explicit_builder.h:104
int mEchoLevel
Number of degrees of freedom of the problem to be solve.
Definition: explicit_builder.h:565
virtual void BuildRHS(ModelPart &rModelPart)
Function to perform the build of the RHS. The vector could be sized as the total number of dofs or as...
Definition: explicit_builder.h:296
virtual void InitializeDofSetReactions()
Initialize the DOF set reactions For an already initialized dof set (mDofSet), this method sets to ze...
Definition: explicit_builder.h:747
bool mResetLumpedMassVectorFlag
If the DOF set requires to be set at each time step.
Definition: explicit_builder.h:555
bool mDofSetIsInitialized
If the lumped mass vector requires to be set at each time step.
Definition: explicit_builder.h:557
void SetDofSetIsInitializedFlag(bool DofSetIsInitialized)
This method sets the flag mDofSetIsInitialized.
Definition: explicit_builder.h:204
virtual void CalculateReactions()
It computes the reactions of the system.
Definition: explicit_builder.h:766
virtual ClassType::Pointer Create(Parameters ThisParameters) const
Create method.
Definition: explicit_builder.h:159
std::size_t SizeType
Definition of the size type.
Definition: explicit_builder.h:74
ModelPart::ElementsContainerType ElementsArrayType
Definition: explicit_builder.h:114
TSparseSpace::DataType TDataType
Definition of the data type.
Definition: explicit_builder.h:80
bool GetDofSetIsInitializedFlag() const
This method returns the flag mDofSetIsInitialized.
Definition: explicit_builder.h:195
virtual Parameters GetDefaultParameters() const
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: explicit_builder.h:460
void SetCalculateReactionsFlag(bool CalculateReactionsFlag)
This method sets the flag mCalculateReactionsFlag.
Definition: explicit_builder.h:186
TSystemVectorPointerType & pGetLumpedMassMatrixVector()
Get the lumped mass matrix vector pointer It allows to get the lumped mass matrix vector pointer.
Definition: explicit_builder.h:275
ExplicitBuilder(Parameters ThisParameters)
Construct a new Explicit Builder object Default constructor with Parameters.
Definition: explicit_builder.h:135
const DofsArrayType & GetDofSet() const
It allows to get the list of Dofs from the element.
Definition: explicit_builder.h:265
virtual void InitializeSolutionStep(ModelPart &rModelPart)
It applies certain operations at the system of equations at the beginning of the solution step.
Definition: explicit_builder.h:398
bool GetResetDofSetFlag() const
This method returns the flag mReshapeMatrixFlag.
Definition: explicit_builder.h:213
void SetEchoLevel(int Level)
It sets the level of echo for the solving strategy.
Definition: explicit_builder.h:488
unsigned int GetEquationSystemSize() const
This method returns the value mEquationSystemSize.
Definition: explicit_builder.h:249
bool mLumpedMassVectorIsInitialized
Flag taking care if the dof set was initialized ot not.
Definition: explicit_builder.h:559
ExplicitBuilder< TSparseSpace, TDenseSpace > ClassType
The definition of the current class.
Definition: explicit_builder.h:121
TSystemVectorPointerType mpLumpedMassVector
The set containing the DoF of the system.
Definition: explicit_builder.h:551
virtual void Clear()
This function is intended to be called at the end of the solution step to clean up memory storage not...
Definition: explicit_builder.h:432
TSparseSpace::VectorPointerType TSystemVectorPointerType
Definition of the pointer to the vector.
Definition: explicit_builder.h:92
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: explicit_builder.h:529
int GetEchoLevel() const
It returns the echo level.
Definition: explicit_builder.h:497
TSparseSpace::VectorType TSystemVectorType
Definition of the vector size.
Definition: explicit_builder.h:86
virtual void SetUpLumpedMassVector(const ModelPart &rModelPart)
Set the Up Lumped Mass Vector object This method sets up the lumped mass vector used in the explicit ...
Definition: explicit_builder.h:703
TDenseSpace::MatrixType LocalSystemMatrixType
The local matrix definition.
Definition: explicit_builder.h:95
void SetResetDofSetFlag(bool ResetDofSetFlag)
This method sets the flag mResetDofSetFlag.
Definition: explicit_builder.h:222
virtual void BuildRHSNoDirichlet(ModelPart &rModelPart)
Function to perform the build of the RHS. The vector could be sized as the total number of dofs or as...
Definition: explicit_builder.h:313
TSystemVectorType & GetLumpedMassMatrixVector()
Get the lumped mass matrix vector It allows to get the lumped mass matrix vector.
Definition: explicit_builder.h:285
ModelPart::DofType DofType
Definition of the DoF class.
Definition: explicit_builder.h:101
virtual void AssignSettings(const Parameters ThisParameters)
This method assigns settings to member variables.
Definition: explicit_builder.h:806
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MasterSlaveConstraintContainerType & MasterSlaveConstraints(IndexType ThisIndex=0)
Definition: model_part.h:654
Communicator & GetCommunicator()
Definition: model_part.h:1821
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
std::vector< DofType::Pointer > DofsVectorType
Definition: model_part.h:110
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
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
void Sort()
Sort the elements in the set.
Definition: pointer_vector_set.h:753
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
void reserve(int reservedsize)
Reserves memory for a specified number of elements.
Definition: pointer_vector_set.h:733
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
#define KRATOS_WARNING(label)
Definition: logger.h:265
void ApplyConstraints(ModelPart &rModelPart)
This method resets the values of the slave dofs.
Definition: constraint_utilities.cpp:159
void ResetSlaveDofs(ModelPart &rModelPart)
This method resets the values of the slave dofs.
Definition: constraint_utilities.cpp:136
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void AtomicAdd(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:55
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
integer i
Definition: TensorModule.f:17