10 #if !defined(KRATOS_SETTLE_MODEL_STRUCTURE_PROCESS_H_INCLUDED )
11 #define KRATOS_SETTLE_MODEL_STRUCTURE_PROCESS_H_INCLUDED
156 std::string
Info()
const override
158 return "SettleModelStructureProcess";
164 rOStream <<
"SettleModelStructureProcess";
213 unsigned int consecutive_index = 1;
215 (i_cond)->SetId(++consecutive_index);
233 unsigned int consecutive_index = 1;
235 i_elem->SetId(++consecutive_index);
254 unsigned int consecutive_index = 1;
258 if(i_node->IsNot(STRUCTURE) ){
259 i_node->SetId(++consecutive_index);
262 i_node->SetId(reverse_index--);
284 if(NumberOfSubModelParts>0){
336 rModelPart.
Nodes().clear();
342 unsigned int nodeId=1;
343 unsigned int elemId=1;
344 unsigned int condId=1;
353 rModelPart.
Conditions().swap(PreservedConditions);
356 rModelPart.
Nodes().Unique();
361 unsigned int consecutive_index = 1;
362 for(ModelPart::NodesContainerType::iterator in = rModelPart.
NodesBegin() ; in != rModelPart.
NodesEnd() ; ++in)
363 in->SetId(++consecutive_index);
392 bool add_to_main_model_part =
false;
394 if( i_mp->IsNot(ACTIVE) && i_mp->IsNot(BOUNDARY) ){
396 if( i_mp->Is(SOLID) || i_mp->Is(FLUID) || i_mp->Is(RIGID) || i_mp->IsNot(CONTACT) )
397 add_to_main_model_part =
true;
401 if( add_to_main_model_part ){
405 std::cout<<
" [ SUBMODEL PART ["<<i_mp->Name()<<
"] [Elems="<<i_mp->NumberOfElements()<<
"|Nodes="<<i_mp->NumberOfNodes()<<
"|Conds="<<i_mp->NumberOfConditions()<<
"] ";
407 temporal_nodes.reserve(i_mp->Nodes().size());
408 temporal_nodes.swap(i_mp->Nodes());
411 if( !i_mp->NumberOfElements() ){
413 for(ModelPart::NodesContainerType::iterator i_node = temporal_nodes.begin() ; i_node != temporal_nodes.end() ; ++i_node)
415 if( i_node->IsNot(TO_ERASE) ){
416 (i_mp->Nodes()).push_back(*(i_node.base()));
417 (rModelPart.
Nodes()).push_back(*(i_node.base()));
418 rModelPart.
Nodes().back().SetId(rNodeId);
426 if( i_mp->Is(FLUID) )
427 for(ModelPart::NodesContainerType::iterator i_node = temporal_nodes.begin() ; i_node != temporal_nodes.end() ; ++i_node)
428 i_node->Set(FLUID,
false);
430 if( i_mp->Is(SOLID) )
431 for(ModelPart::NodesContainerType::iterator i_node = temporal_nodes.begin() ; i_node != temporal_nodes.end() ; ++i_node)
432 i_node->Set(SOLID,
false);
435 for(ModelPart::ElementsContainerType::iterator i_elem = i_mp->ElementsBegin() ; i_elem != i_mp->ElementsEnd() ; ++i_elem)
437 if( i_elem->IsNot(TO_ERASE) ){
443 for(
unsigned int i=0;
i<vertices.
size(); ++
i)
446 vertices[
i].Set(SOLID,
true);
449 else if(i_mp->Is(FLUID)){
451 for(
unsigned int i=0;
i<vertices.
size(); ++
i)
454 vertices[
i].Set(FLUID,
true);
459 (rModelPart.
Elements()).push_back(*(i_elem.base()));
460 rModelPart.
Elements().back().SetId(rElemId);
465 std::cout<<
" ELEMENT TO_ERASE must be RELEASED in a previous stage "<<std::endl;
469 for(ModelPart::NodesContainerType::iterator i_node = temporal_nodes.begin() ; i_node != temporal_nodes.end() ; ++i_node)
472 if( i_node->IsNot(TO_ERASE) ){
473 (i_mp->Nodes()).push_back(*(i_node.base()));
474 (rModelPart.
Nodes()).push_back(*(i_node.base()));
475 rModelPart.
Nodes().back().SetId(rNodeId);
479 i_node->Set(TO_REFINE,
false);
481 if ( i_node->IsNot(BOUNDARY)) {
482 i_node->Set(NEW_ENTITY,
false);
526 if(i_node->IsNot(BOUNDARY)){
528 if( i_node->SolutionStepsDataHas(CONTACT_FORCE) )
529 noalias(i_node->GetSolutionStepValue(CONTACT_FORCE)) = ZeroNormal;
536 for(ModelPart::ConditionsContainerType::iterator i_cond = i_mp->ConditionsBegin() ; i_cond != i_mp->ConditionsEnd() ; ++i_cond)
538 if( i_cond->IsNot(TO_ERASE) ){
539 i_cond->Set(TO_REFINE,
false);
540 rPreservedConditions.push_back(*(i_cond.base()));
541 rPreservedConditions.back().SetId(rCondId);
547 std::cout<<
" / [Elems="<<i_mp->NumberOfElements()<<
"|Nodes="<<i_mp->NumberOfNodes()<<
"|Conds="<<i_mp->NumberOfConditions()<<
"] ] "<<std::endl;
564 unsigned int body_model_part_conditions = rPreservedConditions.size();
566 if(body_model_part_conditions > 0){
571 if( i_mp->Is(BOUNDARY) ){
574 std::cout<<
" [ SUBMODEL PART ["<<i_mp->Name()<<
"] initial [Elems="<<i_mp->NumberOfElements()<<
"|Nodes="<<i_mp->NumberOfNodes()<<
"|Conds="<<i_mp->NumberOfConditions()<<
"] ]"<<std::endl;
578 for(ModelPart::ConditionsContainerType::iterator i_cond = rPreservedConditions.begin(); i_cond!= rPreservedConditions.end(); ++i_cond)
585 if( cn->GetValue(MODEL_PART_NAME) == i_mp->Name() ){
586 i_mp->Conditions().push_back(*(cn.base()));
588 if( i_cond->Is(NEW_ENTITY) ){
589 for(
unsigned int i=0;
i<i_cond->GetGeometry().size(); ++
i)
591 if( i_cond->GetGeometry()[
i].Is(NEW_ENTITY) ){
592 (i_mp->Nodes()).push_back(i_cond->GetGeometry()(
i));
606 if( i_model_part->IsNot(BOUNDARY) && i_model_part->IsNot(ACTIVE) && i_model_part->IsNot(RIGID) ){
608 for(ModelPart::NodesContainerType::iterator i_node = i_model_part->NodesBegin() ; i_node != i_model_part->NodesEnd(); ++i_node)
611 if( i_node->Is(BOUNDARY) && i_node->Is(NEW_ENTITY) ){
614 unsigned int NodeId = i_node->Id();
616 std::vector<int> list_of_neighbour_nodes;
618 for( ModelPart::ConditionsContainerType::iterator j_cond = rPreservedConditions.begin(); j_cond != rPreservedConditions.end(); ++j_cond)
621 bool node_belongs_to_condition =
false;
624 if ( j_cond->Is(NEW_ENTITY) ){
625 for (
unsigned int j = 0;
j < rjGeom.
size() ; ++
j) {
626 if ( rjGeom[
j].Id() == NodeId) {
627 node_belongs_to_condition =
true;
632 if (node_belongs_to_condition){
633 for (
unsigned int j = 0;
j < rjGeom.
size() ; ++
j) {
634 list_of_neighbour_nodes.
push_back( rjGeom[
j].Id() );
641 if(list_of_neighbour_nodes.size() == 0){
647 std::sort(list_of_neighbour_nodes.begin(), list_of_neighbour_nodes.end() );
648 std::vector<int>::iterator new_end = std::unique( list_of_neighbour_nodes.begin(), list_of_neighbour_nodes.end() );
649 list_of_neighbour_nodes.resize( std::distance( list_of_neighbour_nodes.begin(), new_end) );
653 if ( i_mp->Is(BOUNDARY) && i_mp->IsNot(CONTACT) && (i_mp->NumberOfConditions() == 0) )
657 for (
unsigned int ii = 0; ii < list_of_neighbour_nodes.size(); ++ii)
659 unsigned int target = list_of_neighbour_nodes[ii];
661 for (ModelPart::NodesContainerType::iterator i_node = i_mp->NodesBegin(); i_node != i_mp->NodesEnd(); ++i_node)
663 if ( i_node->Id() == target) {
669 if (
counter == list_of_neighbour_nodes.size()-1)
670 i_mp->Nodes().push_back( *(i_node.base() ) );
679 for( ModelPart::ConditionsContainerType::iterator j_cond = rPreservedConditions.begin(); j_cond != rPreservedConditions.end(); ++j_cond)
681 j_cond->Set(NEW_ENTITY,
false);
682 for(
unsigned int j=0;
j<j_cond->GetGeometry().size(); ++
j)
684 if( j_cond->GetGeometry()[
j].Is(NEW_ENTITY) ){
685 j_cond->GetGeometry()[
j].Set(NEW_ENTITY,
false);
693 if( i_mp->Is(BOUNDARY) ){
696 temporal_nodes.reserve(i_mp->Nodes().size());
697 temporal_nodes.swap(i_mp->Nodes());
699 for(ModelPart::NodesContainerType::iterator i_node = temporal_nodes.begin() ; i_node != temporal_nodes.end() ; ++i_node)
701 if( i_node->IsNot(TO_ERASE) )
702 (i_mp->Nodes()).push_back(*(i_node.base()));
706 std::cout<<
" [ SUBMODEL PART ["<<i_mp->Name()<<
"] final [Elems="<<i_mp->NumberOfElements()<<
"|Nodes="<<i_mp->NumberOfNodes()<<
"|Conds="<<i_mp->NumberOfConditions()<<
"] ] "<<std::endl;
713 if( i_mp->Is(BOUNDARY) ){
715 for(ModelPart::ConditionsContainerType::iterator i_cond = i_mp->ConditionsBegin() ; i_cond != i_mp->ConditionsEnd() ; ++i_cond)
717 if( i_cond->IsNot(TO_ERASE) ){
718 i_cond->Set(NEW_ENTITY,
false);
719 rPreservedConditions.push_back(*(i_cond.base()));
720 rPreservedConditions.back().SetId(rCondId);
744 unsigned int rContactId = rCondId;
745 if( rElemId > rCondId )
746 rContactId = rElemId;
752 if( i_mp->Is(CONTACT) ){
755 std::cout<<
" [ SUBMODEL PART ["<<i_mp->Name()<<
"] [Elems="<<i_mp->NumberOfElements()<<
"|Nodes="<<i_mp->NumberOfNodes()<<
"|Conds="<<i_mp->NumberOfConditions()<<
"] ";
757 i_mp->Elements().clear();
761 temporal_nodes.reserve(i_mp->Nodes().size());
762 temporal_nodes.swap(i_mp->Nodes());
765 for(ModelPart::NodesContainerType::iterator i_node = temporal_nodes.begin() ; i_node != temporal_nodes.end() ; ++i_node)
767 if( i_node->IsNot(TO_ERASE) ){
768 (i_mp->Nodes()).push_back(*(i_node.base()));
773 temporal_conditions.reserve(i_mp->Conditions().size());
774 temporal_conditions.swap(i_mp->Conditions());
776 for(ModelPart::ConditionsContainerType::iterator i_cond = temporal_conditions.begin() ; i_cond != temporal_conditions.end() ; ++i_cond)
779 if( i_cond->Is(CONTACT) ){
781 if( i_cond->IsNot(TO_ERASE) ){
783 (i_mp->Conditions()).push_back(*(i_cond.base()));
784 rPreservedConditions.push_back(*(i_cond.base()));
785 rPreservedConditions.back().SetId(rContactId);
795 std::cout<<
" / [Elems="<<i_mp->NumberOfElements()<<
"|Nodes="<<i_mp->NumberOfNodes()<<
"|Conds="<<i_mp->NumberOfConditions()<<
"] ] "<<std::endl;
803 if( rElemId > rCondId )
804 rElemId = rContactId;
806 rCondId = rContactId;
821 if( rModelPart.
Is(BOUNDARY) )
847 std::string ComputingModelPartName;
850 if( i_mp->Is(ACTIVE) && i_mp->IsNot(THERMAL) ){
851 ComputingModelPartName = i_mp->Name();
858 rComputingModelPart.
Nodes().clear();
859 rComputingModelPart.
Elements().clear();
866 if( (i_mp->IsNot(BOUNDARY) && i_mp->IsNot(ACTIVE)) || (i_mp->Is(RIGID)) ){
868 if( i_mp->IsNot(CONTACT) ){
870 for(ModelPart::NodesContainerType::iterator i_node = i_mp->NodesBegin() ; i_node != i_mp->NodesEnd() ; ++i_node)
872 (rComputingModelPart.
Nodes()).push_back(*(i_node.base()));
875 for(ModelPart::ConditionsContainerType::iterator i_cond = i_mp->ConditionsBegin() ; i_cond != i_mp->ConditionsEnd() ; ++i_cond)
877 (rComputingModelPart.
Conditions()).push_back(*(i_cond.base()));
882 for(ModelPart::ElementsContainerType::iterator i_elem = i_mp->ElementsBegin() ; i_elem != i_mp->ElementsEnd() ; ++i_elem)
885 (rComputingModelPart.
Elements()).push_back(*(i_elem.base()));
890 for(ModelPart::ElementsContainerType::iterator i_elem = i_mp->ElementsBegin() ; i_elem != i_mp->ElementsEnd() ; ++i_elem)
892 (rComputingModelPart.
Elements()).push_back(*(i_elem.base()));
904 if( i_mp->Is(CONTACT) ){
906 for(ModelPart::ConditionsContainerType::iterator i_cond = i_mp->ConditionsBegin() ; i_cond != i_mp->ConditionsEnd() ; ++i_cond)
908 if( i_cond->Is(CONTACT) )
909 (rComputingModelPart.
Conditions()).push_back(*(i_cond.base()));
917 rComputingModelPart.
Nodes().Unique();
937 for(ModelPart::NodesContainerType::const_iterator i_node = rModelPart.
NodesBegin(); i_node != rModelPart.
NodesEnd(); ++i_node)
940 i_node->Set(NEW_ENTITY,
false);
941 i_node->Set(TO_REFINE,
false);
945 for(ModelPart::ConditionsContainerType::iterator i_cond = rModelPart.
ConditionsBegin() ; i_cond != rModelPart.
ConditionsEnd() ; ++i_cond)
947 i_cond->Set(NEW_ENTITY,
false);
962 unsigned int rigid = 0;
963 unsigned int moving = 0;
964 for(
unsigned int i=0;
i<rElementGeometry.size(); ++
i)
966 if(rElementGeometry[
i].
Is(RIGID)){
969 for(
unsigned int j=0;
j<3; ++
j){
970 if( movement[
j] != 0 )
976 if( moving > 0 && rigid == rElementGeometry.size() ){
977 double CurrentSize = rElementGeometry.DomainSize();
978 std::vector<array_1d<double, 3> > CurrentCoordinates;
979 for(
unsigned int i=0;
i<rigid; ++
i)
981 CurrentCoordinates.push_back(rElementGeometry[
i].Coordinates());
982 rElementGeometry[
i].Coordinates() = rElementGeometry[
i].GetInitialPosition();
985 double OriginalSize = rElementGeometry.DomainSize();
986 for(
unsigned int i=0;
i<rigid; ++
i)
988 rElementGeometry[
i].Coordinates() = CurrentCoordinates[
i];
991 if( (CurrentSize > OriginalSize + 1
e-3*OriginalSize) || (CurrentSize < OriginalSize - 1
e-3*OriginalSize) ){
1089 rOStream << std::endl;
Definition: boundary_normals_calculation_utilities.hpp:48
void CalculateWeightedBoundaryNormals(ModelPart &rModelPart, int EchoLevel=0)
Calculates the area normal (unitary vector oriented as the normal) and weight the normal to shrink.
Definition: boundary_normals_calculation_utilities.hpp:123
Short class definition.
Definition: build_model_part_boundary_process.hpp:79
bool SearchConditionMasters()
Definition: build_model_part_boundary_process.hpp:240
Base class for all Elements.
Definition: element.h:60
bool Is(Flags const &rOther) const
Definition: flags.h:274
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
void push_back(PointPointerType x)
Definition: geometry.h:548
SizeType size() const
Definition: geometry.h:518
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
SubModelPartIterator SubModelPartsEnd()
Definition: model_part.h:1708
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
SubModelPartIterator SubModelPartsBegin()
Definition: model_part.h:1698
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
SizeType NumberOfSubModelParts() const
Definition: model_part.h:1665
std::string & Name()
Definition: model_part.h:1811
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
SizeType NumberOfElements(IndexType ThisIndex=0) const
Definition: model_part.h:1027
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
SizeType NumberOfConditions(IndexType ThisIndex=0) const
Definition: model_part.h:1218
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Condition ConditionType
Definition: model_part.h:121
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
Short class definition.
Definition: nodal_neighbours_search_process.hpp:50
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
size_type size() const
Definition: pointer_vector.h:255
The base class for all processes in Kratos.
Definition: process.h:49
virtual void Execute()
Execute method is used to execute the Process algorithms.
Definition: process.h:101
Short class definition.
Definition: settle_model_structure_process.hpp:71
virtual ~SettleModelStructureProcess()
Destructor.
Definition: settle_model_structure_process.hpp:92
void ExecuteFinalize() override
Definition: settle_model_structure_process.hpp:127
SettleModelStructureProcess(ModelPart &rMainModelPart, Flags Options, int EchoLevel=0)
Default constructor.
Definition: settle_model_structure_process.hpp:84
KRATOS_CLASS_POINTER_DEFINITION(SettleModelStructureProcess)
Pointer definition of SettleModelStructureProcess.
void operator()()
Definition: settle_model_structure_process.hpp:100
void SortModelPartConditions()
Definition: settle_model_structure_process.hpp:207
Flags mOptions
Definition: settle_model_structure_process.hpp:191
void BuildBoundaryModelParts(ModelPart &rModelPart, ModelPart::ConditionsContainerType &rPreservedConditions, unsigned int &rNodeId, unsigned int &rElemId, unsigned int &rCondId)
Definition: settle_model_structure_process.hpp:559
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: settle_model_structure_process.hpp:168
void BuildBodyModelParts(ModelPart &rModelPart, ModelPart::ConditionsContainerType &rPreservedConditions, unsigned int &rNodeId, unsigned int &rElemId, unsigned int &rCondId)
Definition: settle_model_structure_process.hpp:379
void ExecuteInitialize() override
Definition: settle_model_structure_process.hpp:111
virtual void PerformModelSearches()
Definition: settle_model_structure_process.hpp:299
std::string Info() const override
Turn back information as a string.
Definition: settle_model_structure_process.hpp:156
virtual void BuildComputingDomain(ModelPart &rModelPart, int EchoLevel)
Definition: settle_model_structure_process.hpp:843
virtual bool CheckRigidElementSize(Element &rElement)
Definition: settle_model_structure_process.hpp:956
int mEchoLevel
Definition: settle_model_structure_process.hpp:193
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: settle_model_structure_process.hpp:162
virtual void BuildTotalModelPart(ModelPart &rModelPart, int EchoLevel)
Definition: settle_model_structure_process.hpp:326
void BuildContactModelParts(ModelPart &rModelPart, ModelPart::ConditionsContainerType &rPreservedConditions, unsigned int &rNodeId, unsigned int &rElemId, unsigned int &rCondId)
Definition: settle_model_structure_process.hpp:736
ModelPart & mrMainModelPart
Definition: settle_model_structure_process.hpp:189
void CleanMeshFlags(ModelPart &rModelPart)
Definition: settle_model_structure_process.hpp:932
void SortModelPartElements()
Definition: settle_model_structure_process.hpp:227
void CleanModelPartConditions(ModelPart &rModelPart)
Definition: settle_model_structure_process.hpp:816
void SortModelPartNodes()
Definition: settle_model_structure_process.hpp:248
void BuildModelPartStructure()
Definition: settle_model_structure_process.hpp:277
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
ConditionsContainerType::iterator ConditionIterator
Definition: settle_model_structure_process.hpp:51
ConditionsContainerType::const_iterator ConditionConstantIterator
Definition: settle_model_structure_process.hpp:52
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: find_conditions_neighbours_process.h:45
Geometry< Node > GeometryType
The definition of the geometry.
Definition: mortar_classes.h:37
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
ModelPart::ElementsContainerType ElementsContainerType
Definition: clear_contact_conditions_mesher_process.hpp:43
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
GeometryType::PointsArrayType PointsArrayType
Definition: settle_model_structure_process.hpp:48
Condition ConditionType
Definition: assign_unique_model_part_collection_tag_utility.h:43
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
def FindNeighbours(self)
FOR MEMBRANE print "00000" NormalCalculationUtils().CalculateOnSimplex(self.combined_model_part,...
Definition: ulf_PGLASS.py:386