10 #if !defined( KRATOS_SELECT_ELEMENTS_MESHER_PROCESS_H_INCLUDED )
11 #define KRATOS_SELECT_ELEMENTS_MESHER_PROCESS_H_INCLUDED
110 bool box_side_element =
false;
111 bool wrong_added_node =
false;
113 unsigned int number_of_slivers = 0;
115 unsigned int passed_alpha_shape = 0;
116 unsigned int passed_inner_outer = 0;
121 for(
int el=0;
el<OutNumberOfElements; ++
el)
130 std::cout<<
" Start Element Selection "<<OutNumberOfElements<<std::endl;
137 unsigned int number_of_vertices = 0;
151 for(
el=0;
el<OutNumberOfElements; ++
el)
162 wrong_added_node =
false;
163 box_side_element =
false;
166 for(
unsigned int pn=0;
pn<number_of_vertices; ++
pn)
169 unsigned int id =
el*number_of_vertices+
pn;
171 if(OutElementList[
id]<=0)
172 std::cout<<
" ERROR: something is wrong: nodal id < 0 "<<
el<<std::endl;
177 wrong_added_node =
true;
178 std::cout<<
" ERROR: something is wrong: node out of bounds "<<std::endl;
185 std::cout<<
" ERROR: something is wrong: nodal id < 0 "<<std::endl;
186 box_side_element =
true;
191 Vertices.
push_back(rNodes(OutElementList[
id]));
198 if(box_side_element || wrong_added_node){
242 bool self_contact =
false;
246 ++passed_alpha_shape;
273 ++passed_inner_outer;
303 std::cout<<
" (passed_alpha_shape: "<<passed_alpha_shape<<
", passed_inner_outer: "<<passed_inner_outer<<
") "<<std::endl;
320 std::cout<<
" SELECT MESH ELEMENTS ("<<
mrRemesh.
Info->NumberOfElements<<
") ]; "<<std::endl;
344 std::string
Info()
const override
346 return "SelectElementsMesherProcess";
352 rOStream <<
"SelectElementsMesherProcess";
429 if(rNode.
Is(BOUNDARY))
431 if(rNode.
Is(CONTACT))
435 if(rNode.
Is(ISOLATED))
437 if(rNode.
Is(FREE_SURFACE)){
442 if(rNode.
Is(SELECTED))
444 if(rNode.
Is(NEW_ENTITY))
446 if(rNode.
Is(OLD_ENTITY))
469 const double& CurrentTime = rCurrentProcessInfo[TIME];
470 const double& TimeStep = rCurrentProcessInfo[DELTA_TIME];
471 if(CurrentTime<=TimeStep)
484 if( rModelPart.
Is(FLUID) ){
486 unsigned int count_rigid;
487 for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.
ElementsBegin() ; i_elem != rModelPart.
ElementsEnd() ; ++i_elem)
492 for(
unsigned int i=0;
i<vertices.
size(); ++
i)
494 if( vertices[
i].
Is(RIGID) )
499 if( count_rigid == vertices.
size() ){
501 for(
unsigned int i=0;
i<vertices.
size(); ++
i)
503 vertices[
i].Set(OLD_ENTITY,
true);
510 for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.
ElementsBegin() ; i_elem != rModelPart.
ElementsEnd() ; ++i_elem)
514 for(
unsigned int i=0;
i<vertices.
size(); ++
i)
516 if( vertices[
i].
Is(RIGID) )
521 if( count_rigid != vertices.
size() ){
523 for(
unsigned int i=0;
i<vertices.
size(); ++
i)
526 vertices[
i].Set(OLD_ENTITY,
false);
544 unsigned int number_of_vertices = 0;
545 unsigned int isolated_nodes = 0;
556 for(
int el=0;
el<OutNumberOfElements; ++
el)
559 for(
unsigned int pn=0;
pn<number_of_vertices; ++
pn)
562 rNodes[OutElementList[
el*number_of_vertices+
pn]].Set(BLOCKED);
568 int count_release = 0;
569 for(ModelPart::NodesContainerType::iterator i_node = rNodes.begin() ; i_node != rNodes.end() ; ++i_node)
571 if( i_node->IsNot(BLOCKED) ){
575 if( i_node->Is(RIGID) || i_node->Is(SOLID) || i_node->Is(INLET) ){
576 if( i_node->Is(TO_ERASE) ){
577 i_node->Set(TO_ERASE,
false);
578 std::cout<<
" WARNING TRYING TO DELETE A WALL NODE (fluid): "<<i_node->Id()<<std::endl;
585 if( i_node->IsNot(TO_ERASE) ){
586 i_node->Set(ISOLATED,
true);
597 i_node->Set(TO_ERASE,
true);
599 std::cout<<
" NODE "<<i_node->Id()<<
" IS INSIDE RELEASE "<<std::endl;
600 if( i_node->Is(BOUNDARY) )
601 std::cout<<
" NODE "<<i_node->Id()<<
" IS BOUNDARY RELEASE "<<std::endl;
611 if( i_node->Is(RIGID) || i_node->Is(INLET) ){
613 if( i_node->Is(TO_ERASE) ){
614 i_node->Set(TO_ERASE,
false);
615 std::cout<<
" WARNING TRYING TO DELETE A WALL NODE (solid): "<<i_node->Id()<<std::endl;
623 if( i_node->IsNot(TO_ERASE) ){
624 i_node->Set(ISOLATED,
true);
631 i_node->Set(TO_ERASE);
633 std::cout<<
" NODE "<<i_node->Id()<<
" IS INSIDE RELEASE "<<std::endl;
634 if( i_node->Is(BOUNDARY) )
635 std::cout<<
" NODE "<<i_node->Id()<<
" IS BOUNDARY RELEASE "<<std::endl;
644 i_node->Set(TO_ERASE,
false);
645 i_node->Set(ISOLATED,
false);
649 i_node->Set(BLOCKED,
false);
650 i_node->Set(OLD_ENTITY,
false);
651 if(i_node->Is(VISITED))
652 i_node->Set(SELECTED,
true);
654 i_node->Set(SELECTED,
false);
655 i_node->Set(VISITED,
false);
660 std::cout<<
" NUMBER OF RELEASED NODES "<<count_release<<std::endl;
661 std::cout<<
" NUMBER OF ISOLATED NODES "<<isolated_nodes<<std::endl;
668 void CheckIds(
const int* OutElementList,
const int& OutNumberOfElements,
const unsigned int number_of_vertices)
671 unsigned int max_out_id = 0;
672 for(
int el=0;
el<OutNumberOfElements; ++
el)
674 for(
unsigned int pn=0;
pn<number_of_vertices; ++
pn)
676 unsigned int id =
el*number_of_vertices+
pn;
677 if(
int(max_out_id) < OutElementList[
id] )
678 max_out_id = OutElementList[id];
694 dimension = element_begin->GetGeometry().WorkingSpaceDimension();
695 number_of_vertices = element_begin->GetGeometry().size();
699 dimension = condition_begin->GetGeometry().WorkingSpaceDimension();
701 number_of_vertices = 4;
703 number_of_vertices = 3;
714 bool accepted =
true;
715 unsigned int NumberOfVertices = rVertices.
size();
721 if( rVerticesFlags.
Rigid >= NumberOfVertices-1 )
727 if( rVerticesFlags.
Rigid == NumberOfVertices && rVerticesFlags.
Fluid>0){
729 if( rVerticesFlags.
Fluid < NumberOfVertices-1 ){
733 else if( rVerticesFlags.
Fluid == NumberOfVertices && rVerticesFlags.
OldEntity >= 2 ){
744 if( (rVerticesFlags.
Rigid + rVerticesFlags.
NewEntity) == NumberOfVertices && rVerticesFlags.
Fluid>0){
745 if( rVerticesFlags.
Fluid == NumberOfVertices && rVerticesFlags.
OldEntity >= NumberOfVertices-1 ){
746 std::cout<<
" OLD RIGID NEW ENTITY EDGE DISCARDED (old_entity: "<<rVerticesFlags.
OldEntity<<
" fluid: "<<rVerticesFlags.
Fluid<<
" rigid: "<<rVerticesFlags.
Rigid<<
" free_surface: "<<rVerticesFlags.
FreeSurface<<
")"<<std::endl;
752 if( (rVerticesFlags.
Solid + rVerticesFlags.
Rigid) >= NumberOfVertices && rVerticesFlags.
Fluid == 0)
756 if( rVerticesFlags.
Solid == NumberOfVertices )
769 unsigned int NumberOfVertices = rVertices.
size();
775 if( rVerticesFlags.
Boundary >= NumberOfVertices )
785 const double MaxRelativeVelocity = 1.5;
789 for(
unsigned int i=0;
i<rVertices.
size(); ++
i)
791 if( rVertices[
i].
Is(ISOLATED) )
792 rVertices[
i].Set(TO_ERASE);
800 else if(rDimension==3){
815 double VolumeChange = 0;
816 double VolumeTolerance = 1.15e-4*pow(4.0*
mrRemesh.
Refine->CriticalRadius,rDimension);
817 unsigned int NumberOfVertices = rVertices.
size();
820 if( rVerticesFlags.
Fluid != NumberOfVertices ){
823 if( rVerticesFlags.
Fluid == 0 ){
837 else if( rVerticesFlags.
Rigid == 1 || rVerticesFlags.
Solid == 1 ){
845 else if( rVerticesFlags.
Rigid == 2 || rVerticesFlags.
Solid == 2 || (rVerticesFlags.
Rigid+rVerticesFlags.
Solid)==2 ){
865 if( VolumeChange > 0 && VolumeChange < VolumeTolerance ){
889 const double MaxRelativeVelocity = 1.5;
938 double VolumeChange = 0;
939 double VolumeTolerance = 2.5e-3*pow(4.0*
mrRemesh.
Refine->CriticalRadius,rDimension);
940 unsigned int NumberOfVertices = rVertices.
size();
943 if( rVerticesFlags.
Fluid != NumberOfVertices ){
946 if( rVerticesFlags.
Fluid == 0 ){
960 else if( (rVerticesFlags.
Rigid == 1 || rVerticesFlags.
Solid == 1) ){
968 else if( rVerticesFlags.
Rigid == 2 || rVerticesFlags.
Solid == 2 || (rVerticesFlags.
Rigid+rVerticesFlags.
Solid)==2 ){
976 else if( rVerticesFlags.
Rigid == 3 || rVerticesFlags.
Solid == 3 || (rVerticesFlags.
Rigid+rVerticesFlags.
Solid)==3 ){
979 if( rVerticesFlags.
Fluid == 1 )
999 if( VolumeChange > 0 && VolumeChange < VolumeTolerance && rVerticesFlags.
Rigid == NumberOfVertices ){
1081 bool accepted =
true;
1082 unsigned int NumberOfVertices = rVertices.
size();
1087 if(rDimension == 3 && NumberOfVertices==4){
1100 ++number_of_slivers;
1115 if(rDimension == 2 && NumberOfVertices==3){
1123 for(
unsigned int i=0;
i<NumberOfVertices-1; ++
i)
1125 for(
unsigned int j=
i+1;
j<NumberOfVertices; ++
j)
1127 double Length =
norm_2(rVertices[
j].Coordinates() - rVertices[
i].Coordinates());
1128 if( Length < MinEdgeLength ){
1129 MinEdgeLength = Length;
1131 if( Length > MaxEdgeLength ){
1132 MaxEdgeLength = Length;
1138 const double MaxRelativeVelocity = 1.5;
1139 if( MinEdgeLength*5 < MaxEdgeLength ){
1141 std::cout<<
" WARNING 2D sliver "<<std::endl;
1145 if( rVerticesFlags.
FreeSurface == NumberOfVertices)
1147 ++number_of_slivers;
1148 for(
unsigned int i=0;
i<NumberOfVertices; ++
i)
1150 if( rVertices[
i].
Is(VISITED) )
1151 std::cout<<
" WARNING Second sliver in the same node bis "<<std::endl;
1152 rVertices[
i].Set(VISITED);
1159 else if(rDimension == 3 && NumberOfVertices==4){
1164 double Volume = Tetrahedron.
Volume();
1166 if( Volume < 0.01*pow(4.0*
mrRemesh.
Refine->CriticalRadius,rDimension) ){
1173 if( rVerticesFlags.
FreeSurface == NumberOfVertices)
1176 ++number_of_slivers;
1178 for(
unsigned int i=0;
i<NumberOfVertices; ++
i)
1182 rVertices[
i].Set(VISITED);
1207 else if( ( rVerticesFlags.
Rigid == 1 || rVerticesFlags.
Rigid == 2 ) ){
1213 double MovedVolume = MesherUtils.
GetMovedVolume(rVertices,rDimension,1.0);
1216 if( VolumeIncrement < 0.0 || MovedVolume < 0.0 ){
1223 ++number_of_slivers;
1225 for(
unsigned int i=0;
i<NumberOfVertices; ++
i)
1229 rVertices[
i].Set(VISITED);
1308 rOStream << std::endl;
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
Geometry base class.
Definition: geometry.h:71
void push_back(PointPointerType x)
Definition: geometry.h:548
SizeType size() const
Definition: geometry.h:518
PointReferenceType back()
Definition: geometry.h:507
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
bool CheckVolumeDecrease(GeometryType &rVertices, const unsigned int &rDimension, const double &rTolerance, double &VolumeChange)
Definition: mesher_utilities.cpp:1378
double GetMovedVolume(GeometryType &rVertices, const unsigned int &rDimension, double MovementFactor)
Definition: mesher_utilities.cpp:1421
bool CheckOuterCentre(Geometry< Node > &rGeometry, double &rOffsetFactor, bool &rSelfContact)
Definition: mesher_utilities.cpp:436
double GetDeformationGradientDeterminant(GeometryType &rVertices, const unsigned int &rDimension)
Definition: mesher_utilities.cpp:1483
bool CheckGeometryShape(Geometry< Node > &rGeometry, int &rShape)
Definition: mesher_utilities.cpp:849
bool ShrankAlphaShape(double AlphaParameter, Geometry< Node > &rGeometry, double &rOffsetFactor, const unsigned int dimension)
Definition: mesher_utilities.cpp:1241
bool CheckRelativeVelocities(Geometry< Node > &rGeometry, const double &rRelativeFactor)
Definition: mesher_utilities.cpp:1346
bool CheckRigidOuterCentre(Geometry< Node > &rGeometry)
Definition: mesher_utilities.cpp:262
bool CheckSubdomain(Geometry< Node > &rGeometry)
Definition: mesher_utilities.cpp:198
bool AlphaShape(double AlphaParameter, Geometry< Node > &rGeometry, const unsigned int dimension)
Definition: mesher_utilities.cpp:1182
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
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
SizeType NumberOfElements(IndexType ThisIndex=0) const
Definition: model_part.h:1027
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
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
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Refine Mesh Elements Process 2D and 3D.
Definition: select_elements_mesher_process.hpp:47
void GetElementDimension(unsigned int &dimension, unsigned int &number_of_vertices)
Definition: select_elements_mesher_process.hpp:690
int mEchoLevel
Definition: select_elements_mesher_process.hpp:381
std::string Info() const override
Turn back information as a string.
Definition: select_elements_mesher_process.hpp:344
void GetTriangleFluidElementAlpha(double &rAlpha, GeometryType &rVertices, const NodalFlags &rVerticesFlags, const unsigned int &rDimension)
Definition: select_elements_mesher_process.hpp:810
SelectElementsMesherProcess(ModelPart &rModelPart, MesherUtilities::MeshingParameters &rRemeshingParameters, int EchoLevel)
Default constructor.
Definition: select_elements_mesher_process.hpp:64
void GetAlphaParameter(double &rAlpha, GeometryType &rVertices, const NodalFlags &rVerticesFlags, const unsigned int &rDimension)
Definition: select_elements_mesher_process.hpp:767
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: select_elements_mesher_process.hpp:83
void SelectNodesToErase()
Definition: select_elements_mesher_process.hpp:539
MesherUtilities mMesherUtilities
Definition: select_elements_mesher_process.hpp:379
void LabelEdgeNodes(ModelPart &rModelPart)
Definition: select_elements_mesher_process.hpp:480
void GetTetrahedronFluidElementAlpha(double &rAlpha, GeometryType &rVertices, const NodalFlags &rVerticesFlags, const unsigned int &rDimension)
Definition: select_elements_mesher_process.hpp:934
virtual ~SelectElementsMesherProcess()
Destructor.
Definition: select_elements_mesher_process.hpp:75
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: select_elements_mesher_process.hpp:95
KRATOS_CLASS_POINTER_DEFINITION(SelectElementsMesherProcess)
Pointer definition of Process.
ModelPart & mrModelPart
Definition: select_elements_mesher_process.hpp:375
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: select_elements_mesher_process.hpp:350
ModelPart::ConditionType ConditionType
Definition: select_elements_mesher_process.hpp:55
ConditionType::GeometryType GeometryType
Definition: select_elements_mesher_process.hpp:57
bool CheckElementBoundaries(GeometryType &rVertices, const NodalFlags &rVerticesFlags)
Definition: select_elements_mesher_process.hpp:712
bool IsFirstTimeStep()
Definition: select_elements_mesher_process.hpp:466
MesherUtilities::MeshingParameters & mrRemesh
Definition: select_elements_mesher_process.hpp:377
void CheckIds(const int *OutElementList, const int &OutNumberOfElements, const unsigned int number_of_vertices)
Definition: select_elements_mesher_process.hpp:668
bool CheckElementShape(GeometryType &rVertices, const NodalFlags &rVerticesFlags, const unsigned int &rDimension, unsigned int &number_of_slivers)
Definition: select_elements_mesher_process.hpp:1079
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: select_elements_mesher_process.hpp:356
ModelPart::PropertiesType PropertiesType
Definition: select_elements_mesher_process.hpp:56
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
double Volume() const override
Definition: tetrahedra_3d_4.h:450
#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
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
pn
Definition: generate_droplet_dynamics.py:65
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
def Alpha(n, j)
Definition: quadrature.py:93
int j
Definition: quadrature.py:648
el
Definition: read_stl.py:25
integer i
Definition: TensorModule.f:17
int * GetElementList()
Definition: mesher_utilities.hpp:178
int & GetNumberOfElements()
Definition: mesher_utilities.hpp:183
Definition: mesher_utilities.hpp:631
MeshingInfoParameters::Pointer Info
Definition: mesher_utilities.hpp:681
Flags Options
Definition: mesher_utilities.hpp:645
std::vector< int > PreservedElements
Definition: mesher_utilities.hpp:669
RefiningParameters::Pointer Refine
Definition: mesher_utilities.hpp:684
bool MeshElementsSelectedFlag
Definition: mesher_utilities.hpp:662
MeshContainer OutMesh
Definition: mesher_utilities.hpp:675
double OffsetFactor
Definition: mesher_utilities.hpp:652
std::vector< int > NodalPreIds
Definition: mesher_utilities.hpp:668
double AlphaParameter
Definition: mesher_utilities.hpp:651
Flags ExecutionOptions
Definition: mesher_utilities.hpp:648
Definition: select_elements_mesher_process.hpp:383
unsigned int Rigid
Definition: select_elements_mesher_process.hpp:387
unsigned int OldEntity
Definition: select_elements_mesher_process.hpp:396
unsigned int Sliver
Definition: select_elements_mesher_process.hpp:394
unsigned int Boundary
Definition: select_elements_mesher_process.hpp:388
unsigned int Slave
Definition: select_elements_mesher_process.hpp:397
unsigned int Isolated
Definition: select_elements_mesher_process.hpp:393
unsigned int Fluid
Definition: select_elements_mesher_process.hpp:386
unsigned int Inlet
Definition: select_elements_mesher_process.hpp:392
unsigned int Contact
Definition: select_elements_mesher_process.hpp:391
unsigned int FreeSurface
Definition: select_elements_mesher_process.hpp:389
unsigned int NewEntity
Definition: select_elements_mesher_process.hpp:395
unsigned int NoWallFreeSurface
Definition: select_elements_mesher_process.hpp:390
NodalFlags()
Definition: select_elements_mesher_process.hpp:402
unsigned int Solid
Definition: select_elements_mesher_process.hpp:385
void CountFlags(const Node &rNode)
Definition: select_elements_mesher_process.hpp:421
double Radius
Definition: select_elements_mesher_process.hpp:399