14 #include "libmesh/elem.h" 23 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to modify");
25 "Changes the subdomain ID of elements near the specified boundary(ies).");
28 "block_name",
"Subdomain name to set for inside/outside the bounding box (optional)");
30 "Subdomain id to set for inside/outside the bounding box");
32 params.
addParam<
bool>(
"include_nodesets",
34 "Whether to include nodesets in the boundaries. Nodesets are not sided so " 35 "elements on both sides of the nodesets will be included");
37 "Boundaries to add the layer next to");
43 _input(getMesh(
"input")),
44 _new_block_name(getParam<SubdomainName>(
"block_name")),
45 _include_nodesets(getParam<bool>(
"include_nodesets"))
49 std::unique_ptr<MeshBase>
52 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
59 *
mesh,
getParam<std::vector<BoundaryName>>(
"boundaries"),
false);
62 const auto & boundary_info =
mesh->get_boundary_info();
65 for (
const auto & elem :
mesh->element_ptr_range())
68 bool next_to_a_boundary =
false;
69 for (
const auto side : elem->side_index_range())
70 for (
const auto bid : boundary_ids)
71 if (boundary_info.has_boundary_id(elem, side, bid))
73 next_to_a_boundary =
true;
81 for (
const auto node_index : elem->node_index_range())
82 for (
const auto bid : boundary_ids)
83 if (boundary_info.has_boundary_id(elem->node_ptr(node_index), bid))
85 next_to_a_boundary =
true;
91 if (next_to_a_boundary)
98 mesh->set_isnt_prepared();
const bool _include_nodesets
Whether to consider nodesets in the boundary proximity check.
subdomain_id_type _new_block_id
Block ID to assign to the boundary layer region.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
MeshGenerator for defining a subdomain on the layer next to one or more boundaries.
std::unique_ptr< MeshBase > & _input
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.
static InputParameters validParams()
const SubdomainName _new_block_name
Block name to assign to the boundary layer region.
static InputParameters validParams()
SubdomainID getNextFreeSubdomainID(MeshBase &input_mesh)
Checks input mesh and returns max(block ID) + 1, which represents a block ID that is not currently in...
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
registerMooseObject("MooseApp", BoundaryLayerSubdomainGenerator)
MeshGenerators are objects that can modify or add to an existing mesh.
BoundaryLayerSubdomainGenerator(const InputParameters ¶meters)