Skip to content

Commit 03e0ca1

Browse files
authored
Merge pull request #4295 from pbehne/variational_smoother_misc
Variational smoother: tightened pyramid test tolerances, misc updates
2 parents ccc5bf5 + d58147e commit 03e0ca1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/systems/variational_smoother_system.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ VariationalSmootherSystem::get_target_elem(const ElemType & type)
988988
// identified.
989989

990990
// Side length that preserves the volume of the reference element
991-
const auto side_length = std::pow(16. * ref_vol / 3., 1. / 3.);
991+
const auto side_length = std::cbrt(16. * ref_vol / 3.);
992992
// Prism height with the property that all faces have equal area
993993
const auto target_height = 0.25 * side_length * sqrt_3;
994994

@@ -1057,7 +1057,7 @@ VariationalSmootherSystem::get_target_elem(const ElemType & type)
10571057
// non-optimal reference element.
10581058

10591059
// Side length that preserves the volume of the reference element
1060-
const auto side_length = std::pow(3. * sqrt_2 * ref_vol, 1. / 3.);
1060+
const auto side_length = std::cbrt(3. * sqrt_2 * ref_vol);
10611061
// Pyramid height with the property that all faces are equilateral triangles
10621062
const auto target_height = side_length / sqrt_2;
10631063

tests/mesh/mesh_smoother_test.C

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,11 @@ public:
687687
std::unordered_map<dof_id_type, std::vector<const Elem *>> nodes_to_elem_map;
688688
MeshTools::build_nodes_to_elem_map(mesh, nodes_to_elem_map);
689689

690-
// Make sure we're not too distorted anymore
690+
// Make sure we're not too distorted anymore, using the given
691+
// tolerance.
691692
std::set<dof_id_type> nodes_checked;
693+
const Real tol = TOLERANCE;
694+
692695
for (const auto * elem : mesh.active_element_ptr_range())
693696
{
694697
for (const auto local_node_id : make_range(elem->n_nodes()))
@@ -717,10 +720,9 @@ public:
717720

718721
const auto & base = elem->node_ref(local_node_id - 9);
719722
const auto & apex = elem->node_ref(4);
720-
const Real x =
721-
(type == PYRAMID18) ? 0.566460 : 0.549876;
723+
const Real x = (type == PYRAMID18) ? 0.56646084 : 0.54985875;
722724

723-
CPPUNIT_ASSERT(node.relative_fuzzy_equals(base + x * (apex - base), 1e-3));
725+
CPPUNIT_ASSERT(node.absolute_fuzzy_equals(base + x * (apex - base), tol));
724726
continue;
725727
}
726728
else if (local_node_id > 13)
@@ -737,10 +739,9 @@ public:
737739
const auto & base2 = elem->node_ref((local_node_id - 13) % 4);
738740
const auto & apex = elem->node_ref(4);
739741

740-
const auto node_approx = (0.3141064847 * base1 +
741-
0.3141064847 * base2 +
742-
0.3717870306 * apex);
743-
CPPUNIT_ASSERT(node.relative_fuzzy_equals(node_approx, 1e-3));
742+
const auto node_approx =
743+
(0.31401599 * base1 + 0.31401599 * base2 + 0.37196802 * apex);
744+
CPPUNIT_ASSERT(node.absolute_fuzzy_equals(node_approx, tol));
744745
continue;
745746
}
746747
}
@@ -749,7 +750,6 @@ public:
749750
// smoothed to the actual midpoints.
750751
else if (type_is_tet && !elem->is_vertex(local_node_id))
751752
{
752-
const Real tol = TOLERANCE;
753753
// We have a non-vertex node. Determine what "type" of
754754
// midpoint node with respect to the mesh geometry.
755755
// First, get the nodes that neighbor this node
@@ -783,14 +783,14 @@ public:
783783
if (pointIsCubeFaceCenter(other, side_length))
784784
{
785785
const Real x = (type == TET10) ? 0.42895041 : 0.41486385;
786-
CPPUNIT_ASSERT(node.relative_fuzzy_equals(
786+
CPPUNIT_ASSERT(node.absolute_fuzzy_equals(
787787
other + x * (cube_center - other), tol));
788788
}
789789

790790
else if (pointIsCubeVertex(other, side_length))
791791
{
792792
const Real x = (type == TET10) ? 0.55388920 : 0.58093516;
793-
CPPUNIT_ASSERT(node.relative_fuzzy_equals(
793+
CPPUNIT_ASSERT(node.absolute_fuzzy_equals(
794794
other + x * (cube_center - other), tol));
795795
}
796796
}
@@ -826,7 +826,7 @@ public:
826826
const auto & cube_face_center =
827827
is_0_cube_face_center ? *neighbors[0] : *neighbors[1];
828828
const Real x = (type == TET10) ? 0.61299101 : 0.65125580;
829-
CPPUNIT_ASSERT(node.relative_fuzzy_equals(
829+
CPPUNIT_ASSERT(node.absolute_fuzzy_equals(
830830
cube_vertex + x * (cube_face_center - cube_vertex), tol));
831831
}
832832
}
@@ -934,7 +934,7 @@ public:
934934
else
935935
libmesh_error_msg("We should never get here!");
936936

937-
CPPUNIT_ASSERT(node.relative_fuzzy_equals(node_approx, tol));
937+
CPPUNIT_ASSERT(node.absolute_fuzzy_equals(node_approx, tol));
938938

939939
continue;
940940
break;

0 commit comments

Comments
 (0)