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"))
33std::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)
53 boundary_id_type boundary_id = std::get<1>(id_pair);
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);
71 return dynamic_pointer_cast<MeshBase>(
_input);
registerMooseObject("MooseApp", FlipSidesetGenerator)
MeshGenerator for flipping a sideset.
FlipSidesetGenerator(const InputParameters ¶meters)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const BoundaryName _sideset_name
Name of the sideset to flip.
std::unique_ptr< MeshBase > & _input
Input mesh the operation will be applied to.
static InputParameters validParams()
MeshGenerators are objects that can modify or add to an existing mesh.
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 ...
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...
static const boundary_id_type invalid_id