Skip to content

Commit bb3a8ff

Browse files
authored
Merge pull request #4292 from GiudGiud/PR_vertex_ave_2
Move side vertex average normal implementation from edge2 to edge
2 parents b1a1048 + 63dba73 commit bb3a8ff

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

src/geom/edge_edge2.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Edge2::side_vertex_average_normal(const unsigned int s) const
151151
return (s == 0) ? v : -v;
152152
}
153153

154+
154155
dof_id_type Edge2::key () const
155156
{
156157
return this->compute_key(this->node_id(0),

src/geom/reference_elem.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ void init_ref_elem_table()
178178
{
179179
ref_elem_file.clear();
180180

181+
// 0D elements
182+
ref_elem_file[NODEELEM] = ElemDataStrings::one_nodeelem;
183+
181184
// 1D elements
182185
ref_elem_file[EDGE2] = ElemDataStrings::one_edge;
183186
ref_elem_file[EDGE3] = ElemDataStrings::one_edge3;

src/geom/reference_elem.data

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
typedef std::map<ElemType, std::string> FileMapType;
77
FileMapType ref_elem_file;
88

9+
static const char* one_nodeelem =
10+
"libMesh-0.7.0+\n"
11+
"1 # number of elements\n"
12+
"1 # number of nodes\n"
13+
". # boundary condition specification file\n"
14+
"n/a # subdomain id specification file\n"
15+
"n/a # processor id specification file\n"
16+
"n/a # p-level specification file\n"
17+
"1 # n_elem at level 0, [ type (n0 ... nN-1) ]\n"
18+
"27 0\n"
19+
"0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00\n"
20+
"1 # number of boundary conditions\n"
21+
"0 0 0\n"
22+
;
923

1024
static const char* one_edge =
1125
"libMesh-0.7.0+\n"

tests/geom/side_vertex_average_normal_test.C

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class SideVertexAverageNormalTest : public CppUnit::TestCase
3030
public:
3131
LIBMESH_CPPUNIT_TEST_SUITE( SideVertexAverageNormalTest );
3232
CPPUNIT_TEST( testEdge2 );
33+
CPPUNIT_TEST( testEdge3 );
3334
CPPUNIT_TEST( testTri3 );
3435
CPPUNIT_TEST( testQuad4 );
3536
CPPUNIT_TEST( testPyramid5 );
@@ -79,6 +80,43 @@ public:
7980
}
8081
}
8182

83+
void testEdge3()
84+
{
85+
LOG_UNIT_TEST;
86+
87+
{
88+
// Reference
89+
const Elem & edge3 = ReferenceElem::get(EDGE3);
90+
const Point n1 = edge3.side_vertex_average_normal(0);
91+
LIBMESH_ASSERT_FP_EQUAL(-1, n1(0), TOLERANCE*TOLERANCE);
92+
LIBMESH_ASSERT_FP_EQUAL(0, n1(1), TOLERANCE*TOLERANCE);
93+
LIBMESH_ASSERT_FP_EQUAL(0, n1(2), TOLERANCE*TOLERANCE);
94+
const Point n2 = edge3.side_vertex_average_normal(1);
95+
LIBMESH_ASSERT_FP_EQUAL(1, n2(0), TOLERANCE*TOLERANCE);
96+
LIBMESH_ASSERT_FP_EQUAL(0, n2(1), TOLERANCE*TOLERANCE);
97+
LIBMESH_ASSERT_FP_EQUAL(0, n2(2), TOLERANCE*TOLERANCE);
98+
}
99+
100+
{
101+
// Oriented, checked with the FE construction
102+
std::vector<Point> pts = {Point(1, 0, 0), Point(1, 3, 0), Point(2.2344, 1.210293, 0)};
103+
auto [edge3, nodes] = this->construct_elem(pts, EDGE3);
104+
std::unique_ptr<libMesh::FEBase> fe(libMesh::FEBase::build(1, libMesh::FEType(1)));
105+
libMesh::QGauss qface(0, libMesh::CONSTANT);
106+
const std::vector<Point> & normals = fe->get_normals();
107+
for (const auto s : make_range(edge3->n_sides()))
108+
{
109+
const std::unique_ptr<const Elem> face = edge3->build_side_ptr(s);
110+
fe->attach_quadrature_rule(&qface);
111+
fe->reinit(edge3.get(), s, TOLERANCE);
112+
const Point n1 = edge3->side_vertex_average_normal(s);
113+
LIBMESH_ASSERT_FP_EQUAL(normals[0](0), n1(0), TOLERANCE*TOLERANCE);
114+
LIBMESH_ASSERT_FP_EQUAL(normals[0](1), n1(1), TOLERANCE*TOLERANCE);
115+
LIBMESH_ASSERT_FP_EQUAL(normals[0](2), n1(2), TOLERANCE*TOLERANCE);
116+
}
117+
}
118+
}
119+
82120
void testTri3()
83121
{
84122
LOG_UNIT_TEST;

0 commit comments

Comments
 (0)