Skip to content

Commit 9eb71b8

Browse files
committed
Fix race condition in GetFaceDofsFromAdjacentElement from mfem internal IsoparametricTransformation usage
1 parent 9c50b94 commit 9eb71b8

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ The format of this changelog is based on
108108
- Fix bug in using `"MakeSimplex"` which would cause undefined behaviour for higher order
109109
meshes.
110110
- Fix bug when combining OpenMP and GPU builds in reduction operations over `Vector`.
111+
- Fix race condition that would affect OpenMP parallelism with periodic boundaries (exact
112+
and Floquet).
111113

112114
## [0.13.0] - 2024-05-20
113115

palace/fem/libceed/restriction.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,25 @@ mfem::Array<int> GetFaceDofsFromAdjacentElement(const mfem::FiniteElementSpace &
5151
// Get coordinates of element dofs.
5252
mfem::DenseMatrix elem_pm;
5353
const mfem::FiniteElement *fe_elem = fespace.GetFE(elem_id);
54-
mfem::ElementTransformation *T = fespace.GetMesh()->GetElementTransformation(elem_id);
55-
T->Transform(fe_elem->GetNodes(), elem_pm);
54+
mfem::IsoparametricTransformation T;
55+
fespace.GetMesh()->GetElementTransformation(elem_id, &T);
56+
T.Transform(fe_elem->GetNodes(), elem_pm);
5657

5758
// Find the dofs.
5859
double tol = 1E-5;
5960
mfem::Array<int> elem_dofs, dofs(P);
61+
dofs = -123456789;
6062
fespace.GetElementDofs(elem_id, elem_dofs, dof_trans);
63+
6164
for (int l = 0; l < P; l++)
6265
{
6366
double norm2_f = 0.0;
6467
for (int m = 0; m < face_pm.Height(); m++)
6568
{
6669
norm2_f += face_pm(m, l) * face_pm(m, l);
6770
}
71+
72+
bool found_match = false;
6873
for (int m = 0; m < elem_pm.Width(); m++)
6974
{
7075
double norm2_e = 0.0;
@@ -81,9 +86,28 @@ mfem::Array<int> GetFaceDofsFromAdjacentElement(const mfem::FiniteElementSpace &
8186
if (diff <= relative_tol)
8287
{
8388
dofs[l] = elem_dofs[m];
89+
found_match = true;
90+
break;
8491
}
8592
}
93+
94+
MFEM_ASSERT(found_match,
95+
[&]()
96+
{
97+
std::stringstream msg;
98+
msg << "l " << l << '\n';
99+
msg << "elem_dofs\n";
100+
for (auto x : elem_dofs)
101+
msg << x << ' ';
102+
103+
msg << "\ndofs\n";
104+
for (auto x : dofs)
105+
msg << x << ' ';
106+
msg << '\n';
107+
return msg.str();
108+
}());
86109
}
110+
87111
return dofs;
88112
};
89113

0 commit comments

Comments
 (0)