12 #if !defined(KRATOS_BOUNDARY_NORMALS_CALCULATION_UTILITIES_H_INCLUDED)
13 #define KRATOS_BOUNDARY_NORMALS_CALCULATION_UTILITIES_H_INCLUDED
91 this->ResetBodyNormals(rModelPart);
96 if ((i_mp.Is(FLUID) || i_mp.Is(SOLID) || i_mp.Is(RIGID)) && i_mp.IsNot(ACTIVE) && i_mp.IsNot(BOUNDARY) && i_mp.IsNot(CONTACT))
99 CalculateBoundaryNormals(i_mp);
102 AddNormalsToNodes(i_mp);
110 this->ResetBodyNormals(rModelPart);
112 CalculateBoundaryNormals(rModelPart);
115 AddNormalsToNodes(rModelPart);
126 std::cout <<
"DO NOT ENTER HERE ---- CalculateWeightedBoundaryNormals " << std::endl;
132 this->ResetBodyNormals(rModelPart);
137 if (i_mp.Is(FLUID) && i_mp.IsNot(ACTIVE) && i_mp.IsNot(BOUNDARY) && i_mp.IsNot(CONTACT))
140 CalculateBoundaryNormals(i_mp);
143 AddWeightedNormalsToNodes(i_mp);
149 if (i_mp.Is(SOLID) && i_mp.IsNot(ACTIVE) && i_mp.IsNot(BOUNDARY) && i_mp.IsNot(CONTACT))
152 CalculateBoundaryNormals(i_mp);
155 AddWeightedNormalsToNodes(i_mp);
161 if (i_mp.Is(RIGID) && i_mp.IsNot(ACTIVE) && i_mp.IsNot(BOUNDARY) && i_mp.IsNot(CONTACT))
164 CalculateBoundaryNormals(i_mp);
167 AddWeightedNormalsToNodes(i_mp);
174 this->ResetBodyNormals(rModelPart);
176 CalculateBoundaryNormals(rModelPart);
241 void CalculateBoundaryNormals(
ModelPart &rModelPart)
251 std::cout <<
" [" << rModelPart.
Name() <<
"] (BC)" << std::endl;
253 this->CalculateBoundaryNormals(rModelPart.
Conditions());
258 if (this->CheckElementsLocalSpace(rModelPart,
dimension))
262 std::cout <<
" [" << rModelPart.
Name() <<
"] (BVE)" << std::endl;
264 this->CalculateVolumeBoundaryNormals(rModelPart);
266 else if (this->CheckElementsLocalSpace(rModelPart,
dimension - 1))
270 std::cout <<
" [" << rModelPart.
Name() <<
"] (BE)" << std::endl;
274 this->CalculateBoundaryNormals(rElements);
283 static void CalculateUnitNormal2D(Condition &rCondition, array_1d<double, 3> &An)
285 Geometry<Node> &rGeometry = rCondition.GetGeometry();
288 An[0] = rGeometry[1].Y() - rGeometry[0].Y();
289 An[1] = -(rGeometry[1].X() - rGeometry[0].X());
292 array_1d<double, 3> &normal = rCondition.GetValue(NORMAL);
296 static void CalculateUnitNormal3D(Condition &rCondition, array_1d<double, 3> &An,
297 array_1d<double, 3> &v1, array_1d<double, 3> &v2)
299 Geometry<Node> &rGeometry = rCondition.GetGeometry();
301 v1[0] = rGeometry[1].X() - rGeometry[0].X();
302 v1[1] = rGeometry[1].Y() - rGeometry[0].Y();
303 v1[2] = rGeometry[1].Z() - rGeometry[0].Z();
305 v2[0] = rGeometry[2].X() - rGeometry[0].X();
306 v2[1] = rGeometry[2].Y() - rGeometry[0].Y();
307 v2[2] = rGeometry[2].Z() - rGeometry[0].Z();
311 array_1d<double, 3> &normal = rCondition.GetValue(NORMAL);
318 static void CalculateUnitNormal2D(Element &rElement, array_1d<double, 3> &An)
320 Geometry<Node> &rGeometry = rElement.GetGeometry();
322 if (rGeometry.size() < 2)
324 std::cout <<
" Warning 2D geometry with only " << rGeometry.size() <<
" node :: multiple normal definitions " << std::endl;
325 rElement.GetValue(NORMAL).clear();
330 An[0] = -(rGeometry[1].Y() - rGeometry[0].Y());
331 An[1] = rGeometry[1].X() - rGeometry[0].X();
334 array_1d<double, 3> &normal = rElement.GetValue(NORMAL);
339 static void CalculateUnitNormal3D(Element &rElement, array_1d<double, 3> &An,
340 array_1d<double, 3> &v1, array_1d<double, 3> &v2)
342 Geometry<Node> &rGeometry = rElement.GetGeometry();
344 if (rGeometry.size() < 3)
346 std::cout <<
" Warning 3D geometry with only " << rGeometry.size() <<
" nodes :: multiple normal definitions " << std::endl;
347 rElement.GetValue(NORMAL).clear();
352 v1[0] = rGeometry[1].X() - rGeometry[0].X();
353 v1[1] = rGeometry[1].Y() - rGeometry[0].Y();
354 v1[2] = rGeometry[1].Z() - rGeometry[0].Z();
356 v2[0] = rGeometry[2].X() - rGeometry[0].X();
357 v2[1] = rGeometry[2].Y() - rGeometry[0].Y();
358 v2[2] = rGeometry[2].Z() - rGeometry[0].Z();
363 array_1d<double, 3> &normal = rElement.GetValue(NORMAL);
369 void ResetBodyNormals(ModelPart &rModelPart)
372 for (
auto &i_node : rModelPart.Nodes())
374 i_node.GetSolutionStepValue(NORMAL).clear();
378 void CheckBodyNormals(ModelPart &rModelPart)
381 for (
const auto &i_node : rModelPart.Nodes())
383 std::cout <<
" ID: " << i_node.Id() <<
" normal: " << i_node.GetSolutionStepValue(NORMAL) << std::endl;
410 const unsigned int dimension = rConditions.begin()->GetGeometry().WorkingSpaceDimension();
415 array_1d<double, 3> An;
418 for (
auto &i_cond : rConditions)
420 if (i_cond.IsNot(CONTACT) && i_cond.Is(BOUNDARY))
421 CalculateUnitNormal2D(i_cond, An);
426 array_1d<double, 3> v1;
427 array_1d<double, 3> v2;
428 for (
auto &i_cond : rConditions)
431 if (i_cond.IsNot(CONTACT) && i_cond.Is(BOUNDARY))
433 CalculateUnitNormal3D(i_cond, An, v1, v2);
464 const unsigned int dimension = (rElements.begin())->GetGeometry().WorkingSpaceDimension();
469 array_1d<double, 3> An;
472 for (
auto &i_elem : rElements)
474 if (i_elem.IsNot(CONTACT))
476 i_elem.Set(BOUNDARY);
477 CalculateUnitNormal2D(i_elem, An);
483 array_1d<double, 3> v1;
484 array_1d<double, 3> v2;
485 for (
auto &i_elem : rElements)
488 if (i_elem.IsNot(CONTACT))
490 i_elem.Set(BOUNDARY);
491 CalculateUnitNormal3D(i_elem, An, v1, v2);
500 bool CheckElementsDimension(ModelPart &rModelPart,
unsigned int dimension)
506 ElementsContainerType::iterator it = rElements.begin();
508 if ((it)->GetGeometry().WorkingSpaceDimension() ==
dimension)
521 bool CheckConditionsDimension(ModelPart &rModelPart,
unsigned int dimension)
525 if (rModelPart.Conditions().begin()->GetGeometry().WorkingSpaceDimension() ==
dimension)
538 bool CheckElementsLocalSpace(ModelPart &rModelPart,
unsigned int dimension)
542 if (rModelPart.Elements().begin()->GetGeometry().LocalSpaceDimension() ==
dimension)
555 bool CheckConditionsLocalSpace(ModelPart &rModelPart,
unsigned int dimension)
559 if (rModelPart.Conditions().begin()->GetGeometry().LocalSpaceDimension() ==
dimension)
574 void CalculateVolumeBoundaryNormals(ModelPart &rModelPart)
578 const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
585 bool neighsearch =
false;
586 unsigned int number_of_nodes = rElements.
begin()->GetGeometry().PointsNumber();
587 for (
unsigned int i = 0;
i < number_of_nodes; ++
i)
588 if ((rElements.begin()->GetGeometry()[
i].GetValue(NEIGHBOUR_ELEMENTS)).size() > 1)
592 std::cout <<
" WARNING :: Neighbour Search Not PERFORMED " << std::endl;
594 for (
auto &i_node : rNodes)
596 i_node.GetSolutionStepValue(NORMAL).clear();
599 i_node.GetValue(NEIGHBOUR_ELEMENTS).clear();
600 i_node.Reset(BOUNDARY);
606 for (
auto i_elem(rElements.begin()); i_elem != rElements.end(); ++i_elem)
609 for (
unsigned int i = 0;
i < rGeometry.size(); ++
i)
611 rGeometry[
i].GetValue(NEIGHBOUR_ELEMENTS).push_back(*i_elem.base());
626 unsigned int assigned = 0;
627 unsigned int not_assigned = 0;
628 unsigned int boundary_nodes = 0;
630 for (
auto &i_node : rNodes)
638 for (
auto &i_nelem : nElements)
643 if (rGeometry.EdgesNumber() > 1 && rGeometry.LocalSpaceDimension() ==
dimension)
651 J = rGeometry.Jacobian(
J, PointNumber, mIntegrationMethod);
670 DN_DX =
prod(DN_De[PointNumber], InvJ);
672 double IntegrationWeight = integration_points[PointNumber].Weight() * detJ;
674 for (
unsigned int i = 0;
i < rGeometry.size(); ++
i)
676 if (i_node.Id() == rGeometry[
i].Id())
681 An[
d] += DN_DX(
i,
d) * IntegrationWeight;
691 noalias(i_node.FastGetSolutionStepValue(NORMAL)) = An /
norm_2(An);
695 i_node.Set(BOUNDARY);
700 (i_node.FastGetSolutionStepValue(NORMAL)).clear();
705 i_node.Set(BOUNDARY,
false);
710 if (i_node.Is(BOUNDARY))
718 std::cout <<
" [ Boundary_Normals (Mesh Nodes:" << rNodes.size() <<
")[Boundary nodes: " << boundary_nodes <<
" (SET:" << assigned <<
" / NOT_SET:" << not_assigned <<
")] ]" << std::endl;
727 void AddNormalsToNodes(ModelPart &rModelPart)
731 const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
733 if (rModelPart.NumberOfConditions() && this->CheckConditionsDimension(rModelPart,
dimension - 1))
739 for (
auto &i_cond : rModelPart.Conditions())
741 Geometry<Node> &rGeometry = i_cond.GetGeometry();
742 double coeff = 1.00 / rGeometry.size();
743 const array_1d<double, 3> &An = i_cond.GetValue(NORMAL);
745 for (
unsigned int i = 0;
i < rGeometry.size(); ++
i)
747 noalias(rGeometry[
i].FastGetSolutionStepValue(NORMAL)) +=
coeff * An;
751 else if (rModelPart.NumberOfElements() && this->CheckElementsDimension(rModelPart,
dimension - 1))
755 for (
auto &i_elem : rModelPart.Elements())
757 Geometry<Node> &rGeometry = i_elem.GetGeometry();
758 double coeff = 1.00 / rGeometry.size();
759 const array_1d<double, 3> &An = i_elem.GetValue(NORMAL);
761 for (
unsigned int i = 0;
i < rGeometry.size(); ++
i)
763 noalias(rGeometry[
i].FastGetSolutionStepValue(NORMAL)) +=
coeff * An;
774 void AddWeightedNormalsToNodes(ModelPart &rModelPart)
778 const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
783 std::vector<int> NodeNeighboursIds(MaxNodeId + 1);
784 std::fill(NodeNeighboursIds.begin(), NodeNeighboursIds.end(), 0);
787 std::cout <<
" [" << rModelPart.Name() <<
"] [conditions:" << rModelPart.NumberOfConditions() <<
", elements:" << rModelPart.NumberOfElements() <<
"] dimension: " <<
dimension << std::endl;
789 if (rModelPart.NumberOfConditions() && this->CheckConditionsLocalSpace(rModelPart,
dimension - 1))
793 std::cout <<
" [" << rModelPart.Name() <<
"] (C)" << std::endl;
796 std::vector<ConditionWeakPtrVectorType> Neighbours(rNodes.size() + 1);
799 for (
auto i_cond(rModelPart.Conditions().begin()); i_cond != rModelPart.Conditions().end(); ++i_cond)
801 if (i_cond->IsNot(CONTACT) && i_cond->Is(BOUNDARY))
807 std::cout <<
" Condition ID " << i_cond->Id() <<
" id " <<
id << std::endl;
809 for (
unsigned int i = 0;
i < rGeometry.size(); ++
i)
813 if (NodeNeighboursIds.size() <= rGeometry[
i].Id())
814 std::cout <<
" Shrink node in geom " << rGeometry[
i].Id() <<
" number of nodes " << NodeNeighboursIds.size() << std::endl;
817 if (NodeNeighboursIds[rGeometry[
i].Id()] == 0)
819 NodeNeighboursIds[rGeometry[
i].Id()] = id;
820 Neighbours[id].push_back(*i_cond.base());
825 Neighbours[NodeNeighboursIds[rGeometry[
i].Id()]].push_back(*i_cond.base());
834 ModelPart::NodesContainerType::iterator nodes_begin = rNodes.begin();
837 if (rModelPart.Is(FLUID))
839 for (
unsigned int i = 0;
i < rNodes.size(); ++
i)
841 if ((nodes_begin +
i)->Is(BOUNDARY) && (nodes_begin +
i)->IsNot(RIGID) && NodeNeighboursIds[(nodes_begin +
i)->Id()] != 0)
843 BoundaryNodes.
push_back(*(nodes_begin +
i).base());
850 for (
unsigned int i = 0;
i < rNodes.size(); ++
i)
852 if ((nodes_begin +
i)->Is(BOUNDARY) && NodeNeighboursIds[(nodes_begin +
i)->Id()] != 0)
854 BoundaryNodes.push_back(*(nodes_begin +
i).base());
859 ComputeBoundaryShrinkage<Condition>(BoundaryNodes, Neighbours, NodeNeighboursIds,
dimension);
862 else if (rModelPart.NumberOfElements() && this->CheckElementsLocalSpace(rModelPart,
dimension - 1))
866 std::cout <<
" [" << rModelPart.Name() <<
"] (E) " << std::endl;
871 std::vector<ElementWeakPtrVectorType> Neighbours(rNodes.size() + 1);
874 for (
auto i_elem(rElements.begin()); i_elem != rElements.end(); ++i_elem)
876 if (i_elem->IsNot(CONTACT) && i_elem->Is(BOUNDARY))
882 std::cout <<
" Element ID " << i_elem->Id() <<
" id " <<
id << std::endl;
884 for (
unsigned int i = 0;
i < rGeometry.size(); ++
i)
888 if (NodeNeighboursIds.size() <= rGeometry[
i].Id())
889 std::cout <<
" Shrink node in geom " << rGeometry[
i].Id() <<
" number of nodes " << NodeNeighboursIds.size() <<
" Ids[id] " << NodeNeighboursIds[rGeometry[
i].Id()] << std::endl;
892 if (NodeNeighboursIds[rGeometry[
i].Id()] == 0)
894 NodeNeighboursIds[rGeometry[
i].Id()] = id;
895 Neighbours[id].push_back(*i_elem.base());
900 Neighbours[NodeNeighboursIds[rGeometry[
i].Id()]].push_back(*i_elem.base());
909 ModelPart::NodesContainerType::iterator nodes_begin = rNodes.begin();
912 for (
unsigned int i = 0;
i < rNodes.size(); ++
i)
914 if ((nodes_begin +
i)->Is(BOUNDARY) && NodeNeighboursIds[(nodes_begin +
i)->Id()] != 0)
916 BoundaryNodes.
push_back(*((nodes_begin +
i).base()));
920 ComputeBoundaryShrinkage<Element>(BoundaryNodes, Neighbours, NodeNeighboursIds,
dimension);
930 template <
class TClassType>
931 void ComputeBoundaryShrinkage(
ModelPart::NodesContainerType &rNodes,
const std::vector<GlobalPointersVector<TClassType>> &rNeighbours,
const std::vector<int> &rNodeNeighboursIds,
const unsigned int &
dimension)
936 ModelPart::NodesContainerType::iterator NodesBegin = rNodes.begin();
937 int NumberOfNodes = rNodes.size();
939 int not_assigned = 0;
941 #pragma omp parallel for reduction(+ \
943 for (
int pn = 0;
pn < NumberOfNodes; ++
pn)
945 ModelPart::NodesContainerType::iterator iNode = NodesBegin +
pn;
946 unsigned int Id = rNodeNeighboursIds[(iNode)->Id()];
948 double MeanCosinus = 0;
951 double TotalFaces = 0;
952 double ProjectionValue = 0;
953 double NumberOfNormals = 0;
956 int TipAcuteAngles = 0;
958 array_1d<double, 3> &rNormal = (iNode)->FastGetSolutionStepValue(NORMAL);
959 double &rShrinkFactor = (iNode)->FastGetSolutionStepValue(SHRINK_FACTOR);
962 unsigned int NumberOfNeighbourNormals = rNeighbours[Id].size();
963 if (NumberOfNeighbourNormals != 0)
972 std::cout <<
" Id " << Id <<
" normals size " << NumberOfNeighbourNormals <<
" normal " << rNormal <<
" shrink " << rShrinkFactor << std::endl;
973 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
975 std::cout <<
" normal [" << i_norm <<
"][" << (iNode)->Id() <<
"]: " << rNeighbours[Id][i_norm].GetValue(NORMAL) << std::endl;
979 Vector FaceNormals(NumberOfNeighbourNormals);
981 Vector TipNormals(NumberOfNeighbourNormals);
987 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
990 const array_1d<double, 3> &rEntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
992 if (FaceNormals[i_norm] != 1)
995 double CloseProjection = 0;
996 for (
unsigned int j_norm = i_norm + 1; j_norm < NumberOfNeighbourNormals; ++j_norm)
999 const array_1d<double, 3> &rNormalVector = rNeighbours[Id][j_norm].GetValue(NORMAL);
1001 ProjectionValue =
inner_prod(rEntityNormal, rNormalVector);
1003 if (FaceNormals[j_norm] == 0)
1006 if (ProjectionValue > 0.995)
1008 FaceNormals[j_norm] = 1;
1011 else if (ProjectionValue > 0.955)
1013 CloseProjection += 1;
1014 FaceNormals[j_norm] = 2;
1015 FaceNormals[i_norm] = 2;
1019 if (ProjectionValue < -0.005)
1021 TipAcuteAngles += 1;
1022 TipNormals[j_norm] += 1;
1023 TipNormals[i_norm] += 1;
1028 for (
unsigned int j_norm = i_norm; j_norm < NumberOfNeighbourNormals; ++j_norm)
1030 if (FaceNormals[j_norm] == 2 && CloseProjection > 0)
1031 FaceNormals[j_norm] = (1.0 / (CloseProjection + 1));
1034 if (FaceNormals[i_norm] != 0)
1036 rNormal += rEntityNormal * FaceNormals[i_norm];
1037 NumberOfNormals += FaceNormals[i_norm];
1041 rNormal += rEntityNormal;
1042 NumberOfNormals += 1;
1051 if (
dimension == 3 && NumberOfNormals >= 3 && TipAcuteAngles > 0)
1054 std::vector<array_1d<double, 3>> NormalsTriad(3);
1057 if (NumberOfNormals == 3)
1060 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
1062 if (TipNormals[i_norm] >= 1 && FaceNormals[i_norm] == 0)
1065 const array_1d<double, 3> &rEntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
1066 NormalsTriad[SingleFaces] = rEntityNormal;
1071 else if (NumberOfNormals > 3)
1074 std::vector<int> SignificativeNormals(NumberOfNeighbourNormals);
1075 std::fill(SignificativeNormals.begin(), SignificativeNormals.end(), -1);
1077 double MaxProjection = 0;
1078 double Projection = 0;
1081 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
1085 if (TipNormals[i_norm] >= 1 && FaceNormals[i_norm] != 1)
1088 const array_1d<double, 3> &rEntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
1090 for (
unsigned int j_norm = 0; j_norm < NumberOfNeighbourNormals; ++j_norm)
1092 if (TipNormals[j_norm] >= 1 && FaceNormals[j_norm] != 1 && i_norm != j_norm)
1095 const array_1d<double, 3> &rNormalVector = rNeighbours[Id][j_norm].GetValue(NORMAL);
1096 Projection =
inner_prod(rEntityNormal, rNormalVector);
1098 if (MaxProjection < Projection && Projection > 0.3)
1100 MaxProjection = Projection;
1101 SignificativeNormals[i_norm] = j_norm;
1117 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
1120 if (SingleFaces < 3)
1123 if (TipNormals[i_norm] >= 1 && FaceNormals[i_norm] != 1)
1126 array_1d<double, 3> EntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
1128 if (FaceNormals[i_norm] != 0)
1129 EntityNormal *= FaceNormals[i_norm];
1131 for (
unsigned int j_norm = i_norm + 1; j_norm < NumberOfNeighbourNormals; ++j_norm)
1133 if (TipNormals[j_norm] >= 1 && FaceNormals[j_norm] != 1)
1136 if (i_norm == (
unsigned int)SignificativeNormals[j_norm])
1139 const array_1d<double, 3> &rNormalVector = rNeighbours[Id][i_norm].GetValue(NORMAL);
1141 if (FaceNormals[i_norm] != 0)
1143 EntityNormal += rNormalVector * FaceNormals[i_norm];
1147 EntityNormal += rNormalVector;
1150 if (
norm_2(EntityNormal) != 0)
1151 EntityNormal = EntityNormal /
norm_2(EntityNormal);
1153 FaceNormals[j_norm] = 1;
1158 NormalsTriad[SingleFaces] = EntityNormal;
1165 if (SingleFaces < 3)
1168 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
1170 if (SingleFaces == 3)
1173 if (TipNormals[i_norm] >= 1 && FaceNormals[i_norm] != 0 && FaceNormals[i_norm] != 1)
1175 const array_1d<double, 3> &rEntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
1176 NormalsTriad[SingleFaces] = rEntityNormal;
1180 if (TipNormals[i_norm] == 0 && FaceNormals[i_norm] == 0 && SingleFaces > 0)
1182 const array_1d<double, 3> &rEntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
1183 NormalsTriad[SingleFaces] = rEntityNormal;
1189 if (SingleFaces == 2)
1192 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
1194 if (SingleFaces == 3)
1197 if (TipNormals[i_norm] == 0 && FaceNormals[i_norm] != 0 && FaceNormals[i_norm] != 1 && SingleFaces > 0)
1199 NormalsTriad[SingleFaces] = rNormal;
1205 if (SingleFaces == 3)
1208 array_1d<double, 3> CrossProductN;
1210 double Projection =
inner_prod(NormalsTriad[0], CrossProductN);
1212 if (fabs(Projection) > 1
e-15)
1214 rNormal = CrossProductN;
1216 rNormal += CrossProductN;
1218 rNormal += CrossProductN;
1220 rNormal /= Projection;
1224 rNormal = 0.5 * (NormalsTriad[1] + NormalsTriad[2]);
1229 else if (SingleFaces == 2)
1231 rNormal = 0.5 * (NormalsTriad[0] + NormalsTriad[1]);
1237 std::cout <<
" WARNING something was wrong in normal calculation Triad Not found" << std::endl;
1238 std::cout <<
" Face: " << FaceNormals <<
" Tip: " << TipNormals <<
" Id: " << (iNode)->Id() <<
" NumberOfNormals " << NumberOfNormals <<
" SingleFaces " << SingleFaces << std::endl;
1244 rNormal = rNormal /
norm_2(rNormal);
1268 if (
norm_2(rNormal) != 0)
1269 rNormal = rNormal /
norm_2(rNormal);
1271 for (
unsigned int i_norm = 0; i_norm < NumberOfNeighbourNormals; ++i_norm)
1273 if (FaceNormals[i_norm] != 1)
1276 array_1d<double, 3> rEntityNormal = rNeighbours[Id][i_norm].GetValue(NORMAL);
1278 if (
norm_2(rEntityNormal))
1279 rEntityNormal /=
norm_2(rEntityNormal);
1281 ProjectionValue =
inner_prod(rEntityNormal, rNormal);
1283 MeanCosinus += ProjectionValue;
1287 if (TotalFaces != 0)
1288 MeanCosinus *= (1.0 / TotalFaces);
1291 if (MeanCosinus <= 0.3)
1296 if (MeanCosinus > 3)
1297 std::cout <<
" WARNING WRONG MeanCosinus " << MeanCosinus << std::endl;
1299 if (MeanCosinus != 0 && MeanCosinus > 1
e-3)
1301 MeanCosinus = 1.0 / MeanCosinus;
1302 rNormal *= MeanCosinus;
1306 std::cout <<
" Mean Cosinus not consistent " << MeanCosinus <<
" [" << (iNode)->Id() <<
"] rNormal " << rNormal[0] <<
" " << rNormal[1] <<
" " << rNormal[2] << std::endl;
1311 rShrinkFactor =
norm_2(rNormal);
1313 if (rShrinkFactor != 0)
1316 std::cout <<
"[Id " << (iNode)->Id() <<
" shrink_factor " << rShrinkFactor <<
" Normal " << rNormal[0] <<
" " << rNormal[1] <<
" " << rNormal[2] <<
" MeanCosinus " << MeanCosinus <<
"] shrink " << std::endl;
1317 rNormal /= rShrinkFactor;
1323 std::cout <<
"[Id " << (iNode)->Id() <<
" Normal " << rNormal[0] <<
" " << rNormal[1] <<
" " << rNormal[2] <<
" MeanCosinus " << MeanCosinus <<
"] no shrink " << std::endl;
1333 std::cout <<
" [NORMALS SHRINKAGE (BOUNDARY NODES:" << NumberOfNodes <<
") [SET:" << NumberOfNodes - not_assigned <<
" / NOT_SET:" << not_assigned <<
"] " << 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
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: boundary_normals_calculation_utilities.hpp:58
ModelPart::NodesContainerType NodesArrayType
Definition: boundary_normals_calculation_utilities.hpp:53
ModelPart::MeshType MeshType
Definition: boundary_normals_calculation_utilities.hpp:56
GlobalPointersVector< Condition > ConditionWeakPtrVectorType
Definition: boundary_normals_calculation_utilities.hpp:60
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
ModelPart::ElementsContainerType ElementsContainerType
Definition: boundary_normals_calculation_utilities.hpp:54
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: boundary_normals_calculation_utilities.hpp:59
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: boundary_normals_calculation_utilities.hpp:55
virtual bool AssembleCurrentData(Variable< int > const &ThisVariable)
Definition: communicator.cpp:502
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: condition.h:83
GeometryData::IntegrationMethod IntegrationMethod
Type definition for integration methods.
Definition: element.h:105
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: element.h:83
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
GeometryData::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: geometry.h:189
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
static void InvertMatrix3(const TMatrix1 &rInputMatrix, TMatrix2 &rInvertedMatrix, double &rInputMatrixDet)
It inverts matrices of order 3.
Definition: math_utils.h:449
static void InvertMatrix2(const TMatrix1 &rInputMatrix, TMatrix2 &rInvertedMatrix, double &rInputMatrixDet)
It inverts matrices of order 2.
Definition: math_utils.h:416
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
static BoundedMatrix< double, TDim, TDim > InvertMatrix(const BoundedMatrix< double, TDim, TDim > &rInputMatrix, double &rInputMatrixDet, const double Tolerance=ZeroTolerance)
Calculates the inverse of a 2x2, 3x3 and 4x4 matrices (using bounded matrix for performance)
Definition: math_utils.h:197
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1408
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
bool IsSubModelPart() const
Definition: model_part.h:1893
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
std::string & Name()
Definition: model_part.h:1811
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
SizeType NumberOfElements(IndexType ThisIndex=0) const
Definition: model_part.h:1027
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
SubModelPartsContainerType & SubModelParts()
Definition: model_part.h:1718
SizeType NumberOfConditions(IndexType ThisIndex=0) const
Definition: model_part.h:1218
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
#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 min(double a, double b)
Definition: GeometryFunctions.h:71
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
list coeff
Definition: bombardelli_test.py:41
pn
Definition: generate_droplet_dynamics.py:65
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int d
Definition: ode_solve.py:397
J
Definition: sensitivityMatrix.py:58
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31