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>
61 std::size_t n_boundary_conds_expected)
79 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
84 CPPUNIT_ASSERT_EQUAL(n_boundary_conds_expected, boundary_info.
n_boundary_conds());
90 for (
const Elem * elem :
mesh.element_ptr_range())
92 CPPUNIT_ASSERT(!elem->is_flipped());
93 CPPUNIT_ASSERT(elem->has_affine_map());
94 for (
auto s : elem->side_index_range())
95 if (!elem->neighbor_ptr(s))
149 for (
const Elem * elem :
mesh.element_ptr_range())
152 CPPUNIT_ASSERT(poly !=
nullptr);
156 const std::size_t n_bcs_before =
161 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
162 CPPUNIT_ASSERT_EQUAL(n_bcs_before,
165 for (
const Elem * elem :
mesh.element_ptr_range())
176 constexpr unsigned int n_sides = 8;
180 std::unique_ptr<Elem> octagon = std::make_unique<C0Polygon>(n_sides);
181 for (
unsigned int i = 0; i < n_sides; ++i)
186 octagon->set_node(i, node);
189 Real poly_volume = octagon->volume();
194 for (
unsigned int s = 0; s < n_sides; ++s)
203 CPPUNIT_ASSERT_EQUAL(std::size_t(n_sides),
206 for (
const Elem * e :
mesh.element_ptr_range())
219 (
const std::vector<Point> & points,
220 const std::vector<std::vector<unsigned int>> & nodes_on_side)
227 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
230 const auto & nodes_on_s = nodes_on_side[s];
231 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
236 std::unique_ptr<Node> mid_elem_node;
237 std::unique_ptr<Elem> polyhedron =
238 std::make_unique<C0Polyhedron>(sides, mid_elem_node);
244 const auto * poly = cast_ptr<const C0Polyhedron *>(elem);
245 const dof_id_type n_elem_expected = poly->n_subelements();
249 for (
unsigned int s = 0; s < elem->
n_sides(); ++s)
254 std::size_t n_bcs_expected = 0;
255 for (
unsigned int s = 0; s < elem->
n_sides(); ++s)
256 n_bcs_expected += sides[s]->n_subtriangles();
259 std::vector<std::array<int, 4>> sub_elem_sides_to_parent_side(elem->
n_sub_elem());
261 sub_elem_sides_to_parent_side[
b] = poly->subelement_sides_to_poly_sides(
b);
263 Real poly_volume = poly->volume();
268 CPPUNIT_ASSERT_EQUAL(n_elem_expected,
mesh.
n_elem());
269 CPPUNIT_ASSERT_EQUAL(n_bcs_expected,
272 for (
const Elem * e :
mesh.element_ptr_range())
276 for (
const Elem * e :
mesh.element_ptr_range())
280 const auto side = sub_elem_sides_to_parent_side[e->id()][s];
296 const std::vector<Point> points =
297 { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0},
298 {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} };
300 const std::vector<std::vector<unsigned int>> nodes_on_side =
317 const std::vector<Point> points =
318 { { 0, -2, 0}, {-1, -1, 0}, {-1, 1, 0},
319 { 0, 2, 0}, { 1, 1, 0}, { 1, -1, 0},
320 { 0, -2, 1}, {-1, -1, 1}, {-1, 1, 1},
321 { 0, 2, 1}, { 1, 1, 1}, { 1, -1, 1} };
323 const std::vector<std::vector<unsigned int>> nodes_on_side =
324 { {0, 1, 2, 3, 4, 5},
331 {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 testAllTriQuadShell4()
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(testAllTriQuadShell4)
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...