libMesh
Loading...
Searching...
No Matches
simplex_refinement_test.C
Go to the documentation of this file.
1#include <libmesh/boundary_info.h>
2#include <libmesh/elem.h>
3#include <libmesh/mesh.h>
4#include <libmesh/mesh_generation.h>
5#include <libmesh/mesh_tools.h>
6#include <libmesh/parallel_implementation.h> // max()
7#include <libmesh/simplex_refiner.h>
8
9#include "test_comm.h"
10#include "libmesh_cppunit.h"
11
12#include <cmath>
13
14
15using namespace libMesh;
16
17
18class SimplexRefinementTest : public CppUnit::TestCase
19{
24public:
26
29
31
32public:
33 void setUp() {}
34
35 void tearDown() {}
36
38 Real desired_measure,
39 Real expected_total_measure)
40 {
41 SimplexRefiner simplex_refiner(mesh);
42 simplex_refiner.desired_volume() = desired_measure;
43
44 simplex_refiner.refine_elements();
45
46 Real total_measure = 0;
47 for (const Elem * elem : mesh.local_element_ptr_range())
48 {
49 Real measure = elem->volume();
50 CPPUNIT_ASSERT_LESSEQUAL(desired_measure, measure);
51 total_measure += measure;
52 }
53
54 TestCommWorld->sum(total_measure);
55 LIBMESH_ASSERT_FP_EQUAL(total_measure, expected_total_measure,
57 }
58
59
61 {
62 LOG_UNIT_TEST;
63
64 Mesh trimesh(*TestCommWorld);
65
67 0.0, 2.0, 0.0, 2.0, TRI3);
68
69 testRefinement(trimesh, 0.05, 4);
70 }
71
72
74 {
75 // We may have a bug when trying to edge refine on more processors
76 // than elements? I can't reproduce it and it seems intermittent
77 // in CI.
78 if (TestCommWorld->size() > 8)
79 return;
80
81 LOG_UNIT_TEST;
82
83 Mesh trimesh(*TestCommWorld);
84
86 (trimesh, -1, 1, -1, 1, -1, 1);
87
88 testRefinement(trimesh, 0.05, 4*std::sqrt(Real(3)));
89 }
90};
91
92
LIBMESH_CPPUNIT_TEST_SUITE(SimplexRefinementTest)
The goal of this test is to verify proper operation of the interfaces to tetrahedralization libraries...
CPPUNIT_TEST(testTriRefinement)
void testRefinement(UnstructuredMesh &mesh, Real desired_measure, Real expected_total_measure)
CPPUNIT_TEST(test3DTriRefinement)
This is the base class from which all geometric element types are derived.
Definition elem.h:96
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
A C++ class to refine a simplicial mesh via splitting edges that exceed a given metric.
bool refine_elements()
Finds elements which exceed the requested metric and refines them via subdivision into new simplices ...
Real & desired_volume()
Sets and/or gets the desired element volume.
The UnstructuredMesh class is derived from the MeshBase class.
Communicator * TestCommWorld
MeshBase & mesh
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
void surface_octahedron(UnstructuredMesh &mesh, Real xmin, Real xmax, Real ymin, Real ymax, Real zmin, Real zmax, bool flip_tris=false)
Meshes the surface of an octahedron with 8 Tri3 elements, with counter-clockwise (libMesh default) no...
The libMesh namespace provides an interface to certain functionality in the library.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CPPUNIT_TEST_SUITE_REGISTRATION(SimplexRefinementTest)