15 #include "libmesh/fe_base.h" 16 #include "libmesh/mesh_generation.h" 17 #include "libmesh/mesh.h" 18 #include "libmesh/string_to_enum.h" 19 #include "libmesh/quadrature_gauss.h" 20 #include "libmesh/point_locator_base.h" 21 #include "libmesh/distributed_mesh.h" 22 #include "libmesh/elem.h" 40 "included_subdomains",
41 "Subdomain names or ids for the elements that may have their normal modified.");
45 "normal_to_align_with",
46 "Direction vector that element normals should be pointing in the same " 47 "direction as (dot product > 0)");
48 params.
addParam<std::vector<dof_id_type>>(
49 "element_ids_to_flood_from",
50 "IDs of elements to start flooding and changing the subdomains from");
55 params.
set<
bool>(
"flip_inverted_normals") =
true;
57 params.
set<
bool>(
"consider_flipped_normals") =
true;
58 params.
set<
bool>(
"_using_normal") =
true;
69 "Either a 'normal_to_align_with' or 'element_ids_to_flood_from' must be specified " 70 "to select the behavior of this mesh generator.");
73 std::unique_ptr<MeshBase>
76 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
79 auto & binfo =
mesh->get_boundary_info();
84 for (
auto & elem :
mesh->element_ptr_range())
109 for (
const auto eid :
getParam<std::vector<dof_id_type>>(
"element_ids_to_flood_from"))
111 auto elem =
mesh->elem_ptr(eid);
114 if (elem->dim() != 2)
120 flood(elem, normal, *elem, elem->subdomain_id(), *
mesh);
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
void setup(MeshBase &mesh)
Sets up various data structures.
void flood(Elem *const elem, const Point &normal, const Elem &starting_elem, const subdomain_id_type &sub_id, MeshBase &mesh)
This method implements a recursive flood routine to paint (applying an operation) to elements on 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 ...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
OrientSurfaceMeshGenerator(const InputParameters ¶meters)
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.
Point get2DElemNormal(const Elem *const elem) const
Get the normal of the 2D element.
Point _normal
if specified, then surface elements are only considered if their normal is close to this ...
static InputParameters validParams()
unsigned int _num_flipped
Keeps track of the number of element orientation flips, for output purposes.
This class will re-orient surface elements based on user-specified settings.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
registerMooseObject("MooseApp", OrientSurfaceMeshGenerator)
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
static InputParameters validParams()
std::unique_ptr< MeshBase > & _input
the mesh to add the subdomains to
std::vector< subdomain_id_type > _included_subdomain_ids
A list of included subdomain ids that the element has to be priorly a part of, extracted from the 'in...