21 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to modify");
22 params.
addRequiredParam<BoundaryName>(
"boundary",
"The sideset (boundary) that will be flipped");
28 _input(getMesh(
"input")),
29 _sideset_name(getParam<BoundaryName>(
"boundary"))
33 std::unique_ptr<MeshBase>
37 BoundaryInfo & boundary_info =
_input->get_boundary_info();
39 const auto sideset_id = boundary_info.get_id_by_name(
_sideset_name);
46 std::multimap<const Elem *, std::pair<unsigned short int, boundary_id_type>> sideset_map =
47 boundary_info.get_sideset_map();
51 for (
const auto & [old_elem, id_pair] : sideset_map)
54 if (boundary_id == sideset_id)
56 const auto old_side_id = std::get<0>(id_pair);
57 const auto old_elem_id = old_elem->id();
58 const auto new_elem = old_elem->neighbor_ptr(old_side_id);
62 mooseError(
"elem " + std::to_string(old_elem_id) +
63 " does not have a neighbor through side " + std::to_string(old_side_id) +
64 " therefore it cannot be flipped");
66 const auto new_side_id = new_elem->which_neighbor_am_i(old_elem);
67 boundary_info.remove_side(old_elem, old_side_id, sideset_id);
68 boundary_info.add_side(new_elem, new_side_id, sideset_id);
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
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 ...
static InputParameters validParams()
registerMooseObject("MooseApp", FlipSidesetGenerator)
FlipSidesetGenerator(const InputParameters ¶meters)
const BoundaryName _sideset_name
Name of the sideset to flip.
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.
std::unique_ptr< MeshBase > & _input
Input mesh the operation will be applied to.
static const boundary_id_type invalid_id
MeshGenerator for flipping a sideset.
static InputParameters validParams()
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
MeshGenerators are objects that can modify or add to an existing mesh.