Skip to content

Commit f2940e0

Browse files
committed
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
1 parent 125f664 commit f2940e0

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

include/mesh/boundary_info.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,18 @@ class BoundaryInfo : public ParallelObject
874874
const std::multimap<const Elem *, std::pair<unsigned short int, boundary_id_type>> & get_sideset_map() const
875875
{ return _boundary_side_id; }
876876

877+
/**
878+
* \returns Whether or not there are some children on boundary sides
879+
*/
880+
bool is_children_on_boundary_side() const
881+
{ return _children_on_boundary; }
882+
883+
/**
884+
* Whether or not to allow set boundary sides on children elements
885+
*/
886+
void allow_children_on_boundary_side(const bool children_on_boundary)
887+
{ _children_on_boundary = children_on_boundary; }
888+
877889
private:
878890

879891
/**

src/mesh/boundary_info.C

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,8 @@ void BoundaryInfo::remove_edge (const Elem * elem,
13661366
{
13671367
libmesh_assert(elem);
13681368

1369-
// Only level 0 elements unless the flag "_children_on_boundary" is on.
1370-
libmesh_assert(elem->level()==0 || _children_on_boundary);
1369+
// Only level 0 elements are stored in BoundaryInfo.
1370+
libmesh_assert_equal_to (elem->level(), 0);
13711371

13721372
// Erase (elem, edge, *) entries from map.
13731373
erase_if(_boundary_edge_id, elem,
@@ -1383,8 +1383,8 @@ void BoundaryInfo::remove_edge (const Elem * elem,
13831383
{
13841384
libmesh_assert(elem);
13851385

1386-
// Only level 0 elements unless the flag "_children_on_boundary" is on.
1387-
libmesh_assert(elem->level() == 0 || _children_on_boundary);
1386+
// Only level 0 elements are stored in BoundaryInfo.
1387+
libmesh_assert_equal_to (elem->level(), 0);
13881388

13891389
// Erase (elem, edge, id) entries from map.
13901390
erase_if(_boundary_edge_id, elem,
@@ -1398,8 +1398,8 @@ void BoundaryInfo::remove_shellface (const Elem * elem,
13981398
{
13991399
libmesh_assert(elem);
14001400

1401-
// Only level 0 elements unless the flag "_children_on_boundary" is on.
1402-
libmesh_assert(elem->level() == 0 || _children_on_boundary);
1401+
// Only level 0 elements are stored in BoundaryInfo.
1402+
libmesh_assert_equal_to (elem->level(), 0);
14031403

14041404
// Shells only have 2 faces
14051405
libmesh_assert_less(shellface, 2);
@@ -1418,8 +1418,8 @@ void BoundaryInfo::remove_shellface (const Elem * elem,
14181418
{
14191419
libmesh_assert(elem);
14201420

1421-
// Only level 0 elements unless the flag "_children_on_boundary" is on.
1422-
libmesh_assert(elem->level() == 0 || _children_on_boundary);
1421+
// Only level 0 elements are stored in BoundaryInfo.
1422+
libmesh_assert_equal_to (elem->level(), 0);
14231423

14241424
// Shells only have 2 faces
14251425
libmesh_assert_less(shellface, 2);
@@ -1510,6 +1510,8 @@ unsigned int BoundaryInfo::side_with_boundary_id(const Elem * const elem,
15101510
// parent if any
15111511
if (elem->level() != 0)
15121512
searched_elem_vec.push_back(elem->top_parent());
1513+
else if (!_children_on_boundary)
1514+
searched_elem_vec.push_back(elem);
15131515

15141516
for (auto it = searched_elem_vec.begin(); it != searched_elem_vec.end(); ++it)
15151517
{
@@ -1569,6 +1571,8 @@ BoundaryInfo::sides_with_boundary_id(const Elem * const elem,
15691571
// Return boundary information of its parent as well
15701572
if (elem->level() != 0)
15711573
searched_elem_vec.push_back(elem->top_parent());
1574+
else if (!_children_on_boundary)
1575+
searched_elem_vec.push_back(elem);
15721576

15731577
for (auto it = searched_elem_vec.begin(); it != searched_elem_vec.end(); ++it)
15741578
{

0 commit comments

Comments
 (0)