1 #include <libmesh/libmesh.h> 2 #include <libmesh/replicated_mesh.h> 3 #include <libmesh/elem.h> 4 #include <libmesh/cell_c0polyhedron.h> 5 #include <libmesh/cell_polyhedron.h> 6 #include <libmesh/face_c0polygon.h> 7 #include <libmesh/face_polygon.h> 8 #include <libmesh/mesh_generation.h> 9 #include <libmesh/mesh_modification.h> 10 #include <libmesh/mesh_tools.h> 11 #include <libmesh/boundary_info.h> 34 CPPUNIT_TEST( testAllTriTri );
35 CPPUNIT_TEST( testAllTriQuad );
36 CPPUNIT_TEST( testAllTriQuad8 );
37 CPPUNIT_TEST( testAllTriQuad9 );
38 CPPUNIT_TEST( testAllTriC0Polygon );
39 CPPUNIT_TEST( testAllTriC0PolygonOctagon );
44 CPPUNIT_TEST( testAllTriPrism6 );
45 CPPUNIT_TEST( testAllTriPrism18 );
46 CPPUNIT_TEST( testAllTriPrism20 );
47 CPPUNIT_TEST( testAllTriPrism21 );
48 CPPUNIT_TEST( testAllTriC0PolyhedronCube );
49 CPPUNIT_TEST( testAllTriC0PolyhedronHexagonalPrism );
52 CPPUNIT_TEST_SUITE_END();
58 std::size_t n_boundary_conds_expected)
73 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
82 std::size_t n_boundary_conds_expected)
98 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
145 for (
const Elem * elem :
mesh.element_ptr_range())
148 CPPUNIT_ASSERT(poly !=
nullptr);
152 const std::size_t n_bcs_before =
157 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
158 CPPUNIT_ASSERT_EQUAL(n_bcs_before,
161 for (
const Elem * elem :
mesh.element_ptr_range())
172 constexpr
unsigned int n_sides = 8;
176 std::unique_ptr<Elem> octagon = std::make_unique<C0Polygon>(n_sides);
177 for (
unsigned int i = 0; i < n_sides; ++i)
182 octagon->set_node(i, node);
185 Real poly_volume = octagon->volume();
190 for (
unsigned int s = 0; s < n_sides; ++s)
199 CPPUNIT_ASSERT_EQUAL(std::size_t(n_sides),
202 for (
const Elem * e :
mesh.element_ptr_range())
214 void test_helper_c0polyhedron
215 (
const std::vector<Point> & points,
216 const std::vector<std::vector<unsigned int>> & nodes_on_side)
223 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
226 const auto & nodes_on_s = nodes_on_side[s];
227 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
232 std::unique_ptr<Node> mid_elem_node;
233 std::unique_ptr<Elem> polyhedron =
234 std::make_unique<C0Polyhedron>(sides, mid_elem_node);
240 const auto * poly = cast_ptr<const C0Polyhedron *>(elem);
241 const dof_id_type n_elem_expected = poly->n_subelements();
245 for (
unsigned int s = 0; s < elem->
n_sides(); ++s)
250 std::size_t n_bcs_expected = 0;
251 for (
unsigned int s = 0; s < elem->
n_sides(); ++s)
252 n_bcs_expected += sides[s]->n_subtriangles();
255 std::vector<std::array<int, 4>> sub_elem_sides_to_parent_side(elem->
n_sub_elem());
257 sub_elem_sides_to_parent_side[
b] = poly->subelement_sides_to_poly_sides(
b);
259 Real poly_volume = poly->volume();
264 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
265 CPPUNIT_ASSERT_EQUAL(n_bcs_expected,
268 for (
const Elem * e :
mesh.element_ptr_range())
272 for (
const Elem * e :
mesh.element_ptr_range())
276 const auto side = sub_elem_sides_to_parent_side[e->id()][s];
292 const std::vector<Point> points =
293 { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0},
294 {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} };
296 const std::vector<std::vector<unsigned int>> nodes_on_side =
304 test_helper_c0polyhedron(points, nodes_on_side);
313 const std::vector<Point> points =
314 { { 0, -2, 0}, {-1, -1, 0}, {-1, 1, 0},
315 { 0, 2, 0}, { 1, 1, 0}, { 1, -1, 0},
316 { 0, -2, 1}, {-1, -1, 1}, {-1, 1, 1},
317 { 0, 2, 1}, { 1, 1, 1}, { 1, -1, 1} };
319 const std::vector<std::vector<unsigned int>> nodes_on_side =
320 { {0, 1, 2, 3, 4, 5},
327 {6, 7, 8, 9, 10, 11} };
329 test_helper_c0polyhedron(points, nodes_on_side);
std::size_t n_boundary_conds() const
ElemType
Defines an enum for geometric element types.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
A Node is like a Point, but with more information.
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
unsigned int n_subtriangles() const
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
This is the base class from which all geometric element types are derived.
void testAllTriC0Polygon()
The libMesh namespace provides an interface to certain functionality in the library.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
const int invalid_int
A number which is used quite often to represent an invalid or uninitialized value for an integer...
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
The Polygon is an element in 2D with an arbitrary (but fixed) number of sides.
void testAllTriC0PolygonOctagon()
void testAllTriC0PolyhedronHexagonalPrism()
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
void test_helper_3D(ElemType elem_type, dof_id_type n_elem_expected, std::size_t n_boundary_conds_expected)
virtual unsigned int n_sides() const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
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...
void test_helper_2D(ElemType elem_type, dof_id_type n_elem_expected, std::size_t n_boundary_conds_expected)
CPPUNIT_TEST_SUITE_REGISTRATION(AllTriTest)
virtual unsigned int n_sub_elem() const =0
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
void testAllTriC0PolyhedronCube()