Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/geom/edge_edge2.C
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Edge2::side_vertex_average_normal(const unsigned int s) const
return (s == 0) ? v : -v;
}


dof_id_type Edge2::key () const
{
return this->compute_key(this->node_id(0),
Expand Down
3 changes: 3 additions & 0 deletions src/geom/reference_elem.C
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ void init_ref_elem_table()
{
ref_elem_file.clear();

// 0D elements
ref_elem_file[NODEELEM] = ElemDataStrings::one_nodeelem;

// 1D elements
ref_elem_file[EDGE2] = ElemDataStrings::one_edge;
ref_elem_file[EDGE3] = ElemDataStrings::one_edge3;
Expand Down
14 changes: 14 additions & 0 deletions src/geom/reference_elem.data
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
typedef std::map<ElemType, std::string> FileMapType;
FileMapType ref_elem_file;

static const char* one_nodeelem =
"libMesh-0.7.0+\n"
"1 # number of elements\n"
"1 # number of nodes\n"
". # boundary condition specification file\n"
"n/a # subdomain id specification file\n"
"n/a # processor id specification file\n"
"n/a # p-level specification file\n"
"1 # n_elem at level 0, [ type (n0 ... nN-1) ]\n"
"27 0\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(General comment which I can address separately from this PR.)

So 27 is the ElemType enumeration value here. @roystgnr maybe we should update the xda comment that we typically write to make it clear that the first number is an ElemType rather than the vague "type" and the node ids aren't optional? At least I think that's what we were trying to imply with the parentheses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw I generated this manually. I could not figure out the script (generated an empty file)

"0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00\n"
"1 # number of boundary conditions\n"
"0 0 0\n"
;

static const char* one_edge =
"libMesh-0.7.0+\n"
Expand Down
38 changes: 38 additions & 0 deletions tests/geom/side_vertex_average_normal_test.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SideVertexAverageNormalTest : public CppUnit::TestCase
public:
LIBMESH_CPPUNIT_TEST_SUITE( SideVertexAverageNormalTest );
CPPUNIT_TEST( testEdge2 );
CPPUNIT_TEST( testEdge3 );
CPPUNIT_TEST( testTri3 );
CPPUNIT_TEST( testQuad4 );
CPPUNIT_TEST( testPyramid5 );
Expand Down Expand Up @@ -79,6 +80,43 @@ public:
}
}

void testEdge3()
{
LOG_UNIT_TEST;

{
// Reference
const Elem & edge3 = ReferenceElem::get(EDGE3);
const Point n1 = edge3.side_vertex_average_normal(0);
LIBMESH_ASSERT_FP_EQUAL(-1, n1(0), TOLERANCE*TOLERANCE);
LIBMESH_ASSERT_FP_EQUAL(0, n1(1), TOLERANCE*TOLERANCE);
LIBMESH_ASSERT_FP_EQUAL(0, n1(2), TOLERANCE*TOLERANCE);
const Point n2 = edge3.side_vertex_average_normal(1);
LIBMESH_ASSERT_FP_EQUAL(1, n2(0), TOLERANCE*TOLERANCE);
LIBMESH_ASSERT_FP_EQUAL(0, n2(1), TOLERANCE*TOLERANCE);
LIBMESH_ASSERT_FP_EQUAL(0, n2(2), TOLERANCE*TOLERANCE);
}

{
// Oriented, checked with the FE construction
std::vector<Point> pts = {Point(1, 0, 0), Point(1, 3, 0), Point(2.2344, 1.210293, 0)};
auto [edge3, nodes] = this->construct_elem(pts, EDGE3);
std::unique_ptr<libMesh::FEBase> fe(libMesh::FEBase::build(1, libMesh::FEType(1)));
libMesh::QGauss qface(0, libMesh::CONSTANT);
const std::vector<Point> & normals = fe->get_normals();
for (const auto s : make_range(edge3->n_sides()))
{
const std::unique_ptr<const Elem> face = edge3->build_side_ptr(s);
fe->attach_quadrature_rule(&qface);
fe->reinit(edge3.get(), s, TOLERANCE);
const Point n1 = edge3->side_vertex_average_normal(s);
LIBMESH_ASSERT_FP_EQUAL(normals[0](0), n1(0), TOLERANCE*TOLERANCE);
LIBMESH_ASSERT_FP_EQUAL(normals[0](1), n1(1), TOLERANCE*TOLERANCE);
LIBMESH_ASSERT_FP_EQUAL(normals[0](2), n1(2), TOLERANCE*TOLERANCE);
}
}
}

void testTri3()
{
LOG_UNIT_TEST;
Expand Down