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>
60 std::size_t n_boundary_conds_expected)
78 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
83 CPPUNIT_ASSERT_EQUAL(n_boundary_conds_expected, boundary_info.
n_boundary_conds());
89 for (
const Elem * elem :
mesh.element_ptr_range())
91 CPPUNIT_ASSERT(!elem->is_flipped());
92 CPPUNIT_ASSERT(elem->has_affine_map());
93 for (
auto s : elem->side_index_range())
94 if (!elem->neighbor_ptr(s))
147 for (
const Elem * elem :
mesh.element_ptr_range())
150 CPPUNIT_ASSERT(poly !=
nullptr);
154 const std::size_t n_bcs_before =
159 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
160 CPPUNIT_ASSERT_EQUAL(n_bcs_before,
163 for (
const Elem * elem :
mesh.element_ptr_range())
174 constexpr unsigned int n_sides = 8;
178 std::unique_ptr<Elem> octagon = std::make_unique<C0Polygon>(n_sides);
179 for (
unsigned int i = 0; i < n_sides; ++i)
184 octagon->set_node(i, node);
187 Real poly_volume = octagon->volume();
192 for (
unsigned int s = 0; s < n_sides; ++s)
201 CPPUNIT_ASSERT_EQUAL(std::size_t(n_sides),
204 for (
const Elem * e :
mesh.element_ptr_range())
217 (
const std::vector<Point> & points,
218 const std::vector<std::vector<unsigned int>> & nodes_on_side)
225 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
228 const auto & nodes_on_s = nodes_on_side[s];
229 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
234 std::unique_ptr<Node> mid_elem_node;
235 std::unique_ptr<Elem> polyhedron =
236 std::make_unique<C0Polyhedron>(sides, mid_elem_node);
242 const auto * poly = cast_ptr<const C0Polyhedron *>(elem);
243 const dof_id_type n_elem_expected = poly->n_subelements();
247 for (
unsigned int s = 0; s < elem->
n_sides(); ++s)
252 std::size_t n_bcs_expected = 0;
253 for (
unsigned int s = 0; s < elem->
n_sides(); ++s)
254 n_bcs_expected += sides[s]->n_subtriangles();
257 std::vector<std::array<int, 4>> sub_elem_sides_to_parent_side(elem->
n_sub_elem());
259 sub_elem_sides_to_parent_side[
b] = poly->subelement_sides_to_poly_sides(
b);
261 Real poly_volume = poly->volume();
266 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
267 CPPUNIT_ASSERT_EQUAL(n_bcs_expected,
270 for (
const Elem * e :
mesh.element_ptr_range())
274 for (
const Elem * e :
mesh.element_ptr_range())
278 const auto side = sub_elem_sides_to_parent_side[e->id()][s];
294 const std::vector<Point> points =
295 { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0},
296 {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} };
298 const std::vector<std::vector<unsigned int>> nodes_on_side =
315 const std::vector<Point> points =
316 { { 0, -2, 0}, {-1, -1, 0}, {-1, 1, 0},
317 { 0, 2, 0}, { 1, 1, 0}, { 1, -1, 0},
318 { 0, -2, 1}, {-1, -1, 1}, {-1, 1, 1},
319 { 0, 2, 1}, { 1, 1, 1}, { 1, -1, 1} };
321 const std::vector<std::vector<unsigned int>> nodes_on_side =
322 { {0, 1, 2, 3, 4, 5},
329 {6, 7, 8, 9, 10, 11} };
CPPUNIT_TEST_SUITE_REGISTRATION(AllTriTest)
void testAllTriPyramid5()
CPPUNIT_TEST(testAllTriPrism21)
CPPUNIT_TEST(testAllTriC0PolyhedronHexagonalPrism)
CPPUNIT_TEST(testAllTriPyramid14)
CPPUNIT_TEST(testAllTriPrism20)
LIBMESH_CPPUNIT_TEST_SUITE(AllTriTest)
The goal of this test is to verify proper operation of the Mesh Extruder with the optional object cal...
CPPUNIT_TEST(testAllTriQuad8)
void test_helper_c0polyhedron(const std::vector< Point > &points, const std::vector< std::vector< unsigned int > > &nodes_on_side)
CPPUNIT_TEST(testAllTriC0Polygon)
CPPUNIT_TEST(testAllTriC0PolyhedronCube)
void testAllTriC0PolygonOctagon()
void testAllTriC0Polygon()
CPPUNIT_TEST(testAllTriQuad9)
CPPUNIT_TEST(testAllTriC0PolygonOctagon)
void testAllTriPyramid14()
CPPUNIT_TEST(testAllTriPrism6)
CPPUNIT_TEST(testAllTriTri)
void testAllTriC0PolyhedronHexagonalPrism()
void test_helper(ElemType elem_type, dof_id_type n_elem_expected, std::size_t n_boundary_conds_expected)
CPPUNIT_TEST(testAllTriPyramid5)
CPPUNIT_TEST(testAllTriQuad)
CPPUNIT_TEST(testAllTriPrism18)
void testAllTriC0PolyhedronCube()
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
std::size_t n_boundary_ids() const
std::size_t n_boundary_conds() const
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
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.
This is the base class from which all geometric element types are derived.
virtual unsigned int n_sub_elem() const =0
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
virtual unsigned int n_sides() const =0
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
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.
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.
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
A Node is like a Point, but with more information.
A Point defines a location in LIBMESH_DIM dimensional Real space.
The Polygon is an element in 2D with an arbitrary (but fixed) number of sides.
unsigned int n_subtriangles() const
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Communicator * TestCommWorld
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
ElemType
Defines an enum for geometric element types.
const int invalid_int
A number which is used quite often to represent an invalid or uninitialized value for an integer.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...