[FEM] Possibly fix race conditions

Race conditions introduced after using OpenMP in `FemMesh::getNodesByFace` and
`FemMesh::getNodesBySolid` because of which nodes were randomly added or removed
from sets. Solved by replacing `SMDS_MeshNode::X()` etc., which are not thread
safe, with the thread-safe `SMDS_MeshNode::GetXYZ()`.
This commit is contained in:
Ajinkya Dahale
2021-08-19 11:57:54 -04:00
committed by Uwe
parent 8087b34840
commit 147f2a0b07

View File

@@ -882,16 +882,18 @@ std::set<int> FemMesh::getNodesBySolid(const TopoDS_Solid &solid) const
#pragma omp parallel for schedule(dynamic)
for (size_t i = 0; i < nodes.size(); ++i) {
const SMDS_MeshNode* aNode = nodes[i];
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
double xyz[3];
aNode->GetXYZ(xyz);
Base::Vector3d vec(xyz[0], xyz[1], xyz[2]);
// Apply the matrix to hold the BoundBox in absolute space.
vec = Mtrx * vec;
if (!box.IsOut(gp_Pnt(vec.x,vec.y,vec.z))) {
// create a vertex
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x,vec.y,vec.z));
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x, vec.y, vec.z));
TopoDS_Shape s = aBuilder.Vertex();
// measure distance
BRepExtrema_DistShapeShape measure(solid,s);
BRepExtrema_DistShapeShape measure(solid, s);
measure.Perform();
if (!measure.IsDone() || measure.NbSolution() < 1)
continue;
@@ -929,16 +931,18 @@ std::set<int> FemMesh::getNodesByFace(const TopoDS_Face &face) const
#pragma omp parallel for schedule(dynamic)
for (size_t i = 0; i < nodes.size(); ++i) {
const SMDS_MeshNode* aNode = nodes[i];
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
double xyz[3];
aNode->GetXYZ(xyz);
Base::Vector3d vec(xyz[0], xyz[1], xyz[2]);
// Apply the matrix to hold the BoundBox in absolute space.
vec = Mtrx * vec;
if (!box.IsOut(gp_Pnt(vec.x,vec.y,vec.z))) {
// create a vertex
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x,vec.y,vec.z));
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x, vec.y, vec.z));
TopoDS_Shape s = aBuilder.Vertex();
// measure distance
BRepExtrema_DistShapeShape measure(face,s);
BRepExtrema_DistShapeShape measure(face, s);
measure.Perform();
if (!measure.IsDone() || measure.NbSolution() < 1)
continue;