Skip to content

Commit

Permalink
Address comments (idaholab#20621)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schunert committed Nov 1, 2023
1 parent e38cee4 commit e637b74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
!syntax description /Mesh/SidesetsEncloseBlocks

This mesh generator ensures that the blocks provided by the
[!param](/meshgenerators/SidesetsEncloseBlocks/block)
parameter are enclosed by the sidesets provided by [!param](/meshgenerators/SidesetsEncloseBlocks/boundary).
[!param](/Mesh/SidesetsEncloseBlocks/block)
parameter are enclosed by the sidesets provided by [!param](/Mesh/SidesetsEncloseBlocks/boundary).
If that is not the case, the behavior of the mesh generator depends on whether
[!param](/meshgenerators/SidesetsEncloseBlocks/new_boundary) is provided.
[!param](/Mesh/SidesetsEncloseBlocks/new_boundary) is provided.
If it is not provided, then an error is thrown. If it is provided, then the side
that is not covered is added to the new boundary.

Expand Down
1 change: 1 addition & 0 deletions framework/include/meshgenerators/SidesetsEncloseBlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ class SidesetsEncloseBlocks : public MeshGenerator
std::unique_ptr<MeshBase> generate() override;

protected:
/// the mesh that is passed from the meshgen executed before this meshgen
std::unique_ptr<MeshBase> & _input;
};
14 changes: 3 additions & 11 deletions framework/src/meshgenerators/SidesetsEncloseBlocks.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ SidesetsEncloseBlocks::generate()
{
std::unique_ptr<MeshBase> mesh = std::move(_input);

// Get a reference to our BoundaryInfo object for later use
BoundaryInfo & boundary_info = mesh->get_boundary_info();

// get a list of all sides; vector of tuples (elem, loc_side, side_set)
auto side_list = boundary_info.build_active_side_list();

// error on finding a side that is not covered
bool error_out = !isParamValid("new_boundary");
boundary_id_type new_sideset_id;
Expand All @@ -64,20 +60,18 @@ SidesetsEncloseBlocks::generate()
if (ss.fail())
new_sideset_id = boundary_info.get_id_by_name(new_boundary);

// make sure that _sideset exists
if (new_sideset_id == BoundaryInfo::invalid_id)
paramError("new_boundary", "Not a valid boundary");
}

// get blocks
std::vector<subdomain_id_type> vec_block_ids =
MooseMeshUtils::getSubdomainIDs(*mesh, getParam<std::vector<SubdomainName>>("block"));
std::set<subdomain_id_type> blk_ids(vec_block_ids.begin(), vec_block_ids.end());

// get boundaries
// check if the provided sideset name is actually a sideset id
// if _sideset_name can be converted to integer it's interpreted
// as sideset id
// if it can be converted to integer it's interpreted
// as a sideset id
auto boundary_name_vec = getParam<std::vector<BoundaryName>>("boundary");
std::vector<boundary_id_type> bnd_ids_vec;
bnd_ids_vec.reserve(boundary_name_vec.size());
Expand All @@ -91,7 +85,6 @@ SidesetsEncloseBlocks::generate()
if (ss.fail())
sideset_id = boundary_info.get_id_by_name(bnd_name);

// make sure that _sideset exists
if (sideset_id == BoundaryInfo::invalid_id)
paramError("boundary", "Not a valid boundary");
bnd_ids_vec.push_back(sideset_id);
Expand All @@ -105,7 +98,6 @@ SidesetsEncloseBlocks::generate()
for (const Elem * elem : as_range(mesh->active_local_subdomain_elements_begin(block_id),
mesh->active_local_subdomain_elements_end(block_id)))
{
// loop through sides
for (unsigned int j = 0; j < elem->n_sides(); ++j)
{
const Elem * neigh = elem->neighbor_ptr(j);
Expand All @@ -127,7 +119,7 @@ SidesetsEncloseBlocks::generate()
bnd_ids_vec.begin(),
bnd_ids_vec.end(),
std::inserter(intersection, intersection.end()));
// is intersection emtpy?

if (intersection.size() == 0)
{
if (error_out)
Expand Down
5 changes: 3 additions & 2 deletions test/tests/meshgenerators/sideset_enclose_block/tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

[sidesets_enclosed_blocks]
requirement = 'The system shall be able to check of a set of blocks is enclosed by a set of sidesets'
recover = false

[check_no_error]
type = 'Exodiff'
input = 'sideset_enclose_blocks.i'
exodiff = 'check_no_error.e'
detail = '.'
cli_args = '--mesh-only check_no_error.e'
recover = false
[]

[check_error]
Expand All @@ -20,6 +19,7 @@
expect_err = "Element id 5 side 0 is external and not covered by specified boundaries."
cli_args = 'Mesh/add_sides/paired_block="1" --mesh-only'
detail = ' and error out if this condition is not met.'
recover = false
[]

[add_new_boundary]
Expand All @@ -29,6 +29,7 @@
max_parallel = 1
cli_args = 'Mesh/add_sides/paired_block="1" Mesh/enclosed/new_boundary=12 --mesh-only add_new_boundary.e'
detail = ' and upon user request add missing sides into a specified input.'
recover = false
[]
[]
[]

0 comments on commit e637b74

Please sign in to comment.