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 # ifdef LIBMESH_ENABLE_AMR 41 CPPUNIT_TEST( buildSphereTri3 );
42 CPPUNIT_TEST( buildSphereQuad4 );
46 CPPUNIT_TEST( buildCubeTet4 );
47 CPPUNIT_TEST( buildCubeTet10 );
48 CPPUNIT_TEST( buildCubeTet14 );
49 CPPUNIT_TEST( buildCubeHex8 );
50 CPPUNIT_TEST( buildCubeHex20 );
51 CPPUNIT_TEST( buildCubeHex27 );
52 CPPUNIT_TEST( buildCubePrism6 );
53 CPPUNIT_TEST( buildCubePrism15 );
54 CPPUNIT_TEST( buildCubePrism18 );
55 CPPUNIT_TEST( buildCubePrism20 );
56 CPPUNIT_TEST( buildCubePrism21 );
60 #ifdef LIBMESH_ENABLE_EXCEPTIONS 61 CPPUNIT_TEST( buildCubePyramid5 );
62 CPPUNIT_TEST( buildCubePyramid13 );
63 CPPUNIT_TEST( buildCubePyramid14 );
65 #ifdef LIBMESH_ENABLE_AMR 66 CPPUNIT_TEST( buildSphereHex27 );
70 # ifdef LIBMESH_ENABLE_AMR 71 CPPUNIT_TEST( buildSphereHex8 );
75 CPPUNIT_TEST_SUITE_END();
78 std::unique_ptr<UnstructuredMesh>
new_mesh (
bool is_replicated)
81 return std::make_unique<ReplicatedMesh>(*TestCommWorld);
82 return std::make_unique<DistributedMesh>(*TestCommWorld);
93 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n));
98 CPPUNIT_ASSERT_EQUAL(bbox.min()(0),
Real(-1.0));
99 CPPUNIT_ASSERT_EQUAL(bbox.max()(0),
Real(2.0));
103 for (
auto & elem :
mesh.element_ptr_range())
104 CPPUNIT_ASSERT(elem->has_affine_map());
111 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n));
113 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*2));
120 cast_int<dof_id_type>((n+1)*(n+1)));
125 cast_int<dof_id_type>((2*n+1)*(2*n+1)));
129 cast_int<dof_id_type>((2*n+1)*(2*n+1) - n*n));
133 cast_int<dof_id_type>((2*n+1)*(2*n+1) + 2*n*n));
136 CPPUNIT_ASSERT(
false);
142 CPPUNIT_ASSERT(bbox.
min()(0) <=
Real(-2.0));
143 CPPUNIT_ASSERT(bbox.
max()(0) >=
Real(3.0));
144 CPPUNIT_ASSERT(bbox.
min()(1) <=
Real(-4.0));
145 CPPUNIT_ASSERT(bbox.
max()(1) >=
Real(5.0));
149 for (
auto & elem :
mesh.element_ptr_range())
150 CPPUNIT_ASSERT(elem->has_affine_map());
155 MeshTools::Generation::build_cube (
mesh, n, n, n, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, type);
159 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*24));
164 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*2));
166 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n*6));
169 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), cast_int<dof_id_type>(n*n*n));
180 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n + 3*(n+1)*n*n));
185 cast_int<dof_id_type>((n+1)*(n+1)*(n+1)));
189 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n));
194 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1)));
199 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 3*(n+1)*n*n));
202 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(n+1)*n*n));
206 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(2*n+1)*n*n));
210 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 2*(n+1)*n*n));
214 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n));
218 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n - 3*(n+1)*n*n));
223 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n));
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 +
227 36*n*n*n + 4*3*(n+1)*n*n));
236 CPPUNIT_ASSERT(bbox.
min()(0) <=
Real(-2.0));
237 CPPUNIT_ASSERT(bbox.
max()(0) >=
Real(3.0));
238 CPPUNIT_ASSERT(bbox.
min()(1) <=
Real(-4.0));
239 CPPUNIT_ASSERT(bbox.
max()(1) >=
Real(5.0));
240 CPPUNIT_ASSERT(bbox.
min()(2) <=
Real(-6.0));
241 CPPUNIT_ASSERT(bbox.
max()(2) >=
Real(7.0));
251 for (
auto & elem :
mesh.element_ptr_range())
252 CPPUNIT_ASSERT(elem->has_affine_map());
270 for (
int is_replicated = 0; is_replicated != 2; ++is_replicated)
272 for (
int skip_renumber = 0 ; skip_renumber != 2; ++skip_renumber)
274 std::unique_ptr<UnstructuredMesh>
mesh =
275 new_mesh(is_replicated);
277 (this->*f)(*
mesh, n, type);
314 #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)
The UnstructuredMesh class is derived from the MeshBase class.
const Point & min() const
CPPUNIT_TEST_SUITE_REGISTRATION(MeshGenerationTest)
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)