From f2940e0fcffcb81301cd14c88088a09727b55ebe Mon Sep 17 00:00:00 2001 From: Fande Kong Date: Wed, 23 Feb 2022 14:55:30 -0700 Subject: [PATCH] Added APIs to allow users set the flag: _children_on_boundary The motivaiton is that: "automatic" way might not work for cases. For example, if the flag is on on a subset of processor cores, and then we do reparitioning, and then we might hit trouble because the flag is off on the other processors I try to avoid having a global reduction to have everyone on the same page. In fact, we know when we want to allow children on boundary in MOOSE. In this case, we should set the flag to make the code more robust --- include/mesh/boundary_info.h | 12 ++++++++++++ src/mesh/boundary_info.C | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/mesh/boundary_info.h b/include/mesh/boundary_info.h index 0e7508fbc86..ca06ab661f6 100644 --- a/include/mesh/boundary_info.h +++ b/include/mesh/boundary_info.h @@ -874,6 +874,18 @@ class BoundaryInfo : public ParallelObject const std::multimap> & get_sideset_map() const { return _boundary_side_id; } + /** + * \returns Whether or not there are some children on boundary sides + */ + bool is_children_on_boundary_side() const + { return _children_on_boundary; } + + /** + * Whether or not to allow set boundary sides on children elements + */ + void allow_children_on_boundary_side(const bool children_on_boundary) + { _children_on_boundary = children_on_boundary; } + private: /** diff --git a/src/mesh/boundary_info.C b/src/mesh/boundary_info.C index 8c38ff1ddd9..0e556bb1225 100644 --- a/src/mesh/boundary_info.C +++ b/src/mesh/boundary_info.C @@ -1366,8 +1366,8 @@ void BoundaryInfo::remove_edge (const Elem * elem, { libmesh_assert(elem); - // Only level 0 elements unless the flag "_children_on_boundary" is on. - libmesh_assert(elem->level()==0 || _children_on_boundary); + // Only level 0 elements are stored in BoundaryInfo. + libmesh_assert_equal_to (elem->level(), 0); // Erase (elem, edge, *) entries from map. erase_if(_boundary_edge_id, elem, @@ -1383,8 +1383,8 @@ void BoundaryInfo::remove_edge (const Elem * elem, { libmesh_assert(elem); - // Only level 0 elements unless the flag "_children_on_boundary" is on. - libmesh_assert(elem->level() == 0 || _children_on_boundary); + // Only level 0 elements are stored in BoundaryInfo. + libmesh_assert_equal_to (elem->level(), 0); // Erase (elem, edge, id) entries from map. erase_if(_boundary_edge_id, elem, @@ -1398,8 +1398,8 @@ void BoundaryInfo::remove_shellface (const Elem * elem, { libmesh_assert(elem); - // Only level 0 elements unless the flag "_children_on_boundary" is on. - libmesh_assert(elem->level() == 0 || _children_on_boundary); + // Only level 0 elements are stored in BoundaryInfo. + libmesh_assert_equal_to (elem->level(), 0); // Shells only have 2 faces libmesh_assert_less(shellface, 2); @@ -1418,8 +1418,8 @@ void BoundaryInfo::remove_shellface (const Elem * elem, { libmesh_assert(elem); - // Only level 0 elements unless the flag "_children_on_boundary" is on. - libmesh_assert(elem->level() == 0 || _children_on_boundary); + // Only level 0 elements are stored in BoundaryInfo. + libmesh_assert_equal_to (elem->level(), 0); // Shells only have 2 faces libmesh_assert_less(shellface, 2); @@ -1510,6 +1510,8 @@ unsigned int BoundaryInfo::side_with_boundary_id(const Elem * const elem, // parent if any if (elem->level() != 0) searched_elem_vec.push_back(elem->top_parent()); + else if (!_children_on_boundary) + searched_elem_vec.push_back(elem); for (auto it = searched_elem_vec.begin(); it != searched_elem_vec.end(); ++it) { @@ -1569,6 +1571,8 @@ BoundaryInfo::sides_with_boundary_id(const Elem * const elem, // Return boundary information of its parent as well if (elem->level() != 0) searched_elem_vec.push_back(elem->top_parent()); + else if (!_children_on_boundary) + searched_elem_vec.push_back(elem); for (auto it = searched_elem_vec.begin(); it != searched_elem_vec.end(); ++it) {