15 #include "libmesh/boundary_info.h" 25 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to modify");
27 "The boundaries to be deleted / kept");
36 _input(getMesh(
"input")),
37 _boundary_names(getParam<
std::vector<BoundaryName>>(
"boundary_names"))
41 std::unique_ptr<MeshBase>
44 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
47 std::set<boundary_id_type> ids;
51 if (bid == BoundaryInfo::invalid_id)
52 paramError(
"boundary_names",
"The boundary '",
name,
"' was not found in the mesh");
57 std::set<boundary_id_type> ids_to_remove;
58 if (getParam<MooseEnum>(
"operation") ==
"keep")
60 ids_to_remove =
mesh->get_boundary_info().get_boundary_ids();
61 for (
const auto &
id : ids)
62 ids_to_remove.erase(
id);
67 for (
const auto &
id : ids_to_remove)
68 mesh->get_boundary_info().remove_id(
id);
70 mesh->set_isnt_prepared();
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
registerMooseObject("MooseApp", BoundaryDeletionGenerator)
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.
virtual std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
Gets the boundary ID associated with the given BoundaryName.
const std::string & name() const
Get the name of the class.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
const std::vector< BoundaryName > _boundary_names
The boundaries to be removed.
std::unique_ptr< MeshBase > & _input
The input mesh.
BoundaryDeletionGenerator(const InputParameters ¶meters)
MeshGenerators are objects that can modify or add to an existing mesh.