1#include <libmesh/libmesh.h>
2#include <libmesh/distributed_mesh.h>
3#include <libmesh/elem.h>
4#include <libmesh/mesh_generation.h>
5#include <libmesh/mesh_tools.h>
6#include <libmesh/replicated_mesh.h>
27# ifdef LIBMESH_ENABLE_AMR
42# ifdef LIBMESH_ENABLE_AMR
63#ifdef LIBMESH_ENABLE_EXCEPTIONS
68#ifdef LIBMESH_ENABLE_AMR
73# ifdef LIBMESH_ENABLE_AMR
81 std::unique_ptr<UnstructuredMesh>
new_mesh (
bool is_replicated)
96 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n));
101 CPPUNIT_ASSERT_EQUAL(bbox.
min()(0),
Real(-1.0));
102 CPPUNIT_ASSERT_EQUAL(bbox.
max()(0),
Real(2.0));
106 for (
auto & elem :
mesh.element_ptr_range())
107 CPPUNIT_ASSERT(elem->has_affine_map());
114 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n + 4 + 2 * (n - 1) + ((n - 1) / 2)));
116 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n));
118 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*2));
125 cast_int<dof_id_type>((n+1)*(n+1)));
130 cast_int<dof_id_type>((2*n+1)*(2*n+1)));
134 cast_int<dof_id_type>((2*n+1)*(2*n+1) - n*n));
138 cast_int<dof_id_type>((2*n+1)*(2*n+1) + 2*n*n));
142 cast_int<dof_id_type>(4 + 2*n*n + (n - 1) + 2*n + 2 * (n%2)));
145 CPPUNIT_ASSERT(
false);
151 CPPUNIT_ASSERT(bbox.
min()(0) <=
Real(-2.0));
152 CPPUNIT_ASSERT(bbox.
max()(0) >=
Real(3.0));
153 CPPUNIT_ASSERT(bbox.
min()(1) <=
Real(-4.0));
154 CPPUNIT_ASSERT(bbox.
max()(1) >=
Real(5.0));
159 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
min()(0),
162 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
max()(0),
165 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
min()(1),
168 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
max()(1),
176 for (
auto & elem :
mesh.element_ptr_range())
177 CPPUNIT_ASSERT(elem->has_affine_map());
182 MeshTools::Generation::build_cube (
mesh, n, n, n, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, type);
185 const dof_id_type grid_nodes = cast_int<dof_id_type>((n+1)*(n+1)*(n+1));
187 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n));
189 CPPUNIT_ASSERT(
mesh.
n_nodes() <= grid_nodes + cast_int<dof_id_type>(n*n*n));
196 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*24));
201 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*2));
203 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*6));
206 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n));
217 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n + 3*(n+1)*n*n));
222 cast_int<dof_id_type>((n+1)*(n+1)*(n+1)));
226 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n));
231 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1)));
236 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 3*(n+1)*n*n));
239 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(n+1)*n*n));
243 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(2*n+1)*n*n));
247 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 2*(n+1)*n*n));
251 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n));
255 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n - 3*(n+1)*n*n));
260 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n));
263 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n +
264 36*n*n*n + 4*3*(n+1)*n*n));
274 CPPUNIT_ASSERT(bbox.
min()(0) <=
Real(-2.0));
275 CPPUNIT_ASSERT(bbox.
max()(0) >=
Real(3.0));
276 CPPUNIT_ASSERT(bbox.
min()(1) <=
Real(-4.0));
277 CPPUNIT_ASSERT(bbox.
max()(1) >=
Real(5.0));
278 CPPUNIT_ASSERT(bbox.
min()(2) <=
Real(-6.0));
279 CPPUNIT_ASSERT(bbox.
max()(2) >=
Real(7.0));
286 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
min()(0),
289 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
max()(0),
292 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
min()(1),
295 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
max()(1),
298 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
min()(2),
301 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.
max()(2),
308 for (
auto & elem :
mesh.element_ptr_range())
311 CPPUNIT_ASSERT_EQUAL(elem->n_sides(), 6u);
312 CPPUNIT_ASSERT(elem->n_sub_elem() > 0);
313 CPPUNIT_ASSERT(elem->volume() > 0);
327 for (
auto & elem :
mesh.element_ptr_range())
328 CPPUNIT_ASSERT(elem->has_affine_map());
346 for (
int is_replicated = 0; is_replicated != 2; ++is_replicated)
348 for (
int skip_renumber = 0 ; skip_renumber != 2; ++skip_renumber)
350 std::unique_ptr<UnstructuredMesh>
mesh =
353 (this->*f)(*
mesh, n, type);
394#ifdef LIBMESH_ENABLE_EXCEPTIONS
void ErrorVector unsigned int
CPPUNIT_TEST(buildSquareQuad9)
CPPUNIT_TEST(buildLineEdge2)
std::unique_ptr< UnstructuredMesh > new_mesh(bool is_replicated)
void testBuildLine(UnstructuredMesh &mesh, unsigned int n, ElemType type)
CPPUNIT_TEST(buildLineEdge3)
LIBMESH_CPPUNIT_TEST_SUITE(MeshGenerationTest)
The goal of this test is to verify proper operation of MeshGeneration functions, as well as to indire...
CPPUNIT_TEST(buildCubePrism6)
CPPUNIT_TEST(buildCubePyramid13)
CPPUNIT_TEST(buildCubeTet4)
CPPUNIT_TEST(buildCubePrism18)
void testBuildSphere(unsigned int n_ref, ElemType type)
CPPUNIT_TEST(buildCubeHex20)
void buildCubeC0Polyhedron()
CPPUNIT_TEST(buildCubePrism15)
CPPUNIT_TEST(buildSphereEdge3)
CPPUNIT_TEST(buildCubeC0Polyhedron)
CPPUNIT_TEST(buildSphereEdge2)
CPPUNIT_TEST(buildLineEdge4)
void testBuildCube(UnstructuredMesh &mesh, unsigned int n, ElemType type)
CPPUNIT_TEST(buildCubeHex8)
CPPUNIT_TEST(buildSquareTri6)
CPPUNIT_TEST(buildSphereHex8)
CPPUNIT_TEST(buildSquareC0PolygonEven)
CPPUNIT_TEST(buildSquareTri3)
CPPUNIT_TEST(buildSquareQuad8)
void buildCubePyramid14()
CPPUNIT_TEST(buildCubeHex27)
CPPUNIT_TEST(buildSphereTri3)
void buildCubePyramid13()
CPPUNIT_TEST(buildCubeTet14)
void testBuildSquare(UnstructuredMesh &mesh, unsigned int n, ElemType type)
void tester(Builder f, unsigned int n, ElemType type)
CPPUNIT_TEST(buildCubePrism21)
void buildSquareC0PolygonOdd()
CPPUNIT_TEST(buildSphereQuad4)
CPPUNIT_TEST(buildCubePyramid5)
void buildSquareC0PolygonEven()
CPPUNIT_TEST(buildSquareTri7)
CPPUNIT_TEST(buildCubePyramid14)
CPPUNIT_TEST(buildCubePrism20)
CPPUNIT_TEST(buildCubeTet10)
CPPUNIT_TEST(buildSquareC0PolygonOdd)
CPPUNIT_TEST(buildSphereHex27)
CPPUNIT_TEST(buildSquareQuad4)
void(MeshGenerationTest::* Builder)(UnstructuredMesh &, unsigned int, ElemType)
Defines a Cartesian bounding box by the two corner extremum.
const Point & max() const
const Point & min() const
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
static const unsigned int type_to_n_nodes_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of nodes in the element...
static const unsigned int type_to_n_sides_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of sides on the element...
virtual dof_id_type n_elem() const =0
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
virtual dof_id_type n_nodes() const =0
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
The UnstructuredMesh class is derived from the MeshBase class.
Communicator * TestCommWorld
CPPUNIT_TEST_SUITE_REGISTRATION(MeshGenerationTest)
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real