1#include <libmesh/boundary_info.h>
2#include <libmesh/elem.h>
3#include <libmesh/enum_quadrature_type.h>
4#include <libmesh/fe_map.h>
5#include <libmesh/mesh.h>
6#include <libmesh/mesh_generation.h>
7#include <libmesh/mesh_modification.h>
8#include <libmesh/mesh_tools.h>
9#include <libmesh/quadrature.h>
43# ifdef LIBMESH_ENABLE_AMR
71# ifdef LIBMESH_ENABLE_AMR
98 dim > 0 ? 2 : 0,
dim > 1 ? 1 : 0,
dim > 2 ? 1 : 0,
109 std::vector<Real> orig_hmin(n_orig_elem), orig_hmax(n_orig_elem);
113 for (
auto & elem :
mesh.element_ptr_range())
115 orig_hmin[elem->id()] = elem->hmin();
116 orig_hmax[elem->id()] = elem->hmax();
121 CPPUNIT_ASSERT_EQUAL(n_orig_elem,
mesh.
n_elem());
126 for (
auto & elem :
mesh.element_ptr_range())
128 CPPUNIT_ASSERT_EQUAL(elem->mapping_type(),
130 CPPUNIT_ASSERT(elem->has_affine_map());
133 LIBMESH_ASSERT_FP_EQUAL(elem->volume(), orig_volume,
135 LIBMESH_ASSERT_FP_EQUAL(elem->hmax(), orig_hmax[elem->id()],
137 LIBMESH_ASSERT_FP_EQUAL(elem->hmin(), orig_hmin[elem->id()],
141 for (
auto & node :
mesh.node_ptr_range())
143 const Real w = node->get_extra_datum<
Real>(weight_index);
145 CPPUNIT_ASSERT_EQUAL(
Real(1), w);
160 n_refinements,
QUAD9);
163 interior_mesh.get_boundary_info().sync(boundary_mesh);
167 CPPUNIT_ASSERT_EQUAL(boundary_mesh.
n_elem(), n_edges);
168 CPPUNIT_ASSERT_EQUAL(boundary_mesh.
n_nodes(), n_edges*2);
170 for (
auto & node : boundary_mesh.node_ptr_range())
172 const Point p = *node;
173 LIBMESH_ASSERT_FP_EQUAL(p.
norm(),
radius, tol);
179 const Real max_lagrange_error =
180 radius * 5e-2 / (1 << (4*n_refinements));
182 circumference, max_lagrange_error);
186 for (
auto & elem : boundary_mesh.element_ptr_range())
194 constexpr int n_intervals = 4;
196 for (master_pt(0) = -1; master_pt(0) <= 1 +
TOLERANCE;
197 master_pt(0) +=
Real(2)/n_intervals)
200 LIBMESH_ASSERT_FP_EQUAL(
radius, p.
norm(), tol);
207 const Real max_rbb_error =
208 radius * 1e-3 / (1 << (6*n_refinements));
210 circumference, max_rbb_error);
223 n_refinements, type);
226 (5 << (n_refinements*2)) * (type ==
QUAD9 ? 1 : 2);
233 const Real max_lagrange_error =
234 radius * 5e-2 / (1 << (4*n_refinements));
237 area, max_lagrange_error);
241 for (
const Elem * elem :
mesh.element_ptr_range())
251 if (elem->neighbor_ptr(s))
254 constexpr int n_intervals = 4;
255 Point master_pt = elem->master_point(s);
257 (elem->master_point((s+1)%elem->n_sides()) - master_pt)
263 LIBMESH_ASSERT_FP_EQUAL(
radius, p.
norm(), tol);
272 const Real max_rbb_error =
273 radius * 2e-3 / (1 << (6*n_refinements));
275 area, max_rbb_error);
283 const Real height = 3;
292 n_refinements, side_type);
295 const unsigned int nz = 2;
300 (5 << (n_refinements*2)) * (side_type ==
QUAD9 ? 1 : 2) * nz;
307 const Real max_lagrange_error =
308 radius * 5e-2 / (1 << (4*n_refinements)) *
312 volume, max_lagrange_error);
316 std::unique_ptr<const Elem> elem_side;
317 constexpr int n_intervals = 4;
320 for (
const Elem * elem :
mesh.element_ptr_range())
330 if (elem->neighbor_ptr(s))
333 const Point side_normal =
334 elem->side_vertex_average_normal(s);
345 elem->build_side_ptr(elem_side, s);
346 qrule->init(*elem_side);
352 LIBMESH_ASSERT_FP_EQUAL(
radius, p.
norm(), tol);
360 const Real max_rbb_error =
361 radius * 2e-3 / (1 << (6*n_refinements)) *
364 volume, max_rbb_error);
380 n_refinements,
HEX27);
383 interior_mesh.get_boundary_info().sync(boundary_mesh);
385 const dof_id_type n_faces = 6 << (2*n_refinements);
387 CPPUNIT_ASSERT_EQUAL(boundary_mesh.
n_elem(), n_faces);
389 auto check_radii = [&boundary_mesh,
radius, type](
Real radius_tol) {
390 constexpr int n_intervals = 4;
392 Real max_radius_error = 0;
393 for (
auto & elem : boundary_mesh.element_ptr_range())
405 for (master_pt(0) = 0; master_pt(0) <= 1 +
TOLERANCE;
406 master_pt(0) +=
Real(1)/n_intervals)
408 for (master_pt(1) = 0; master_pt(1) <= 1 - master_pt(0) +
TOLERANCE;
409 master_pt(1) +=
Real(1)/n_intervals)
412 max_radius_error = std::max(max_radius_error, std::abs(
radius-p.
norm()));
418 libmesh_assert_equal_to(type,
QUAD9);
419 for (master_pt(0) = -1; master_pt(0) <= 1 +
TOLERANCE;
420 master_pt(0) +=
Real(2)/n_intervals)
422 for (master_pt(1) = -1; master_pt(1) <= 1 +
TOLERANCE;
423 master_pt(1) +=
Real(2)/n_intervals)
426 max_radius_error = std::max(max_radius_error, std::abs(
radius-p.
norm()));
430 LIBMESH_ASSERT_FP_EQUAL(max_radius_error, 0, radius_tol);
434 auto verify_equispaced_midnodes = [&boundary_mesh, type]()
436 std::unique_ptr<Elem> side_ptr;
437 for (
auto & elem : boundary_mesh.element_ptr_range())
444 for (
auto s : elem->side_index_range())
446 elem->build_side_ptr(side_ptr, s);
448 auto c02 = side_ptr->point(2) - side_ptr->point(0);
449 auto c12 = side_ptr->point(2) - side_ptr->point(1);
450 LIBMESH_ASSERT_FP_EQUAL
456 verify_equispaced_midnodes();
461 verify_equispaced_midnodes();
464 libmesh_assert_equal_to(type,
QUAD9);
468 for (
auto & node : boundary_mesh.node_ptr_range())
470 const Point p = *node;
471 LIBMESH_ASSERT_FP_EQUAL(p.
norm(),
radius, tol);
476 const Real max_lagrange_rad_error =
477 radius * 0.2 / (1 << (3*n_refinements));
478 check_radii(max_lagrange_rad_error);
483 const Real max_lagrange_vol_error =
486 surface_area, max_lagrange_vol_error);
492 for (
auto & elem : boundary_mesh.element_ptr_range())
498 const Point & p = elem->point(v);
499 LIBMESH_ASSERT_FP_EQUAL(p.
norm(),
radius, tol);
505 const Real max_rbb_rad_error =
506 radius * 0.2 / (1 << (3*n_refinements));
507 check_radii(max_rbb_rad_error);
510 const Real max_rbb_vol_error =
513 surface_area, max_rbb_vol_error);
CPPUNIT_TEST_SUITE_REGISTRATION(AllRBBTest)
CPPUNIT_TEST(testAllRBBTet10)
CPPUNIT_TEST(testAllRBBDisk5)
CPPUNIT_TEST(testAllRBBDisk80)
void testAllRBBTri6Disk40()
CPPUNIT_TEST(testAllRBBSphere6)
CPPUNIT_TEST(testAllRBBTri6Sphere192)
CPPUNIT_TEST(testAllRBBSphere96)
CPPUNIT_TEST(testAllRBBQuad)
CPPUNIT_TEST(testAllRBBTri6Disk160)
void testAllRBBTri6Sphere48()
void testAllRBBCircle16()
void test_sphere(unsigned int n_refinements, const ElemType type=QUAD9)
void test_cylinder(unsigned int n_refinements, const ElemType type=HEX27)
CPPUNIT_TEST(testAllRBBTet)
CPPUNIT_TEST(testAllRBBTri6Disk40)
CPPUNIT_TEST(testAllRBBTri)
void testAllRBBNodeElem()
CPPUNIT_TEST(testAllRBBNodeElem)
CPPUNIT_TEST(testAllRBBQuad9)
void test_box(ElemType elem_type)
CPPUNIT_TEST(testAllRBBTri6)
CPPUNIT_TEST(testAllRBBTri6Sphere48)
CPPUNIT_TEST(testAllRBBSphere24)
CPPUNIT_TEST(testAllRBBCircle16)
void testAllRBBSphere24()
void testAllRBBTri6Disk10()
CPPUNIT_TEST(testAllRBBQuad8)
CPPUNIT_TEST(testAllRBBHex)
CPPUNIT_TEST(testAllRBBTri6Disk10)
CPPUNIT_TEST(testAllRBBHex27)
CPPUNIT_TEST(testAllRBBDisk20)
CPPUNIT_TEST(testAllRBBCircle8)
void testAllRBBTri6Disk160()
void testAllRBBCylinder80()
void test_circle(unsigned int n_refinements)
void testAllRBBSphere96()
CPPUNIT_TEST(testAllRBBCylinder10)
CPPUNIT_TEST(testAllRBBEdge)
CPPUNIT_TEST(testAllRBBCylinder80)
void testAllRBBCylinder10()
void testAllRBBTri6Sphere12()
void test_disk(unsigned int n_refinements, const ElemType type=QUAD9)
CPPUNIT_TEST(testAllRBBEdge3)
CPPUNIT_TEST(testAllRBBHex20)
CPPUNIT_TEST(testAllRBBCircle4)
void testAllRBBTri6Sphere192()
CPPUNIT_TEST(testAllRBBTri6Sphere12)
LIBMESH_CPPUNIT_TEST_SUITE(AllRBBTest)
The goal of this test is to verify proper operation of the all_rbb() mesh modification,...
virtual dof_id_type n_nodes() const override final
virtual dof_id_type n_elem() const override final
This is the base class from which all geometric element types are derived.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
virtual dof_id_type n_elem() const =0
virtual dof_id_type max_elem_id() const =0
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A Point defines a location in LIBMESH_DIM dimensional Real space.
static std::unique_ptr< QBase > build(std::string_view name, const unsigned int dim, const Order order=INVALID_ORDER)
Builds a specific quadrature rule based on the name string.
Communicator * TestCommWorld
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
void libmesh_ignore(const Args &...)
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...