10 #if !defined(KRATOS_SET_ACTIVE_FLAG_MESHER_PROCESS_H_INCLUDED)
11 #define KRATOS_SET_ACTIVE_FLAG_MESHER_PROCESS_H_INCLUDED
82 bool unactivePeakElements,
83 bool unactiveSliverElements,
108 double tolerance = 0.0000000001;
110 const double timeInterval = rCurrentProcessInfo[DELTA_TIME];
112 unsigned int sliversDetectedFromVolume = 0;
113 unsigned int sliversDetectedFromShape = 0;
118 double ModelPartVolume = 0;
126 bool sliverEliminationCriteria =
false;
127 bool peakElementsEliminationCriteria =
false;
128 bool wallElementsEliminationCriteria =
false;
129 unsigned int numNodes = itElem->GetGeometry().size();
134 double ElementalVolume = 0;
137 ElementalVolume = (itElem)->GetGeometry().Area();
142 if (itElem->GetGeometry().WorkingSpaceDimension() == 3)
143 ElementalVolume = (itElem)->GetGeometry().Volume();
151 if (fabs(ElementalVolume) < CriticalVolume)
153 sliverEliminationCriteria =
true;
154 sliversDetectedFromVolume++;
163 if (sliverEliminationCriteria ==
false &&
dimension == 3)
174 a1 = (nodeB[1] - nodeA[1]) * (nodeC[2] - nodeA[2]) - (nodeC[1] - nodeA[1]) * (nodeB[2] - nodeA[2]);
175 b1 = (nodeB[2] - nodeA[2]) * (nodeC[0] - nodeA[0]) - (nodeC[2] - nodeA[2]) * (nodeB[0] - nodeA[0]);
176 c1 = (nodeB[0] - nodeA[0]) * (nodeC[1] - nodeA[1]) - (nodeC[0] - nodeA[0]) * (nodeB[1] - nodeA[1]);
180 a2 = (nodeB[1] - nodeA[1]) * (nodeD[2] - nodeA[2]) - (nodeD[1] - nodeA[1]) * (nodeB[2] - nodeA[2]);
181 b2 = (nodeB[2] - nodeA[2]) * (nodeD[0] - nodeA[0]) - (nodeD[2] - nodeA[2]) * (nodeB[0] - nodeA[0]);
182 c2 = (nodeB[0] - nodeA[0]) * (nodeD[1] - nodeA[1]) - (nodeD[0] - nodeA[0]) * (nodeB[1] - nodeA[1]);
186 a3 = (nodeB[1] - nodeC[1]) * (nodeD[2] - nodeC[2]) - (nodeD[1] - nodeC[1]) * (nodeB[2] - nodeC[2]);
187 b3 = (nodeB[2] - nodeC[2]) * (nodeD[0] - nodeC[0]) - (nodeD[2] - nodeC[2]) * (nodeB[0] - nodeC[0]);
188 c3 = (nodeB[0] - nodeC[0]) * (nodeD[1] - nodeC[1]) - (nodeD[0] - nodeC[0]) * (nodeB[1] - nodeC[1]);
192 a4 = (nodeA[1] - nodeC[1]) * (nodeD[2] - nodeC[2]) - (nodeD[1] - nodeC[1]) * (nodeA[2] - nodeC[2]);
193 b4 = (nodeA[2] - nodeC[2]) * (nodeD[0] - nodeC[0]) - (nodeD[2] - nodeC[2]) * (nodeA[0] - nodeC[0]);
194 c4 = (nodeA[0] - nodeC[0]) * (nodeD[1] - nodeC[1]) - (nodeD[0] - nodeC[0]) * (nodeA[1] - nodeC[1]);
196 double cosAngle12 = (a1 * a2 + b1 * b2 + c1 * c2) / (sqrt(pow(a1, 2) + pow(b1, 2) + pow(c1, 2)) * sqrt(pow(a2, 2) + pow(b2, 2) + pow(c2, 2)));
197 double cosAngle13 = (a1 * a3 + b1 * b3 + c1 * c3) / (sqrt(pow(a1, 2) + pow(b1, 2) + pow(c1, 2)) * sqrt(pow(a3, 2) + pow(b3, 2) + pow(c3, 2)));
198 double cosAngle14 = (a1 * a4 + b1 * b4 + c1 * c4) / (sqrt(pow(a1, 2) + pow(b1, 2) + pow(c1, 2)) * sqrt(pow(a4, 2) + pow(b4, 2) + pow(c4, 2)));
199 double cosAngle23 = (a3 * a2 + b3 * b2 + c3 * c2) / (sqrt(pow(a3, 2) + pow(b3, 2) + pow(c3, 2)) * sqrt(pow(a2, 2) + pow(b2, 2) + pow(c2, 2)));
200 double cosAngle24 = (a4 * a2 + b4 * b2 + c4 * c2) / (sqrt(pow(a4, 2) + pow(b4, 2) + pow(c4, 2)) * sqrt(pow(a2, 2) + pow(b2, 2) + pow(c2, 2)));
201 double cosAngle34 = (a4 * a3 + b4 * b3 + c4 * c3) / (sqrt(pow(a4, 2) + pow(b4, 2) + pow(c4, 2)) * sqrt(pow(a3, 2) + pow(b3, 2) + pow(c3, 2)));
204 double limit = 0.99999;
205 if (fabs(cosAngle12) >
limit || fabs(cosAngle13) >
limit || fabs(cosAngle14) >
limit || fabs(cosAngle23) >
limit || fabs(cosAngle24) >
limit || fabs(cosAngle34) >
limit)
207 unsigned int fsNodes = 0;
208 for (
unsigned int i = 0;
i < numNodes;
i++)
210 if (itElem->GetGeometry()[
i].Is(FREE_SURFACE))
215 unsigned int neighborNodes = rN.
size();
216 if (neighborNodes == numNodes)
224 sliverEliminationCriteria =
true;
225 sliversDetectedFromShape++;
234 double scalarProduct = 1.0;
235 bool doNotErase =
false;
236 unsigned int elementRigidNodes = 0;
237 for (
unsigned int i = 0;
i < numNodes;
i++)
239 if (itElem->GetGeometry()[
i].Is(RIGID) && itElem->GetGeometry()[
i].IsNot(SOLID))
243 if (itElem->GetGeometry()[
i].IsNot(RIGID) && itElem->GetGeometry()[
i].IsNot(FREE_SURFACE))
245 peakElementsEliminationCriteria =
false;
249 else if (itElem->GetGeometry()[
i].Is(RIGID) && itElem->GetGeometry()[
i].IsNot(SOLID) && itElem->GetGeometry()[
i].Is(FREE_SURFACE) && doNotErase ==
false)
251 peakElementsEliminationCriteria =
true;
252 const array_1d<double, 3> &wallVelocity = itElem->GetGeometry()[
i].FastGetSolutionStepValue(VELOCITY);
253 double normWallVelocity =
norm_2(wallVelocity);
254 if (normWallVelocity == 0)
256 for (
unsigned int j = 0;
j < numNodes;
j++)
259 if (itElem->GetGeometry()[
j].IsNot(RIGID) && itElem->GetGeometry()[
j].Is(FREE_SURFACE))
261 Point freeSurfaceToRigidNodeVector =
Point{itElem->GetGeometry()[
i].
Coordinates() - itElem->GetGeometry()[
j].Coordinates()};
262 const array_1d<double, 3> &freeSurfaceVelocity = itElem->GetGeometry()[
j].FastGetSolutionStepValue(VELOCITY);
264 double freeSurfaceToRigidNodeDistance = sqrt(freeSurfaceToRigidNodeVector[0] * freeSurfaceToRigidNodeVector[0] +
265 freeSurfaceToRigidNodeVector[1] * freeSurfaceToRigidNodeVector[1] +
266 freeSurfaceToRigidNodeVector[2] * freeSurfaceToRigidNodeVector[2]);
267 double displacementFreeSurface = timeInterval * (sqrt(freeSurfaceVelocity[0] * freeSurfaceVelocity[0] +
268 freeSurfaceVelocity[1] * freeSurfaceVelocity[1] +
269 freeSurfaceVelocity[2] * freeSurfaceVelocity[2]));
272 scalarProduct = freeSurfaceToRigidNodeVector[0] * freeSurfaceVelocity[0] + freeSurfaceToRigidNodeVector[1] * freeSurfaceVelocity[1];
276 scalarProduct = freeSurfaceToRigidNodeVector[0] * freeSurfaceVelocity[0] + freeSurfaceToRigidNodeVector[1] * freeSurfaceVelocity[1] + freeSurfaceToRigidNodeVector[2] * freeSurfaceVelocity[2];
278 if (scalarProduct > tolerance && displacementFreeSurface > (0.01 * freeSurfaceToRigidNodeDistance))
281 peakElementsEliminationCriteria =
false;
289 unsigned int rigidNodes = 0;
290 unsigned int freeSurfaceNodes = 0;
291 for (
unsigned int i = 0;
i < rN.
size();
i++)
293 if (rN[
i].
Is(RIGID) && rN[
i].IsNot(SOLID))
295 if (rN[
i].
Is(FREE_SURFACE) && rN[
i].IsNot(RIGID))
296 freeSurfaceNodes += 1;
300 if (rigidNodes == rN.
size())
302 peakElementsEliminationCriteria =
false;
309 if (rigidNodes == rN.
size() || freeSurfaceNodes == 1 || (scalarProduct > tolerance && freeSurfaceNodes < 4))
311 peakElementsEliminationCriteria =
false;
322 if (elementRigidNodes == numNodes)
324 wallElementsEliminationCriteria =
true;
332 unsigned int elementRigidNodes = 0;
333 for (
unsigned int i = 0;
i < numNodes;
i++)
335 if (itElem->GetGeometry()[
i].Is(RIGID) && itElem->GetGeometry()[
i].IsNot(SOLID))
341 if (elementRigidNodes == numNodes)
343 wallElementsEliminationCriteria =
true;
349 if (sliverEliminationCriteria ==
true || peakElementsEliminationCriteria ==
true || wallElementsEliminationCriteria ==
true)
351 (itElem)->
Set(ACTIVE,
false);
355 (itElem)->
Set(ACTIVE,
true);
388 std::string
Info()
const override
390 return "SetActiveFlagMesherProcess";
396 rOStream <<
"SetActiveFlagMesherProcess";
477 rOStream << std::endl;
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
Geometry base class.
Definition: geometry.h:71
PointerVector< TPointType > PointsArrayType
Definition: geometry.h:118
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
size_type size() const
Definition: global_pointers_vector.h:307
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mesher_process.hpp:157
Short class definition.
Definition: mesher_utilities.hpp:49
double ComputeModelPartVolume(ModelPart &rModelPart)
Definition: mesher_utilities.cpp:228
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::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
static void PartitionedIterators(TVector &rVector, typename TVector::iterator &rBegin, typename TVector::iterator &rEnd)
Generate a partition for an std::vector-like array, providing iterators to the begin and end position...
Definition: openmp_utils.h:179
Point class.
Definition: point.h:59
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Short class definition.
Definition: set_active_flag_mesher_process.hpp:68
void operator()()
Definition: set_active_flag_mesher_process.hpp:94
KRATOS_CLASS_POINTER_DEFINITION(SetActiveFlagMesherProcess)
Pointer definition of SetActiveFlagMesherProcess.
std::string Info() const override
Turn back information as a string.
Definition: set_active_flag_mesher_process.hpp:388
SetActiveFlagMesherProcess(ModelPart &rModelPart, bool unactivePeakElements, bool unactiveSliverElements, int EchoLevel)
Default constructor.
Definition: set_active_flag_mesher_process.hpp:81
virtual ~SetActiveFlagMesherProcess()
Destructor.
Definition: set_active_flag_mesher_process.hpp:90
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: set_active_flag_mesher_process.hpp:394
void Execute() override
Execute method is used to execute the MesherProcess algorithms.
Definition: set_active_flag_mesher_process.hpp:103
Short class definition.
Definition: set_active_flag_process.hpp:69
void SetPressureToIsolatedWallNodes(Geometry< Node > &wallElementNodes)
Definition: set_active_flag_process.hpp:203
bool mUnactiveSliverElements
Definition: set_active_flag_process.hpp:198
bool mUnactivePeakElements
Definition: set_active_flag_process.hpp:197
ModelPart & mrModelPart
Definition: set_active_flag_process.hpp:194
#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
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
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
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
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
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int j
Definition: quadrature.py:648
limit
Definition: run_t_junction_analysis.py:8
integer i
Definition: TensorModule.f:17