Skip to content

Commit 5547078

Browse files
authored
Merge pull request #4220 from pbehne/variational_smoother_enum_cleanup
VariationalMeshSmoother: Refactored element type check to use string comparison
2 parents 231f9e6 + 8de09d9 commit 5547078

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/systems/variational_smoother_system.C

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "libmesh/quadrature.h"
3030
#include "libmesh/string_to_enum.h"
3131
#include "libmesh/utility.h"
32+
#include "libmesh/enum_to_string.h"
3233

3334
// C++ includes
3435
#include <functional> // std::reference_wrapper
@@ -139,8 +140,10 @@ void VariationalSmootherSystem::prepare_for_smoothing()
139140
target_elem_inverse_jacobian_dets[elem->type()] =
140141
std::vector<Real>(nq_points, 1.0);
141142

143+
const auto type_str = Utility::enum_to_string(elem->type());
144+
142145
// Elems deriving from Tri
143-
if (elem->type() == TRI3 || elem->type() == TRI6)
146+
if (type_str.compare(0, 3, "TRI") == 0)
144147
{
145148

146149
// The target element will be an equilateral triangle with area equal to
@@ -180,7 +183,7 @@ void VariationalSmootherSystem::prepare_for_smoothing()
180183
}
181184

182185
default:
183-
libmesh_error_msg("Unsupported triangular element!");
186+
libmesh_error_msg("Unsupported triangular element: " << type_str);
184187
break;
185188
}
186189

tests/mesh/mesh_smoother_test.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <libmesh/system.h> // LIBMESH_HAVE_SOLVER define
1515
#include "libmesh/face_tri.h"
1616
#include "libmesh/utility.h"
17+
#include "libmesh/enum_to_string.h"
1718

1819
#include "test_comm.h"
1920
#include "libmesh_cppunit.h"
@@ -283,7 +284,7 @@ public:
283284
// Get mesh dimension, determine whether type is triangular
284285
const auto * ref_elem = &(ReferenceElem::get(type));
285286
const auto dim = ref_elem->dim();
286-
const bool type_is_tri = dynamic_cast<const Tri*>(ref_elem);
287+
const bool type_is_tri = Utility::enum_to_string(type).compare(0, 3, "TRI") == 0;
287288

288289
unsigned int n_elems_per_side = 5;
289290

0 commit comments

Comments
 (0)