Skip to content

Commit

Permalink
Made location=outside actually work inside of sidesets_bounding_box_g…
Browse files Browse the repository at this point in the history
…enerator.C idaholab#16813
  • Loading branch information
peatna committed Sep 29, 2022
1 parent 14b5c5a commit 453b2ae
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
11 changes: 7 additions & 4 deletions framework/src/meshgenerators/SideSetsFromBoundingBoxGenerator.C
Expand Up @@ -78,6 +78,7 @@ SideSetsFromBoundingBoxGenerator::generate()

bool found_element = false;
bool found_side_sets = false;
const bool inside = (_location == "INSIDE");

if (!_boundary_id_overlap)
{
Expand All @@ -87,8 +88,8 @@ SideSetsFromBoundingBoxGenerator::generate()
// boolean if element centroid is in bounding box
bool contains = _bounding_box.contains_point(elem->vertex_average());

// check if active elements are found in the bounding box
if (contains)
// check if active elements are found either in or out of the bounding box, apropos "inside"
if (contains == inside)
{
found_element = true;
// loop over sides of elements within bounding box
Expand All @@ -106,9 +107,12 @@ SideSetsFromBoundingBoxGenerator::generate()
}
}
}
if (!found_element)
if (!found_element && inside)
mooseError("No elements found within the bounding box");

if (!found_element && !inside)
mooseError("No elements found outside the bounding box");

if (!found_side_sets)
mooseError("No side sets found on active elements within the bounding box");
}
Expand All @@ -121,7 +125,6 @@ SideSetsFromBoundingBoxGenerator::generate()
" Must be 2 boundary inputs or more.");

bool found_node = false;
const bool inside = (_location == "INSIDE");

// Loop over the elements and assign node set id to nodes within the bounding box
for (auto node = mesh->active_nodes_begin(); node != mesh->active_nodes_end(); ++node)
Expand Down
@@ -0,0 +1,24 @@
[Mesh]
[./gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
parallel_type = replicated
[]

[./createNewSidesetOne]
type = SideSetsFromBoundingBoxGenerator
input = gmg
boundary_id_old = 'left'
boundary_id_new = 10
location = OUTSIDE
bottom_left = '-0.1 -0.1 0'
block_id = 0
top_right = '0.5 0.5 0'
[]
[]

[Outputs]
exodus = true
[]
Binary file not shown.
12 changes: 11 additions & 1 deletion test/tests/meshgenerators/sidesets_bounding_box_generator/tests
@@ -1,6 +1,6 @@
[Tests]
design = 'meshgenerators/SideSetsFromBoundingBoxGenerator.md'
issues = '#11640'
issues = '#11640 #16813'

[generate]
requirement = 'The system shall have the ability to generate side sets based upon bounding '
Expand Down Expand Up @@ -44,6 +44,16 @@

detail = 'where bounding boxes perfectly overlap but create unique ids.'
[]
[location_outside]
type = 'Exodiff'
input = 'generate_outside.i'
cli_args = '--mesh-only'
exodiff = 'generate_outside_in.e'
mesh_mode = 'REPLICATED'
recover = false

detail = 'with only elements located outside of the bounding boxes.'
[]
[]

[errors]
Expand Down

0 comments on commit 453b2ae

Please sign in to comment.