10 #if !defined(KRATOS_BUILD_MODEL_PART_BOUNDARY_FOR_FLUIDS_PROCESS_H_INCLUDED)
11 #define KRATOS_BUILD_MODEL_PART_BOUNDARY_FOR_FLUIDS_PROCESS_H_INCLUDED
91 std::string
const rModelPartName,
122 bool success =
false;
137 std::cout <<
" [ Construct Boundary on ModelPart [" << i_mp->Name() <<
"] ]" << std::endl;
143 std::cout <<
" ERROR: BOUNDARY CONSTRUCTION FAILED ModelPart : [" << i_mp->Name() <<
"] " << std::endl;
160 std::cout <<
" [ Construct Boundary on ModelPart[" <<
mModelPartName <<
"] ]" << std::endl;
167 std::cout <<
" ERROR: BOUNDARY CONSTRUCTION FAILED on ModelPart : [" << rModelPart.
Name() <<
"] " << std::endl;
180 if (NumberOfSubModelParts > 1)
182 SetMainModelPartConditions();
183 SetComputingModelPart();
199 std::cout <<
" Boundary Normals Computed and Assigned ] " << std::endl;
212 int composite_conditions = 0;
213 int total_conditions = 0;
221 if (i_cond->Is(BOUNDARY))
222 composite_conditions++;
232 unsigned int size = rConditionGeometry.
size();
234 bool perform_search =
true;
235 for (
unsigned int i = 0;
i < size; ++
i)
237 if (rConditionGeometry[
i].
Is(RIGID))
238 perform_search =
false;
241 if (i_cond->Is(CONTACT))
242 perform_search =
false;
256 if (rE1.
size() == 0 || rE2.
size() == 0)
257 std::cout <<
" NO SIZE in NEIGHBOUR_ELEMENTS " << std::endl;
264 if ((ne)->Id() == (ie)->Id() && !found)
273 i_cond->SetValue(MASTER_ELEMENTS, MasterElements);
282 for (
unsigned int iface = 0; iface < rElementGeometry.
size(); ++iface)
285 found = MesherUtils.
FindCondition(rConditionGeometry, rElementGeometry, lpofa, lnofa, iface);
300 if (i_cond->GetValue(MASTER_NODES)[0].Id() != MasterNodes[0].Id())
301 std::cout <<
"Condition " << i_cond->Id() <<
" WARNING: master nodes (" << i_cond->GetValue(MASTER_NODES)[0].Id() <<
" != " << MasterNodes[0].Id() <<
")" << std::endl;
302 i_cond->SetValue(MASTER_NODES, MasterNodes);
307 std::cout <<
" MASTER_NODE not FOUND : something is wrong " << std::endl;
320 if (rE1.
size() == 0 || rE2.
size() == 0 || rE3.
size() == 0)
321 std::cout <<
" NO SIZE in NEIGHBOUR_ELEMENTS " << std::endl;
328 if ((je)->Id() == (ie)->Id() && !found)
334 if ((ke)->Id() == (ie)->Id() && !found)
341 if (i_cond->GetValue(MASTER_ELEMENTS)[0].Id() != MasterElements[0].Id())
342 std::cout <<
"Condition " << i_cond->Id() <<
" WARNING: master elements (" << i_cond->GetValue(MASTER_ELEMENTS)[0].Id() <<
" != " << MasterElements[0].Id() <<
")" << std::endl;
344 i_cond->SetValue(MASTER_ELEMENTS, MasterElements);
353 for (
unsigned int iface = 0; iface < rElementGeometry.
size(); ++iface)
356 found = MesherUtils.
FindCondition(rConditionGeometry, rElementGeometry, lpofa, lnofa, iface);
371 if (i_cond->GetValue(MASTER_NODES)[0].Id() != MasterNodes[0].Id())
372 std::cout <<
"Condition " << i_cond->Id() <<
" WARNING: master nodes (" << i_cond->GetValue(MASTER_NODES)[0].Id() <<
" != " << MasterNodes[0].Id() <<
")" << std::endl;
374 i_cond->SetValue(MASTER_NODES, MasterNodes);
378 std::cout <<
" MASTER_NODE not FOUND : something is wrong " << std::endl;
398 if (
counter == total_conditions)
401 std::cout <<
" Condition Masters (ModelPart " <<
mrModelPart.
Name() <<
"): LOCATED [" <<
counter <<
"]" << std::endl;
407 std::cout <<
" Condition Masters (ModelPart " <<
mrModelPart.
Name() <<
"): not LOCATED [" <<
counter - total_conditions <<
"]" << std::endl;
411 if (
counter != composite_conditions)
413 std::cout <<
" Condition Masters (ModelPart " <<
mrModelPart.
Name() <<
"): LOCATED [" <<
counter <<
"] COMPOSITE [" << composite_conditions <<
"] NO MATCH" << std::endl;
417 std::cout <<
" Condition Masters Found " << std::endl;
435 std::string
Info()
const override
437 return "BuildModelPartBoundaryForFluidsProcess";
443 rOStream <<
"BuildModelPartBoundaryForFluidsProcess";
486 for (ModelPart::ConditionsContainerType::iterator ic = rTemporaryConditions.begin(); ic != rTemporaryConditions.end(); ++ic)
489 MasterElements.
erase(MasterElements.
begin(), MasterElements.
end());
510 std::cout <<
" [ Initial Conditions : " << rModelPart.
Conditions().size() << std::endl;
513 if (!rModelPart.
Elements().size() || (rModelPart.
Is(ACTIVE)))
517 std::cout <<
" [ Final Conditions : " << rModelPart.
Conditions().size() << std::endl;
523 bool any_node_to_erase =
false;
524 for (ModelPart::NodesContainerType::const_iterator in = rModelPart.
NodesBegin(); in != rModelPart.
NodesEnd(); ++in)
526 if (any_node_to_erase ==
false)
527 if (in->Is(TO_ERASE))
528 any_node_to_erase =
true;
607 ModelPart::ElementsContainerType::iterator elements_begin = rModelPart.
ElementsBegin();
608 ModelPart::ElementsContainerType::iterator elements_end = rModelPart.
ElementsEnd();
610 for (ModelPart::ElementsContainerType::iterator ie = elements_begin; ie != elements_end; ie++)
633 boost::numeric::ublas::matrix<unsigned int> lpofa;
634 boost::numeric::ublas::vector<unsigned int> lnofa;
643 unsigned int iface = 0;
646 unsigned int NumberNodesInFace = lnofa[iface];
648 if ((ne)->Id() == ie->Id())
651 bool freeSurfaceFace =
false;
652 for (
unsigned int j = 1;
j <= NumberNodesInFace;
j++)
654 rElementGeometry[lpofa(
j, iface)].Set(BOUNDARY);
655 if (rElementGeometry[lpofa(
j, iface)].
IsNot(RIGID))
657 freeSurfaceFace =
true;
660 if (freeSurfaceFace ==
true)
662 for (
unsigned int j = 1;
j <= NumberNodesInFace;
j++)
664 rElementGeometry[lpofa(
j, iface)].Set(FREE_SURFACE);
692 ModelPart::ElementsContainerType::iterator elements_begin = rModelPart.
ElementsBegin();
693 ModelPart::ElementsContainerType::iterator elements_end = rModelPart.
ElementsEnd();
696 for (ModelPart::ElementsContainerType::iterator ie = elements_begin; ie != elements_end; ++ie)
700 for (
unsigned int j = 0;
j < rElementGeometry.
size(); ++
j)
702 rElementGeometry[
j].Reset(BOUNDARY);
707 for (ModelPart::ElementsContainerType::iterator ie = elements_begin; ie != elements_end; ++ie)
742 unsigned int iface = 0;
745 unsigned int NumberNodesInFace = lnofa[iface];
747 if ((ne)->Id() == ie->Id())
750 for (
unsigned int j = 1;
j <= NumberNodesInFace; ++
j)
752 rElementGeometry[lpofa(
j, iface)].Set(BOUNDARY);
758 Condition::GeometryType::Pointer ConditionVertices;
760 FaceNodes.
reserve(NumberNodesInFace);
762 for (
unsigned int j = 1;
j <= NumberNodesInFace; ++
j)
764 FaceNodes.
push_back(rElementGeometry(lpofa(
j, iface)));
767 if (NumberNodesInFace == 2)
770 ConditionVertices = Kratos::make_shared<Line2D2<Node>>(FaceNodes);
772 ConditionVertices = Kratos::make_shared<Line3D2<Node>>(FaceNodes);
774 else if (NumberNodesInFace == 3)
777 ConditionVertices = Kratos::make_shared<Line2D3<Node>>(FaceNodes);
779 ConditionVertices = Kratos::make_shared<Triangle3D3<Node>>(FaceNodes);
785 CompositeCondition::Pointer p_cond = Kratos::make_intrusive<CompositeCondition>(rConditionId, ConditionVertices, properties);
787 bool condition_found =
false;
788 bool point_condition =
false;
791 for (ModelPart::ConditionsContainerType::iterator i_cond = rTemporaryConditions.begin(); i_cond != rTemporaryConditions.end(); ++i_cond)
796 condition_found = MesherUtils.
FindCondition(rConditionGeometry, rElementGeometry, lpofa, lnofa, iface);
801 p_cond->AddChild(*(i_cond.base()));
803 rPreservedConditions[i_cond->Id()] += 1;
806 point_condition =
true;
811 if (!point_condition)
820 MasterElements.
push_back((*(ie.base())));
821 p_cond->SetValue(MASTER_ELEMENTS, MasterElements);
824 MasterNodes.
push_back(rElementGeometry(lpofa(0, iface)));
825 p_cond->SetValue(MASTER_NODES, MasterNodes);
828 rModelPart.
Conditions().push_back(Condition::Pointer(p_cond));
839 for (
unsigned int j = 0;
j < rElementGeometry.
size(); ++
j)
841 rElementGeometry[
j].Set(BOUNDARY);
859 for (
unsigned int i = 0;
i < rConditionGeometry.
size(); ++
i)
861 for (ModelPart::NodesContainerType::const_iterator in = rModelPart.
NodesBegin(); in != rModelPart.
NodesEnd(); ++in)
863 if (rConditionGeometry[
i].Id() == in->
Id())
882 std::cout <<
" CONDITIONS: geometry nodes (" << rModelPart.
Conditions().size() <<
")" << std::endl;
885 for (ConditionsContainerType::iterator i_cond = rCond.begin(); i_cond != rCond.end(); ++i_cond)
889 std::cout <<
"[" << i_cond->
Id() <<
"]:" << std::endl;
892 for (
unsigned int i = 0;
i < rConditionGeometry.
size(); ++
i)
894 std::cout << rConditionGeometry[
i].
Id() <<
", ";
898 i_cond->GetValue(MASTER_ELEMENTS)[0].PrintInfo(std::cout);
900 std::cout << std::endl;
902 std::cout << std::endl;
918 for (ModelPart::ConditionsContainerType::iterator i_cond = rTemporaryConditions.begin(); i_cond != rTemporaryConditions.end(); ++i_cond)
921 if (rPreservedConditions[i_cond->Id()] == 0)
933 for (
unsigned int j = 0;
j < rConditionGeometry.
size(); ++
j)
938 rPreservedConditions[i_cond->Id()] += 1;
942 Condition::Pointer p_cond = i_cond->Clone(rConditionId, FaceNodes);
955 bool all_assigned =
true;
956 unsigned int lost_conditions = 0;
957 for (
unsigned int i = 1;
i < rPreservedConditions.size(); ++
i)
959 if (rPreservedConditions[
i] == 0)
961 all_assigned =
false;
971 if (all_assigned ==
true)
972 std::cout <<
" ALL_PREVIOUS_CONDITIONS_RELOCATED " << std::endl;
974 std::cout <<
" SOME_PREVIOUS_CONDITIONS_ARE_LOST [lost_conditions:" << lost_conditions <<
"]" << std::endl;
1042 void SetComputingModelPart()
1047 std::string ComputingModelPartName;
1050 if (i_mp->Is(ACTIVE))
1051 ComputingModelPartName = i_mp->Name();
1058 std::cout <<
" [" << ComputingModelPartName <<
" :: CONDITIONS [OLD:" << rModelPart.
NumberOfConditions();
1066 if (i_mp->NumberOfElements() && ComputingModelPartName != i_mp->Name())
1069 for (ModelPart::ConditionsContainerType::iterator i_cond = i_mp->ConditionsBegin(); i_cond != i_mp->ConditionsEnd(); ++i_cond)
1074 KeepConditions.
push_back(*(i_cond.base()));
1082 rModelPart.Conditions().swap(KeepConditions);
1086 std::cout <<
" / NEW:" << rModelPart.NumberOfConditions() <<
"] " << std::endl;
1095 void SetMainModelPartConditions()
1108 unsigned int condId = 1;
1114 if (!(i_mp->Is(ACTIVE)) && !(i_mp->Is(CONTACT)))
1117 for (ModelPart::ConditionsContainerType::iterator i_cond = i_mp->ConditionsBegin(); i_cond != i_mp->ConditionsEnd(); ++i_cond)
1122 KeepConditions.
push_back(*(i_cond.base()));
1123 KeepConditions.back().SetId(condId);
1135 if (i_cond->Is(CONTACT))
1137 KeepConditions.push_back(*(i_cond.base()));
1138 KeepConditions.back().SetId(condId);
1157 void ResetNodesBoundaryFlag(ModelPart &rModelPart)
1160 for (ModelPart::NodesContainerType::const_iterator in = rModelPart.NodesBegin(); in != rModelPart.NodesEnd(); ++in)
1162 in->Reset(BOUNDARY);
1206 rOStream << std::endl;
Definition: boundary_normals_calculation_utilities.hpp:48
void CalculateUnitBoundaryNormals(ModelPart &rModelPart, int EchoLevel=0)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area).
Definition: boundary_normals_calculation_utilities.hpp:83
Short class definition.
Definition: build_model_part_boundary_for_fluids_process.hpp:77
std::string Info() const override
Turn back information as a string.
Definition: build_model_part_boundary_for_fluids_process.hpp:435
virtual bool BuildCompositeConditions(ModelPart &rModelPart, ModelPart::ConditionsContainerType &rTemporaryConditions, std::vector< int > &rPreservedConditions, unsigned int &rConditionId)
Definition: build_model_part_boundary_for_fluids_process.hpp:680
virtual ~BuildModelPartBoundaryForFluidsProcess()
Destructor.
Definition: build_model_part_boundary_for_fluids_process.hpp:100
ModelPart & mrModelPart
Definition: build_model_part_boundary_for_fluids_process.hpp:465
BuildModelPartBoundaryForFluidsProcess(ModelPart &rModelPart, std::string const rModelPartName, int EchoLevel=0)
Default constructor.
Definition: build_model_part_boundary_for_fluids_process.hpp:90
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: build_model_part_boundary_for_fluids_process.hpp:447
void PrintSkin(ModelPart &rModelPart)
Definition: build_model_part_boundary_for_fluids_process.hpp:876
virtual void AddConditionToModelPart(ModelPart &rModelPart, Condition::Pointer pCondition)
Definition: build_model_part_boundary_for_fluids_process.hpp:999
std::string mModelPartName
Definition: build_model_part_boundary_for_fluids_process.hpp:467
bool AddOtherConditions(ModelPart &rModelPart, ModelPart::ConditionsContainerType &rTemporaryConditions, std::vector< int > &rPreservedConditions, unsigned int &rConditionId)
Definition: build_model_part_boundary_for_fluids_process.hpp:910
bool SearchConditionMasters()
Definition: build_model_part_boundary_for_fluids_process.hpp:207
void operator()()
Definition: build_model_part_boundary_for_fluids_process.hpp:108
virtual bool SetBoundaryAndFreeSurface(ModelPart &rModelPart)
Definition: build_model_part_boundary_for_fluids_process.hpp:598
bool ClearMasterEntities(ModelPart &rModelPart, ModelPart::ConditionsContainerType &rTemporaryConditions)
Definition: build_model_part_boundary_for_fluids_process.hpp:482
virtual bool CheckAcceptedCondition(ModelPart &rModelPart, Condition &rCondition)
Definition: build_model_part_boundary_for_fluids_process.hpp:985
void Execute() override
Execute method is used to execute the MesherProcess algorithms.
Definition: build_model_part_boundary_for_fluids_process.hpp:117
bool FindConditionID(ModelPart &rModelPart, Geometry< Node > &rConditionGeometry)
Definition: build_model_part_boundary_for_fluids_process.hpp:854
bool UniqueSkinSearch(ModelPart &rModelPart)
Definition: build_model_part_boundary_for_fluids_process.hpp:503
int mEchoLevel
Definition: build_model_part_boundary_for_fluids_process.hpp:469
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: build_model_part_boundary_for_fluids_process.hpp:441
KRATOS_CLASS_POINTER_DEFINITION(BuildModelPartBoundaryForFluidsProcess)
Pointer definition of BuildModelPartBoundaryForFluidsProcess.
Base class for all Conditions.
Definition: condition.h:59
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
virtual void NodesInFaces(DenseMatrix< unsigned int > &rNodesInFaces) const
Definition: geometry.h:2195
virtual void NumberNodesInFaces(DenseVector< unsigned int > &rNumberNodesInFaces) const
Definition: geometry.h:2190
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
virtual SizeType FacesNumber() const
Returns the number of faces of the current geometry.
Definition: geometry.h:2152
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
iterator erase(iterator pos)
Definition: global_pointers_vector.h:351
void push_back(TPointerType x)
Definition: global_pointers_vector.h:322
iterator begin()
Definition: global_pointers_vector.h:221
size_type size() const
Definition: global_pointers_vector.h:307
iterator end()
Definition: global_pointers_vector.h:229
Definition: amatrix_interface.h:41
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
bool FindCondition(Geometry< Node > &rConditionGeometry, Geometry< Node > &rGeometry, DenseMatrix< unsigned int > &lpofa, DenseVector< unsigned int > &lnofa, unsigned int &iface)
Definition: mesher_utilities.cpp:1971
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
PropertiesType::Pointer pGetProperties(IndexType PropertiesId, IndexType MeshIndex=0)
Returns the Properties::Pointer corresponding to it's identifier.
Definition: model_part.cpp:664
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
SubModelPartIterator SubModelPartsBegin()
Definition: model_part.h:1698
SizeType NumberOfProperties(IndexType ThisIndex=0) const
Returns the number of properties of the mesh.
Definition: model_part.cpp:575
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
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
void AddCondition(ConditionType::Pointer pNewCondition, IndexType ThisIndex=0)
Definition: model_part.cpp:1436
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
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
ModelPart & GetParentModelPart()
Definition: model_part.cpp:2124
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void reserve(size_type dim)
Definition: pointer_vector.h:319
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:60
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
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: find_conditions_neighbours_process.h:45
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:59
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
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
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
Definition: mesh_converter.cpp:38