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

Skip to content

Commit 67b9856

Browse files
authored
Merge pull request #3897 from lindsayad/is-internal
Create `Elem::is_internal` API for local node indices
2 parents 7f0cfbe + 9d64dd4 commit 67b9856

File tree

6 files changed

+63
-6
lines changed

6 files changed

+63
-6
lines changed

include/geom/cell_inf_hex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class InfHex : public InfCell
127127
/**
128128
* We number faces last.
129129
*/
130-
virtual bool is_face(const unsigned int i) const override final { return (i >= 12 && i < 16); }
130+
virtual bool is_face(const unsigned int i) const override final { return (i >= 12 && i < 17); }
131131

132132
/**
133133
* \returns \p true if the specified child is on the

include/geom/cell_inf_prism.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ class InfPrism : public InfCell
110110
/**
111111
* We number edges next.
112112
*/
113-
virtual bool is_edge(const unsigned int i) const override final { return (i > 6 && i < 9); }
113+
virtual bool is_edge(const unsigned int i) const override final { return (i >= 6 && i < 9); }
114114

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

120120
/**
121121
* \returns \p true if the specified (local) node number is a

include/geom/elem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,11 @@ class Elem : public ReferenceCountedObject<Elem>,
738738
*/
739739
virtual bool is_face(const unsigned int i) const = 0;
740740

741+
/**
742+
* \returns \p true if the specified (local) node number is an internal node.
743+
*/
744+
bool is_internal(const unsigned int i) const;
745+
741746
/**
742747
* \returns \p true if the specified (local) node number is on the
743748
* specified side.

src/geom/elem.C

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3197,4 +3197,27 @@ void Elem::swap2boundaryedges(unsigned short e1,
31973197
boundary_info->add_edge(this, e1, ids2);
31983198
}
31993199

3200+
bool
3201+
Elem::is_internal(const unsigned int i) const
3202+
{
3203+
switch (this->dim())
3204+
{
3205+
case 0:
3206+
return false;
3207+
3208+
case 1:
3209+
return !this->is_vertex(i);
3210+
3211+
case 2:
3212+
return !this->is_vertex(i) && !this->is_edge(i);
3213+
3214+
case 3:
3215+
return !this->is_vertex(i) && !this->is_edge(i) && !this->is_face(i);
3216+
3217+
default:
3218+
libmesh_error_msg("impossible element dimension " << std::to_string(this->dim()));
3219+
return 0;
3220+
}
3221+
}
3222+
32003223
} // namespace libMesh

src/geom/face_tri7.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool Tri7::is_vertex(const unsigned int i) const
128128

129129
bool Tri7::is_edge(const unsigned int i) const
130130
{
131-
if (i < 3)
131+
if (i < 3 || i == 6)
132132
return false;
133133
return true;
134134
}

tests/geom/elem_test.C

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,34 @@ public:
636636
test_n_refinements(2);
637637
}
638638

639+
void test_is_internal()
640+
{
641+
LOG_UNIT_TEST;
642+
643+
for (const auto & elem :
644+
this->_mesh->active_local_element_ptr_range())
645+
for (const auto nd : elem->node_index_range())
646+
{
647+
if ((elem->type() == EDGE3 || elem->type() == EDGE4) && nd >= 2)
648+
CPPUNIT_ASSERT(elem->is_internal(nd));
649+
else if (elem->type() == HEX27 && nd == 26)
650+
CPPUNIT_ASSERT(elem->is_internal(nd));
651+
else if (elem->type() == PRISM21 && nd == 20)
652+
CPPUNIT_ASSERT(elem->is_internal(nd));
653+
else if ((elem->type() == QUAD9 || elem->type() == QUADSHELL9) && nd == 8)
654+
CPPUNIT_ASSERT(elem->is_internal(nd));
655+
else if (elem->type() == TRI7 && nd == 6)
656+
CPPUNIT_ASSERT(elem->is_internal(nd));
657+
else if (elem->type() == INFHEX18 && nd == 17)
658+
CPPUNIT_ASSERT(elem->is_internal(nd));
659+
else if (elem->type() == INFQUAD6 && nd == 5)
660+
CPPUNIT_ASSERT(elem->is_internal(nd));
661+
else
662+
CPPUNIT_ASSERT(!elem->is_internal(nd));
663+
}
664+
}
665+
666+
639667
};
640668

641669
#define ELEMTEST \
@@ -651,8 +679,9 @@ public:
651679
CPPUNIT_TEST( test_center_node_on_side ); \
652680
CPPUNIT_TEST( test_side_type ); \
653681
CPPUNIT_TEST( test_elem_side_builder ); \
654-
CPPUNIT_TEST( test_refinement); \
655-
CPPUNIT_TEST( test_double_refinement);
682+
CPPUNIT_TEST( test_refinement ); \
683+
CPPUNIT_TEST( test_double_refinement ); \
684+
CPPUNIT_TEST( test_is_internal )
656685

657686
#define INSTANTIATE_ELEMTEST(elemtype) \
658687
class ElemTest_##elemtype : public ElemTest<elemtype> { \

0 commit comments

Comments
 (0)