2 #include <libmesh/cell_c0polyhedron.h> 3 #include <libmesh/elem.h> 4 #include <libmesh/enum_elem_type.h> 5 #include <libmesh/face_c0polygon.h> 6 #include <libmesh/mesh_generation.h> 7 #include <libmesh/mesh_modification.h> 8 #include <libmesh/mesh.h> 9 #include <libmesh/reference_elem.h> 10 #include <libmesh/replicated_mesh.h> 11 #include <libmesh/node.h> 12 #include <libmesh/enum_to_string.h> 13 #include <libmesh/tensor_value.h> 14 #include <libmesh/enum_elem_quality.h> 15 #include <libmesh/fe_base.h> 16 #include <libmesh/quadrature_gauss.h> 32 CPPUNIT_TEST( testEdge2 );
33 CPPUNIT_TEST( testTri3 );
34 CPPUNIT_TEST( testQuad4 );
35 CPPUNIT_TEST( testPyramid5 );
36 CPPUNIT_TEST( testPrism6 );
37 CPPUNIT_TEST( testHex8 );
38 CPPUNIT_TEST( testC0Polygon );
39 CPPUNIT_TEST( testC0Polyhedron );
40 CPPUNIT_TEST_SUITE_END();
69 std::vector<Point> pts = {
Point(1, 0, 0),
Point(1, 3, 0)};
70 auto [edge2, nodes] = this->construct_elem(pts,
EDGE2);
71 const Point n1 = edge2->side_vertex_average_normal(0);
75 const Point n2 = edge2->side_vertex_average_normal(1);
104 std::vector<Point> pts = {
Point(1, 0, 0),
Point(1, 1, 0),
Point(0, 3, 1)};
105 auto [tri3, nodes] = this->construct_elem(pts,
TRI3);
106 const Point n1 = tri3->side_vertex_average_normal(0);
110 const Point n2 = tri3->side_vertex_average_normal(1);
114 const Point n3 = tri3->side_vertex_average_normal(2);
148 std::vector<Point> pts = {
Point(1, 0, 0),
Point(1, 3, 0),
Point(-1, -1, 0),
Point(0, -1, 0)};
149 auto [quad4, nodes] = this->construct_elem(pts,
QUAD4);
150 const Point n1 = quad4->side_vertex_average_normal(0);
154 const Point n2 = quad4->side_vertex_average_normal(1);
158 const Point n3 = quad4->side_vertex_average_normal(2);
162 const Point n4 = quad4->side_vertex_average_normal(3);
170 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, 0, 1),
Point(1, 1, 0),
Point(0, 1, 1)};
171 auto [quad4, nodes] = this->construct_elem(pts,
QUAD4);
172 const Point n1 = quad4->side_vertex_average_normal(0);
176 const Point n2 = quad4->side_vertex_average_normal(1);
180 const Point n3 = quad4->side_vertex_average_normal(2);
184 const Point n4 = quad4->side_vertex_average_normal(3);
192 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, -2, 3),
Point(1, 1, 0),
Point(0, 2, -10.5)};
193 auto [quad4, nodes] = this->construct_elem(pts,
QUAD4);
194 for (
const auto s :
make_range(quad4->n_sides()))
196 const Point n1 = quad4->side_vertex_average_normal(s);
197 const Point normal = quad4->Elem::side_vertex_average_normal(s);
300 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, 0, 3),
Point(1, 1, 0),
Point(0, 2, 1),
301 Point(-2.2, 0, 4),
Point(-1, 0, 5),
Point(-0.5, 1, 4),
Point(-2.2, 2, 6)};
302 auto [hex8, nodes] = this->construct_elem(pts,
HEX8);
305 const std::vector<Point> & normals = fe->get_normals();
306 for (
const auto s :
make_range(hex8->n_sides()))
308 const std::unique_ptr<const Elem> face = hex8->build_side_ptr(s);
309 fe->attach_quadrature_rule(&qface);
311 const Point n1 = hex8->side_vertex_average_normal(s);
324 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, 0, 0),
Point(1, 1, 0),
Point(0, 1, 0)};
325 auto [square, nodes] = this->construct_elem(pts,
C0POLYGON);
326 const Point n1 = square->side_vertex_average_normal(0);
330 const Point n2 = square->side_vertex_average_normal(1);
334 const Point n3 = square->side_vertex_average_normal(2);
338 const Point n4 = square->side_vertex_average_normal(3);
345 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, 0, 0),
Point(1.5, 1, 0),
Point(1, 2, 0),
Point(0, 2, 0) ,
Point(-0.5, 1, 0)};
346 auto [hexagon, nodes] = this->construct_elem(pts,
C0POLYGON);
347 const Point n1 = hexagon->side_vertex_average_normal(0);
351 const Point n2 = hexagon->side_vertex_average_normal(1);
355 const Point n3 = hexagon->side_vertex_average_normal(2);
359 const Point n4 = hexagon->side_vertex_average_normal(3);
363 const Point n5 = hexagon->side_vertex_average_normal(4);
367 const Point n6 = hexagon->side_vertex_average_normal(5);
375 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, 0, 3),
Point(1, 1, 0),
Point(0, 2, 1)};
376 auto [poly4, nodes] = this->construct_elem(pts,
C0POLYGON);
378 auto [quad4, nodes2] = this->construct_elem(pts,
QUAD4);
379 const std::unique_ptr<const Elem> face = quad4->build_side_ptr(0);
382 fe->attach_quadrature_rule(&qface);
383 const std::vector<Point> & normals = fe->get_normals();
384 for (
const auto s :
make_range(quad4->n_sides()))
386 const std::unique_ptr<const Elem> face = quad4->build_side_ptr(s);
387 fe->attach_quadrature_rule(&qface);
389 const Point n1 = quad4->side_vertex_average_normal(s);
402 std::vector<Point> points = {
Point(0, 0, 0),
Point(1, 0, 0),
Point(1, 1, 0),
Point(0, 1, 0),
403 Point(0, 0, 1),
Point(1, 0, 1),
Point(1, 1, 1),
Point(0, 1, 1)};
406 const std::vector<std::vector<unsigned int>> nodes_on_side =
415 std::vector<std::unique_ptr<Node>> nodes(points.size());
420 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
424 const auto & nodes_on_s = nodes_on_side[s];
425 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
427 sides[s]->set_node(i, nodes[nodes_on_s[i]].
get());
430 std::unique_ptr<Elem> polyhedron = std::make_unique<C0Polyhedron>(sides);
431 const Point n1 = polyhedron->side_vertex_average_normal(0);
435 const Point n2 = polyhedron->side_vertex_average_normal(1);
439 const Point n3 = polyhedron->side_vertex_average_normal(2);
443 const Point n4 = polyhedron->side_vertex_average_normal(3);
447 const Point n5 = polyhedron->side_vertex_average_normal(4);
451 const Point n6 = polyhedron->side_vertex_average_normal(5);
459 std::vector<Point> pts = {
Point(0, 0, 0),
Point(1, 0, 0),
Point(1, 1, 0),
Point(0, 1, 0),
460 Point(0, 0, 4),
Point(1, 0, 4),
Point(1, 1, 5),
Point(0, 1, 5)};
463 const std::vector<std::vector<unsigned int>> nodes_on_side =
472 std::vector<std::unique_ptr<Node>> nodes(pts.size());
477 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
481 const auto & nodes_on_s = nodes_on_side[s];
482 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
484 sides[s]->set_node(i, nodes[nodes_on_s[i]].
get());
487 std::unique_ptr<Elem> polyhedron = std::make_unique<C0Polyhedron>(sides);
490 auto [hex8, nodes2] = this->construct_elem(pts,
HEX8);
491 for (
const auto s :
make_range(hex8->n_sides()))
493 const Point n1 = polyhedron->side_vertex_average_normal(s);
494 const Point normal = hex8->Elem::side_vertex_average_normal(s);
508 std::pair<std::unique_ptr<Elem>, std::vector<std::unique_ptr<Node>>>
512 const unsigned int n_points = pts.size();
515 std::vector<std::unique_ptr<Node>> nodes(n_points);
516 for (
unsigned int i=0; i<n_points; i++)
520 std::unique_ptr<Elem> elem;
524 elem = std::make_unique<C0Polygon>(n_points);
527 libmesh_error_msg_if(elem->n_nodes() != n_points,
528 "Wrong number of points " 530 <<
" provided to build a " 533 for (
unsigned int i=0; i<n_points; i++)
534 elem->set_node(i, nodes[i].get());
537 return std::make_pair(std::move(elem), std::move(nodes));
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
ElemType
Defines an enum for geometric element types.
static constexpr Real TOLERANCE
This is the base class from which all geometric element types are derived.
CPPUNIT_TEST_SUITE_REGISTRATION(SideVertexAverageNormalTest)
The libMesh namespace provides an interface to certain functionality in the library.
std::pair< std::unique_ptr< Elem >, std::vector< std::unique_ptr< Node > > > construct_elem(const std::vector< Point > &pts, ElemType elem_type)
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
virtual Point side_vertex_average_normal(const unsigned int s) const
std::string enum_to_string(const T e)
static std::unique_ptr< Node > build(const Node &n)
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...
This class implements specific orders of Gauss quadrature.
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...
const Elem & get(const ElemType type_in)