17 #include <unordered_set>
18 #include <unordered_map>
57 template<
class TSparseSpace,
137 typename TLinearSolver::Pointer pNewLinearSystemSolver,
139 ) :
BaseType(pNewLinearSystemSolver)
149 typename TLinearSolver::Pointer pNewLinearSystemSolver)
173 typename BaseBuilderAndSolverType::Pointer
Create(
174 typename TLinearSolver::Pointer pNewLinearSystemSolver,
178 return Kratos::make_shared<ClassType>(pNewLinearSystemSolver,ThisParameters);
190 SetUpSystemWithConstraints(rModelPart);
192 BaseSetUpSystem(rModelPart);
204 typename TSchemeType::Pointer pScheme,
222 "name" : "contact_residual_elimination_builder_and_solver_with_constraints"
228 return default_parameters;
237 return "contact_residual_elimination_builder_and_solver_with_constraints";
277 typename TSchemeType::Pointer pScheme,
284 if (rModelPart.
NodesBegin()->SolutionStepsDataHas(VECTOR_LAGRANGE_MULTIPLIER)) {
288 constrain.SetId(constraint_id);
302 #pragma omp parallel firstprivate(transformation_matrix, constant_vector, dof_list, second_dof_list)
312 const int number_of_constraints =
static_cast<int>(r_constraints_array.size());
313 #pragma omp for schedule(guided, 512)
314 for (
int i = 0;
i < number_of_constraints; ++
i) {
315 auto it_const = r_constraints_array.begin() +
i;
318 it_const->GetDofList(dof_list, second_dof_list, r_current_process_info);
319 it_const->CalculateLocalSystem(transformation_matrix, constant_vector, r_current_process_info);
322 bool create_lm_constraint =
false;
325 bool slave_nodes_master_dof =
false;
327 for (
auto& p_dof : second_dof_list) {
328 if (IsDisplacementDof(*p_dof)) {
331 if (pnode->Is(SLAVE)) {
332 slave_nodes_master_dof =
true;
339 for (
auto& p_dof : dof_list) {
340 if (IsDisplacementDof(*p_dof)) {
342 const auto& r_variable = p_dof->GetVariable();
344 if (pnode->IsNot(INTERFACE) || slave_nodes_master_dof) {
345 if (r_variable == DISPLACEMENT_X) {
346 slave_dofs.push_back(pnode->pGetDof(VECTOR_LAGRANGE_MULTIPLIER_X));
347 }
else if (r_variable == DISPLACEMENT_Y) {
348 slave_dofs.push_back(pnode->pGetDof(VECTOR_LAGRANGE_MULTIPLIER_Y));
349 }
else if (r_variable == DISPLACEMENT_Z) {
350 slave_dofs.push_back(pnode->pGetDof(VECTOR_LAGRANGE_MULTIPLIER_Z));
353 it_const->Set(TO_ERASE);
358 if (slave_nodes_master_dof) {
359 for (
auto& p_dof : second_dof_list) {
360 if (IsDisplacementDof(*p_dof)) {
362 const auto& r_variable = p_dof->GetVariable();
364 if (r_variable == DISPLACEMENT_X) {
365 master_dofs.push_back(pnode->pGetDof(VECTOR_LAGRANGE_MULTIPLIER_X));
366 }
else if (r_variable == DISPLACEMENT_Y) {
367 master_dofs.push_back(pnode->pGetDof(VECTOR_LAGRANGE_MULTIPLIER_Y));
368 }
else if (r_variable == DISPLACEMENT_Z) {
369 master_dofs.push_back(pnode->pGetDof(VECTOR_LAGRANGE_MULTIPLIER_Z));
376 if ((slave_dofs.size() == dof_list.size()) &&
377 (master_dofs.size() == second_dof_list.size())) {
378 create_lm_constraint =
true;
382 if (create_lm_constraint) {
383 auto p_constraint = r_clone_constraint.Create(constraint_id +
i + 1, master_dofs, slave_dofs, transformation_matrix, constant_vector);
384 (constraints_buffer).insert((constraints_buffer).begin(), p_constraint);
400 "Model part after creating new constraints" << rModelPart << std::endl;
451 void SetUpSystemWithConstraints(
ModelPart& rModelPart)
456 BaseSetUpSystem(rModelPart);
472 KRATOS_CATCH(
"ContactResidualBasedEliminationBuilderAndSolverWithConstraints::FormulateGlobalMasterSlaveRelations failed ..");
479 void BaseSetUpSystem(ModelPart& rModelPart)
486 std::unordered_map<IndexType, IndexSetType> set_nodes_with_lm_associated;
487 if (rModelPart.HasSubModelPart(
"Contact"))
488 set_nodes_with_lm_associated.reserve(rModelPart.GetSubModelPart(
"Contact").NumberOfNodes());
499 const IndexType key_lm_x = VECTOR_LAGRANGE_MULTIPLIER_X.Key();
500 const IndexType key_lm_y = VECTOR_LAGRANGE_MULTIPLIER_Y.Key();
501 const IndexType key_lm_z = VECTOR_LAGRANGE_MULTIPLIER_Z.Key();
506 auto it = set_nodes_with_lm_associated.find(
node_id);
507 if ( it != set_nodes_with_lm_associated.end()) {
508 if (i_dof.IsFixed()) {
509 const auto& r_variable = i_dof.GetVariable();
510 auto& aux_set = (it->second);
511 if (r_variable == DISPLACEMENT_X) {
512 aux_set.insert(key_lm_x);
513 }
else if (r_variable == DISPLACEMENT_Y) {
514 aux_set.insert(key_lm_y);
515 }
else if (r_variable == DISPLACEMENT_Z) {
516 aux_set.insert(key_lm_z);
524 if (i_dof.IsFree()) {
526 auto it = set_nodes_with_lm_associated.find(
node_id);
527 if (it != set_nodes_with_lm_associated.end()) {
528 auto& aux_set = it->second;
529 if (aux_set.find((i_dof.GetVariable()).Key()) != aux_set.end()) {
544 static inline bool IsDisplacementDof(
const DofType& rDoF)
546 const auto& r_variable = rDoF.GetVariable();
547 if (r_variable == DISPLACEMENT_X ||
548 r_variable == DISPLACEMENT_Y ||
549 r_variable == DISPLACEMENT_Z) {
561 static inline bool IsLMDof(
const DofType& rDoF)
563 const auto& r_variable = rDoF.GetVariable();
564 if (r_variable == VECTOR_LAGRANGE_MULTIPLIER_X ||
565 r_variable == VECTOR_LAGRANGE_MULTIPLIER_Y ||
566 r_variable == VECTOR_LAGRANGE_MULTIPLIER_Z) {
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
std::size_t IndexType
Definition of the index type.
Definition: builder_and_solver.h:76
TSparseSpace::VectorType TSystemVectorType
Definition of the vector size.
Definition: builder_and_solver.h:85
ModelPart::NodesContainerType NodesArrayType
The containers of the entities.
Definition: builder_and_solver.h:109
TSparseSpace::MatrixType TSystemMatrixType
Definition of the sparse matrix.
Definition: builder_and_solver.h:82
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: builder_and_solver.h:111
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: builder_and_solver.h:767
TDenseSpace::MatrixType LocalSystemMatrixType
The local matrix definition.
Definition: builder_and_solver.h:94
TSparseSpace::VectorPointerType TSystemVectorPointerType
Definition of the pointer to the vector.
Definition: builder_and_solver.h:91
TSparseSpace::DataType TDataType
Definition of the data type.
Definition: builder_and_solver.h:79
DofsArrayType mDofSet
Pointer to the linear solver.
Definition: builder_and_solver.h:739
TDenseSpace::VectorType LocalSystemVectorType
The local vector definition.
Definition: builder_and_solver.h:97
TSparseSpace::MatrixPointerType TSystemMatrixPointerType
Definition of the pointer to the sparse matrix.
Definition: builder_and_solver.h:88
std::size_t SizeType
Definition of the size type.
Definition: builder_and_solver.h:73
int GetEchoLevel() const
It returns the echo level.
Definition: builder_and_solver.h:674
unsigned int mEquationSystemSize
Flag taking in account if it is needed or not to calculate the reactions.
Definition: builder_and_solver.h:747
ModelPart::ElementsContainerType ElementsArrayType
Definition: builder_and_solver.h:110
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
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
void RemoveMasterSlaveConstraintsFromAllLevels(Flags IdentifierFlag=TO_ERASE)
It erases all constraints identified by "IdentifierFlag" by removing the pointer.
Definition: model_part.cpp:1411
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
MeshType::MasterSlaveConstraintContainerType MasterSlaveConstraintContainerType
Definition: model_part.h:219
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
void AddMasterSlaveConstraints(std::vector< IndexType > const &MasterSlaveConstraintIds, IndexType ThisIndex=0)
Definition: model_part.cpp:1200
NodeType::Pointer pGetNode(IndexType NodeId, IndexType ThisIndex=0)
Definition: model_part.h:421
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void RecursivelyAddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1457
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
iterator find(const key_type &Key)
Find an element with the specified key.
Definition: pointer_vector_set.h:678
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Element::DofsVectorType DofsVectorType
Definition: residualbased_elimination_builder_and_solver.h:105
Element::EquationIdVectorType EquationIdVectorType
Definition of the equation id vector.
Definition: residualbased_elimination_builder_and_solver.h:104
Current class provides an implementation for standard builder and solving operations.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:93
PointerVectorSet< Element, IndexedObject > ElementsContainerType
Additional definitions.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:130
Element::EquationIdVectorType EquationIdVectorType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:131
void SetUpDofSet(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart) override
Builds the list of the DofSets involved in the problem by "asking" to each element and condition its ...
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:302
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:122
std::unordered_set< IndexType > IndexSetType
Set definition.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:140
DofType::Pointer DofPointerType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:137
BaseType::TDataType TDataType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:116
BaseType::NodesArrayType NodesArrayType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:125
void SetUpSystem(ModelPart &rModelPart) override
Organises the dofset in order to speed up the building phase.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:220
BaseType::ConditionsArrayType ConditionsArrayType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:127
BaseType::ElementsArrayType ElementsArrayType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:126
Element::DofsVectorType DofsVectorType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:132
BaseType::TSystemVectorType TSystemVectorType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:119
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:121
BaseType::TSchemeType TSchemeType
Definition of the classes from the base class.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:115
SizeType mDoFToSolveSystemSize
The set containing the slave DoF of the system.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:390
DofsArrayType mDoFSlaveSet
The set containing the fixed master DoF of the system.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:389
NodeType::DofType DofType
DoF types definition.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:136
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:317
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:1456
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:123
void SetUpDofSetWithConstraints(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart)
Builds the list of the DofSets involved in the problem by "asking" to each element and condition its ...
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:577
BaseType::DofsArrayType DofsArrayType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:117
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:120
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residualbased_elimination_builder_and_solver_with_constraints.h:118
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
end
Definition: DEM_benchmarks.py:180
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int dof
Definition: ode_solve.py:393
int node_id
Definition: read_stl.py:12
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17