Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Create Elem::is_internal API for local node indices #3897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 10, 2024
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
2 changes: 1 addition & 1 deletion include/geom/cell_inf_hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class InfHex : public InfCell
/**
* We number faces last.
*/
virtual bool is_face(const unsigned int i) const override final { return (i >= 12 && i < 16); }
virtual bool is_face(const unsigned int i) const override final { return (i >= 12 && i < 17); }
Copy link
Member

Choose a reason for hiding this comment

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

Damn, can't believe this has been sitting around for so long. Thank you!


/**
* \returns \p true if the specified child is on the
Expand Down
4 changes: 2 additions & 2 deletions include/geom/cell_inf_prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ class InfPrism : public InfCell
/**
* We number edges next.
*/
virtual bool is_edge(const unsigned int i) const override final { return (i > 6 && i < 9); }
virtual bool is_edge(const unsigned int i) const override final { return (i >= 6 && i < 9); }

/**
* We number faces last.
*/
virtual bool is_face(const unsigned int i) const override final { return (i > 9 && i < 12); }
virtual bool is_face(const unsigned int i) const override final { return (i >= 9 && i < 12); }

/**
* \returns \p true if the specified (local) node number is a
Expand Down
5 changes: 5 additions & 0 deletions include/geom/elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ class Elem : public ReferenceCountedObject<Elem>,
*/
virtual bool is_face(const unsigned int i) const = 0;

/**
* \returns \p true if the specified (local) node number is an internal node.
*/
bool is_internal(const unsigned int i) const;

/**
* \returns \p true if the specified (local) node number is on the
* specified side.
Expand Down
23 changes: 23 additions & 0 deletions src/geom/elem.C
Original file line number Diff line number Diff line change
Expand Up @@ -3197,4 +3197,27 @@ void Elem::swap2boundaryedges(unsigned short e1,
boundary_info->add_edge(this, e1, ids2);
}

bool
Elem::is_internal(const unsigned int i) const
{
switch (this->dim())
{
case 0:
return false;

case 1:
return !this->is_vertex(i);

case 2:
return !this->is_vertex(i) && !this->is_edge(i);

case 3:
return !this->is_vertex(i) && !this->is_edge(i) && !this->is_face(i);

default:
libmesh_error_msg("impossible element dimension " << std::to_string(this->dim()));
return 0;
}
}

} // namespace libMesh
2 changes: 1 addition & 1 deletion src/geom/face_tri7.C
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool Tri7::is_vertex(const unsigned int i) const

bool Tri7::is_edge(const unsigned int i) const
{
if (i < 3)
if (i < 3 || i == 6)
Copy link
Member

Choose a reason for hiding this comment

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

Okay, now I'm just ashamed.

return false;
return true;
}
Expand Down
33 changes: 31 additions & 2 deletions tests/geom/elem_test.C
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,34 @@ public:
test_n_refinements(2);
}

void test_is_internal()
{
LOG_UNIT_TEST;

for (const auto & elem :
this->_mesh->active_local_element_ptr_range())
for (const auto nd : elem->node_index_range())
{
if ((elem->type() == EDGE3 || elem->type() == EDGE4) && nd >= 2)
CPPUNIT_ASSERT(elem->is_internal(nd));
else if (elem->type() == HEX27 && nd == 26)
CPPUNIT_ASSERT(elem->is_internal(nd));
else if (elem->type() == PRISM21 && nd == 20)
CPPUNIT_ASSERT(elem->is_internal(nd));
else if ((elem->type() == QUAD9 || elem->type() == QUADSHELL9) && nd == 8)
CPPUNIT_ASSERT(elem->is_internal(nd));
else if (elem->type() == TRI7 && nd == 6)
CPPUNIT_ASSERT(elem->is_internal(nd));
else if (elem->type() == INFHEX18 && nd == 17)
CPPUNIT_ASSERT(elem->is_internal(nd));
else if (elem->type() == INFQUAD6 && nd == 5)
CPPUNIT_ASSERT(elem->is_internal(nd));
else
CPPUNIT_ASSERT(!elem->is_internal(nd));
}
}


};

#define ELEMTEST \
Expand All @@ -651,8 +679,9 @@ public:
CPPUNIT_TEST( test_center_node_on_side ); \
CPPUNIT_TEST( test_side_type ); \
CPPUNIT_TEST( test_elem_side_builder ); \
CPPUNIT_TEST( test_refinement); \
CPPUNIT_TEST( test_double_refinement);
CPPUNIT_TEST( test_refinement ); \
CPPUNIT_TEST( test_double_refinement ); \
CPPUNIT_TEST( test_is_internal )

#define INSTANTIATE_ELEMTEST(elemtype) \
class ElemTest_##elemtype : public ElemTest<elemtype> { \
Expand Down