[bos #42217][EDF 28921] Horseshoe with bodyfitting.

Fix for prev commit: crash on parallel execution caused reallocation of vector after push_back().
This commit is contained in:
Konstantin Leontev 2024-08-01 20:11:10 +01:00
parent 36b825e934
commit b248263b49

View File

@ -2825,23 +2825,24 @@ namespace
bool Hexahedron::isSplittedLink(const Solid* solid, SMESH_MesherHelper& helper, const Hexahedron::_Link& linkIn) const bool Hexahedron::isSplittedLink(const Solid* solid, SMESH_MesherHelper& helper, const Hexahedron::_Link& linkIn) const
{ {
_Link split; _Link split;
std::vector<_Node> intNodes;
_Link link = linkIn; _Link link = linkIn;
link._fIntNodes.clear(); link._fIntNodes.clear();
link._fIntNodes.reserve( link._fIntPoints.size() ); link._fIntNodes.reserve( link._fIntPoints.size() );
std::vector<_Node> intNodes;
intNodes.reserve(link._fIntPoints.size());
for ( size_t i = 0; i < link._fIntPoints.size(); ++i ) for ( size_t i = 0; i < link._fIntPoints.size(); ++i )
if ( solid->ContainsAny( link._fIntPoints[i]->_faceIDs )) if ( solid->ContainsAny( link._fIntPoints[i]->_faceIDs ))
{ {
intNodes.push_back( _Node( 0, link._fIntPoints[i] )); intNodes.emplace_back(nullptr, link._fIntPoints[i]);
link._fIntNodes.push_back( & intNodes.back() ); link._fIntNodes.push_back( & intNodes.back() );
} }
link._splits.clear();
split._nodes[ 0 ] = link._nodes[0]; split._nodes[ 0 ] = link._nodes[0];
bool isOut = ( ! link._nodes[0]->Node() ); bool isOut = ( ! link._nodes[0]->Node() );
bool checkTransition; bool checkTransition = false;
for ( size_t i = 0; i < link._fIntNodes.size(); ++i ) for ( size_t i = 0; i < link._fIntNodes.size(); ++i )
{ {
const bool isGridNode = ( ! link._fIntNodes[i]->Node() ); const bool isGridNode = ( ! link._fIntNodes[i]->Node() );
@ -4077,12 +4078,14 @@ bool Hexahedron::createVolume(const Solid* solid)
{ {
// A simple case - just one task executed in one thread. // A simple case - just one task executed in one thread.
// TODO: check if it's faster to do it sequentially // TODO: check if it's faster to do it sequentially
// threads.reserve(numTasksTotal); threads.reserve(numTasksTotal);
// for (; it < last; ++it) for (; it < last; ++it)
// { {
// threads.emplace_back(f, std::ref(*it)); threads.emplace_back(f, std::ref(*it));
// } }
std::for_each(it, last, f);
// This line for debug in sequential mode
// std::for_each(it, last, f);
} }
else else
{ {