Skip to content

Commit 05c9ac4

Browse files
authored
Merge pull request #4080 from lindsayad/thread-safety-for-failed-point-inversion
Add thread safety for when multiple threads are failing point inversion
2 parents 5d4c38f + 3bc6227 commit 05c9ac4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/fe/fe_map.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,11 @@ class FEMap
10421042
* Work vector for compute_affine_map()
10431043
*/
10441044
std::vector<const Node *> _elem_nodes;
1045+
1046+
/**
1047+
* A mutex for locking the error stream for failed point inversions
1048+
*/
1049+
static Threads::spin_mutex _point_inv_err_mutex;
10451050
};
10461051

10471052

src/fe/fe_map.C

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
namespace libMesh
4242
{
43+
Threads::spin_mutex FEMap::_point_inv_err_mutex;
4344

4445
FEFamily
4546
FEMap::map_fe_type(const Elem & elem)
@@ -892,10 +893,11 @@ void FEMap::compute_single_point_map(const unsigned int dim,
892893
// Don't call print_info() recursively if we're already
893894
// failing. print_info() calls Elem::volume() which may
894895
// call FE::reinit() and trigger the same failure again.
895-
static bool failing = false;
896+
thread_local bool failing = false;
896897
if (!failing)
897898
{
898899
failing = true;
900+
Threads::spin_mutex::scoped_lock lock(_point_inv_err_mutex);
899901
elem->print_info(libMesh::err);
900902
failing = false;
901903
if (calculate_xyz)

0 commit comments

Comments
 (0)