From 4fa86613c9114829ca20dd8375e17da704cf128b Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Wed, 19 Jun 2024 15:13:30 -0700 Subject: [PATCH 1/7] Add Elem::is_internal --- include/geom/elem.h | 5 +++++ src/geom/elem.C | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/geom/elem.h b/include/geom/elem.h index c1b02425019..fc9c83995d9 100644 --- a/include/geom/elem.h +++ b/include/geom/elem.h @@ -738,6 +738,11 @@ class Elem : public ReferenceCountedObject, */ virtual bool is_face(const unsigned int i) const = 0; + /** + * \returns \p true if the specified (local) node number is an interior node. + */ + bool is_internal(const unsigned int i) const; + /** * \returns \p true if the specified (local) node number is on the * specified side. diff --git a/src/geom/elem.C b/src/geom/elem.C index c7ac2b2931a..77319267cd9 100644 --- a/src/geom/elem.C +++ b/src/geom/elem.C @@ -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 !is_vertex(i); + + case 2: + return !is_vertex(i) && !is_edge(i); + + case 3: + return !is_vertex(i) && !is_edge(i) && !is_face(i); + + default: + libmesh_error_msg("impossible element dimension " << std::to_string(this->dim())); + return 0; + } +} + } // namespace libMesh From 6f483cfb5a759e18ac625a92054a67b751a28ee6 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Mon, 1 Jul 2024 13:30:43 -0700 Subject: [PATCH 2/7] Be consistent about using 'internal' --- include/geom/elem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/geom/elem.h b/include/geom/elem.h index fc9c83995d9..bc6eec403ad 100644 --- a/include/geom/elem.h +++ b/include/geom/elem.h @@ -739,7 +739,7 @@ class Elem : public ReferenceCountedObject, virtual bool is_face(const unsigned int i) const = 0; /** - * \returns \p true if the specified (local) node number is an interior node. + * \returns \p true if the specified (local) node number is an internal node. */ bool is_internal(const unsigned int i) const; From 1dfcaa30189e3cf838b2ac834eb51f65f20ed80d Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Tue, 2 Jul 2024 10:09:06 -0700 Subject: [PATCH 3/7] Fix is_edge in tri7 --- src/geom/face_tri7.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geom/face_tri7.C b/src/geom/face_tri7.C index 98e875e13db..f93748e7a22 100644 --- a/src/geom/face_tri7.C +++ b/src/geom/face_tri7.C @@ -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) return false; return true; } From 654fb114c5586a88347ba85a2e21b6dbff1f39d3 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Tue, 2 Jul 2024 10:09:27 -0700 Subject: [PATCH 4/7] prefix with this-> --- src/geom/elem.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/geom/elem.C b/src/geom/elem.C index 77319267cd9..eaafc58d250 100644 --- a/src/geom/elem.C +++ b/src/geom/elem.C @@ -3206,13 +3206,13 @@ Elem::is_internal(const unsigned int i) const return false; case 1: - return !is_vertex(i); + return !this->is_vertex(i); case 2: - return !is_vertex(i) && !is_edge(i); + return !this->is_vertex(i) && !this->is_edge(i); case 3: - return !is_vertex(i) && !is_edge(i) && !is_face(i); + 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())); From 1d01dd8076c692a86ede7e9be36df3db6c7f0ef3 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Tue, 2 Jul 2024 10:09:40 -0700 Subject: [PATCH 5/7] Unit test is_internal --- tests/geom/elem_test.C | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/geom/elem_test.C b/tests/geom/elem_test.C index c0b7255cb59..f2f1d7fa1ae 100644 --- a/tests/geom/elem_test.C +++ b/tests/geom/elem_test.C @@ -636,6 +636,30 @@ 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 && nd == 8) + CPPUNIT_ASSERT(elem->is_internal(nd)); + else if (elem->type() == TRI7 && nd == 6) + CPPUNIT_ASSERT(elem->is_internal(nd)); + else + CPPUNIT_ASSERT(!elem->is_internal(nd)); + } + } + + }; #define ELEMTEST \ @@ -651,8 +675,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 { \ From 97d37f13b3ab44f1df8b8f90a421e4528cc7536a Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Tue, 2 Jul 2024 11:50:15 -0700 Subject: [PATCH 6/7] Fix inf hex and prism `is_*` code --- include/geom/cell_inf_hex.h | 2 +- include/geom/cell_inf_prism.h | 4 ++-- tests/geom/elem_test.C | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/geom/cell_inf_hex.h b/include/geom/cell_inf_hex.h index 4cab6435fb2..c2a2ce2a2ed 100644 --- a/include/geom/cell_inf_hex.h +++ b/include/geom/cell_inf_hex.h @@ -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); } /** * \returns \p true if the specified child is on the diff --git a/include/geom/cell_inf_prism.h b/include/geom/cell_inf_prism.h index eaf49925c90..ba178872ade 100644 --- a/include/geom/cell_inf_prism.h +++ b/include/geom/cell_inf_prism.h @@ -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 diff --git a/tests/geom/elem_test.C b/tests/geom/elem_test.C index f2f1d7fa1ae..0e3ab9b0059 100644 --- a/tests/geom/elem_test.C +++ b/tests/geom/elem_test.C @@ -654,6 +654,10 @@ public: 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)); } From 9d64dd4345f60f1c350bb9ea97f0812127136d62 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Tue, 2 Jul 2024 12:03:19 -0700 Subject: [PATCH 7/7] Update test for QUADSHELL9 --- tests/geom/elem_test.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/geom/elem_test.C b/tests/geom/elem_test.C index 0e3ab9b0059..64b2b5e626b 100644 --- a/tests/geom/elem_test.C +++ b/tests/geom/elem_test.C @@ -650,7 +650,7 @@ public: CPPUNIT_ASSERT(elem->is_internal(nd)); else if (elem->type() == PRISM21 && nd == 20) CPPUNIT_ASSERT(elem->is_internal(nd)); - else if (elem->type() == QUAD9 && nd == 8) + 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));