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> 24 CPPUNIT_TEST( buildLineEdge2 );
25 CPPUNIT_TEST( buildLineEdge3 );
26 CPPUNIT_TEST( buildLineEdge4 );
27 # ifdef LIBMESH_ENABLE_AMR 28 CPPUNIT_TEST( buildSphereEdge2 );
29 CPPUNIT_TEST( buildSphereEdge3 );
34 CPPUNIT_TEST( buildSquareTri3 );
35 CPPUNIT_TEST( buildSquareTri6 );
36 CPPUNIT_TEST( buildSquareTri7 );
37 CPPUNIT_TEST( buildSquareQuad4 );
38 CPPUNIT_TEST( buildSquareQuad8 );
39 CPPUNIT_TEST( buildSquareQuad9 );
40 CPPUNIT_TEST( buildSquareC0PolygonEven );
41 CPPUNIT_TEST( buildSquareC0PolygonOdd );
42 # ifdef LIBMESH_ENABLE_AMR 43 CPPUNIT_TEST( buildSphereTri3 );
44 CPPUNIT_TEST( buildSphereQuad4 );
48 CPPUNIT_TEST( buildCubeTet4 );
49 CPPUNIT_TEST( buildCubeTet10 );
50 CPPUNIT_TEST( buildCubeTet14 );
51 CPPUNIT_TEST( buildCubeHex8 );
52 CPPUNIT_TEST( buildCubeHex20 );
53 CPPUNIT_TEST( buildCubeHex27 );
54 CPPUNIT_TEST( buildCubePrism6 );
55 CPPUNIT_TEST( buildCubePrism15 );
56 CPPUNIT_TEST( buildCubePrism18 );
57 CPPUNIT_TEST( buildCubePrism20 );
58 CPPUNIT_TEST( buildCubePrism21 );
62 #ifdef LIBMESH_ENABLE_EXCEPTIONS 63 CPPUNIT_TEST( buildCubePyramid5 );
64 CPPUNIT_TEST( buildCubePyramid13 );
65 CPPUNIT_TEST( buildCubePyramid14 );
67 #ifdef LIBMESH_ENABLE_AMR 68 CPPUNIT_TEST( buildSphereHex27 );
72 # ifdef LIBMESH_ENABLE_AMR 73 CPPUNIT_TEST( buildSphereHex8 );
77 CPPUNIT_TEST_SUITE_END();
80 std::unique_ptr<UnstructuredMesh>
new_mesh (
bool is_replicated)
83 return std::make_unique<ReplicatedMesh>(*TestCommWorld);
84 return std::make_unique<DistributedMesh>(*TestCommWorld);
95 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n));
100 CPPUNIT_ASSERT_EQUAL(bbox.min()(0),
Real(-1.0));
101 CPPUNIT_ASSERT_EQUAL(bbox.max()(0),
Real(2.0));
105 for (
auto & elem :
mesh.element_ptr_range())
106 CPPUNIT_ASSERT(elem->has_affine_map());
113 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n + 4 + 2 * (n - 1) + ((n - 1) / 2)));
115 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n));
117 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*2));
124 cast_int<dof_id_type>((n+1)*(n+1)));
129 cast_int<dof_id_type>((2*n+1)*(2*n+1)));
133 cast_int<dof_id_type>((2*n+1)*(2*n+1) - n*n));
137 cast_int<dof_id_type>((2*n+1)*(2*n+1) + 2*n*n));
141 cast_int<dof_id_type>(4 + 2*n*n + (n - 1) + 2*n + 2 * (n%2)));
144 CPPUNIT_ASSERT(
false);
150 CPPUNIT_ASSERT(bbox.
min()(0) <=
Real(-2.0));
151 CPPUNIT_ASSERT(bbox.
max()(0) >=
Real(3.0));
152 CPPUNIT_ASSERT(bbox.
min()(1) <=
Real(-4.0));
153 CPPUNIT_ASSERT(bbox.
max()(1) >=
Real(5.0));
158 for (
auto & elem :
mesh.element_ptr_range())
159 CPPUNIT_ASSERT(elem->has_affine_map());
164 MeshTools::Generation::build_cube (
mesh, n, n, n, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, type);
168 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*24));
173 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*2));
175 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*6));
178 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n));
189 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n + 3*(n+1)*n*n));
194 cast_int<dof_id_type>((n+1)*(n+1)*(n+1)));
198 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n));
203 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1)));
208 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 3*(n+1)*n*n));
211 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(n+1)*n*n));
215 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(2*n+1)*n*n));
219 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 2*(n+1)*n*n));
223 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n));
227 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n - 3*(n+1)*n*n));
232 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n));
235 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n +
236 36*n*n*n + 4*3*(n+1)*n*n));
245 CPPUNIT_ASSERT(bbox.
min()(0) <=
Real(-2.0));
246 CPPUNIT_ASSERT(bbox.
max()(0) >=
Real(3.0));
247 CPPUNIT_ASSERT(bbox.
min()(1) <=
Real(-4.0));
248 CPPUNIT_ASSERT(bbox.
max()(1) >=
Real(5.0));
249 CPPUNIT_ASSERT(bbox.
min()(2) <=
Real(-6.0));
250 CPPUNIT_ASSERT(bbox.
max()(2) >=
Real(7.0));
260 for (
auto & elem :
mesh.element_ptr_range())
261 CPPUNIT_ASSERT(elem->has_affine_map());
279 for (
int is_replicated = 0; is_replicated != 2; ++is_replicated)
281 for (
int skip_renumber = 0 ; skip_renumber != 2; ++skip_renumber)
283 std::unique_ptr<UnstructuredMesh>
mesh =
284 new_mesh(is_replicated);
286 (this->*f)(*
mesh, n, type);
325 #ifdef LIBMESH_ENABLE_EXCEPTIONS
ElemType
Defines an enum for geometric element types.
void testBuildLine(UnstructuredMesh &mesh, unsigned int n, ElemType type)
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
void testBuildCube(UnstructuredMesh &mesh, unsigned int n, ElemType type)
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...
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
libMesh::Parallel::Communicator * TestCommWorld
void buildCubePyramid14()
The libMesh namespace provides an interface to certain functionality in the library.
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...
std::unique_ptr< UnstructuredMesh > new_mesh(bool is_replicated)
void testBuildSquare(UnstructuredMesh &mesh, unsigned int n, ElemType type)
void buildSquareC0PolygonOdd()
The UnstructuredMesh class is derived from the MeshBase class.
const Point & min() const
CPPUNIT_TEST_SUITE_REGISTRATION(MeshGenerationTest)
void buildSquareC0PolygonEven()
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
Defines a Cartesian bounding box by the two corner extremum.
void tester(Builder f, unsigned int n, ElemType type)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void buildCubePyramid13()
void tester(const std::set< int > &s, int i)
const Point & max() const
virtual dof_id_type n_elem() const =0
void ErrorVector unsigned int
virtual dof_id_type n_nodes() const =0
void testBuildSphere(unsigned int n_ref, ElemType type)