From 8acd5cd3a25b1ccfc88e8101ac6ac434cee1e8be Mon Sep 17 00:00:00 2001 From: Veselin Dobrev Date: Fri, 13 Feb 2026 10:29:22 -0800 Subject: [PATCH] Fix a size bug in thread-safe mode in H1_TriangleElement::CalcHessian. Fix use-after-delete bug in nurbs_ex10p.cpp. Use relative tolerance in the "Collocated Derivative Kernels" unit test to resolve failures in some setups with the original absolute tolerance. --- fem/fe/fe_h1.cpp | 2 +- miniapps/nurbs/nurbs_ex10p.cpp | 2 +- tests/unit/fem/test_col_lag_der.cpp | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fem/fe/fe_h1.cpp b/fem/fe/fe_h1.cpp index b164cb94f0..7380244500 100644 --- a/fem/fe/fe_h1.cpp +++ b/fem/fe/fe_h1.cpp @@ -589,7 +589,7 @@ void H1_TriangleElement::CalcHessian(const IntegrationPoint &ip, Vector shape_x(p + 1), shape_y(p + 1), shape_l(p + 1); Vector dshape_x(p + 1), dshape_y(p + 1), dshape_l(p + 1); Vector ddshape_x(p + 1), ddshape_y(p + 1), ddshape_l(p + 1); - DenseMatrix ddu(dof, dim); + DenseMatrix ddu(dof, (dim*(dim+1))/2); #endif poly1d.CalcBasis(p, ip.x, shape_x, dshape_x, ddshape_x); diff --git a/miniapps/nurbs/nurbs_ex10p.cpp b/miniapps/nurbs/nurbs_ex10p.cpp index 65614af5d3..838f2b0f3f 100644 --- a/miniapps/nurbs/nurbs_ex10p.cpp +++ b/miniapps/nurbs/nurbs_ex10p.cpp @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) // parallel degrees of freedom, with offsets given by array true_offset. FiniteElementCollection *fec = nullptr; NURBSExtension *NURBSext = nullptr; - if (mesh->NURBSext) + if (pmesh->NURBSext) { NURBSext = new NURBSExtension(pmesh->NURBSext, order); fec = new NURBSFECollection(order); diff --git a/tests/unit/fem/test_col_lag_der.cpp b/tests/unit/fem/test_col_lag_der.cpp index 3680ad56b2..7367ab4804 100644 --- a/tests/unit/fem/test_col_lag_der.cpp +++ b/tests/unit/fem/test_col_lag_der.cpp @@ -151,6 +151,8 @@ TEST_CASE("Collocated Derivative Kernels", "[QuadratureInterpolator]") auto L = GENERATE(QVectorLayout::byNODES, QVectorLayout::byVDIM); auto P = GENERATE(true, false); + CAPTURE(L, P); + const int nd = maps.ndof; const int nq = maps.nqpt; @@ -163,7 +165,15 @@ TEST_CASE("Collocated Derivative Kernels", "[QuadratureInterpolator]") CGK::Run(dim, L, P, vdim, nd, nelem, maps.G.Read(), geom->J.Read(), evec_values.Read(), col_der.Write(), sdim, vdim, nd); + const real_t max_norm = qp_der.Normlinf(); + qp_der -= col_der; - REQUIRE(qp_der.Normlinf() == MFEM_Approx(0.0, 1e-10, 1e-10)); + + const real_t abs_err = qp_der.Normlinf(); + const real_t rel_err = max_norm > 0_r ? + abs_err/max_norm : + abs_err > 0_r ? mfem::infinity() : 0_r; + CAPTURE(rel_err, max_norm); + CHECK(rel_err <= 8e-14); } }