Skip to content

Commit

Permalink
Allow filtering faces by neighboring subdomain ID in ParsedGenerateSi…
Browse files Browse the repository at this point in the history
…deset (idaholab#15651)
  • Loading branch information
schuseba committed Jul 27, 2020
1 parent e1c9e89 commit 1409f61
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
6 changes: 6 additions & 0 deletions framework/include/meshgenerators/ParsedGenerateSideset.h
Expand Up @@ -45,12 +45,18 @@ class ParsedGenerateSideset : public SideSetsGeneratorBase, public FunctionParse
/// whether to check subdomain ids when adding sides or not
bool _check_subdomains;

/// whether to check neighbor subdomain ids when adding sides or not
bool _check_neighbor_subdomains;

/// whether to check normals when adding sides or not
bool _check_normal;

/// A list of included subdomain ids that the side has to be part of
std::vector<subdomain_id_type> _included_ids;

/// A list of included neighbor subdomain ids
std::vector<subdomain_id_type> _included_neighbor_ids;

/// A normal vector that (if provided) is compared against side's normals
Point _normal;

Expand Down
29 changes: 29 additions & 0 deletions framework/src/meshgenerators/ParsedGenerateSideset.C
Expand Up @@ -36,6 +36,10 @@ ParsedGenerateSideset::validParams()
params.addParam<std::vector<subdomain_id_type>>(
"included_subdomain_ids",
"A set of subdomain ids whose sides will be included in the new sidesets");
params.addParam<std::vector<subdomain_id_type>>(
"included_neighbor_ids",
"A set of neighboring subdomain ids. A face is only added if the subdomain id of the "
"neighbor is in this set");
params.addParam<Point>(
"normal",
Point(),
Expand All @@ -60,10 +64,14 @@ ParsedGenerateSideset::ParsedGenerateSideset(const InputParameters & parameters)
_function(parameters.get<std::string>("combinatorial_geometry")),
_sideset_name(getParam<BoundaryName>("new_sideset_name")),
_check_subdomains(isParamValid("included_subdomain_ids")),
_check_neighbor_subdomains(isParamValid("included_neighbor_ids")),
_check_normal(parameters.isParamSetByUser("normal")),
_included_ids(_check_subdomains
? parameters.get<std::vector<SubdomainID>>("included_subdomain_ids")
: std::vector<SubdomainID>()),
_included_neighbor_ids(_check_neighbor_subdomains
? parameters.get<std::vector<SubdomainID>>("included_neighbor_ids")
: std::vector<SubdomainID>()),
_normal(getParam<Point>("normal"))
{
if (typeid(_input).name() == typeid(std::unique_ptr<DistributedMesh>).name())
Expand Down Expand Up @@ -122,6 +130,27 @@ ParsedGenerateSideset::generate()
const std::vector<Point> & normals = _fe_face->get_normals();
_fe_face->reinit(elem, side);

// check if the neighboring elems subdomain is included
if (_check_neighbor_subdomains)
{
const Elem * neighbor = elem->neighbor_ptr(side);
// if the neighbor does not exist, then skip this face; we only add sidesets
// between existing elems if _check_neighbor_subdomains is true
if (!neighbor)
continue;

subdomain_id_type curr_neighbor_subdomain = neighbor->subdomain_id();
if (std::find(_included_neighbor_ids.begin(),
_included_neighbor_ids.end(),
curr_neighbor_subdomain) == _included_neighbor_ids.end())
continue;
}

if (_check_neighbor_subdomains &&
std::find(_included_neighbor_ids.begin(), _included_neighbor_ids.end(), curr_subdomain) ==
_included_ids.end())
continue;

// check normal if requested
if (_check_normal && std::abs(1.0 - _normal * normals[0]) > _variance)
continue;
Expand Down
Binary file not shown.
@@ -0,0 +1,21 @@
[Mesh]
[./cmg]
type = CartesianMeshGenerator
dim = 2
dx = '1 1'
dy = '2 2'
subdomain_id = '0 1 0 0'
[../]

[sideset]
type = ParsedGenerateSideset
input = cmg
combinatorial_geometry = 'abs(x - 1) < 1e-6'
included_neighbor_ids = '1'
new_sideset_name = interior
[]
[]

[Outputs]
exodus = true
[]
13 changes: 13 additions & 0 deletions test/tests/meshgenerators/parsed_generate_sideset/tests
Expand Up @@ -11,4 +11,17 @@
design = 'meshgenerators/ParsedGenerateSideset.md'
issues = '#11640'
[../]

[./parsed_generate_sideset_neighbor_sub_id_test]
type = 'Exodiff'
input = 'parsed_generate_sideset_neighbor_sub_id.i'
cli_args = '--mesh-only'
exodiff = 'parsed_generate_sideset_neighbor_sub_id_in.e'
mesh_mode = 'REPLICATED'
recover = false

requirement = 'The system shall have the ability to filter by neighboring subdomain id in ParsedGenerateSideset.'
design = 'meshgenerators/ParsedGenerateSideset.md'
issues = '#15651'
[../]
[]

0 comments on commit 1409f61

Please sign in to comment.