18 #include "libmesh/mesh_generation.h" 19 #include "libmesh/mesh.h" 20 #include "libmesh/string_to_enum.h" 21 #include "libmesh/quadrature_gauss.h" 22 #include "libmesh/point_locator_base.h" 23 #include "libmesh/distributed_mesh.h" 24 #include "libmesh/elem.h" 25 #include "libmesh/fe_base.h" 37 "Adds a new named sideset to the mesh for all faces matching the specified normal.");
39 "normals",
"A list of normals for which to start painting sidesets");
40 params.
addParam<
Real>(
"tolerance",
"Tolerance for comparing the face normal");
59 _normals(getParam<
std::vector<Point>>(
"normals")),
60 _boundary_to_normal_map(
65 mooseError(
"normal list and boundary list are not the same length");
70 if (normal.norm() < 1e-5)
72 normal /= normal.norm();
78 std::unique_ptr<MeshBase>
81 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
83 mooseError(
"SideSetsFromNormalsGenerator is not implemented for distributed meshes when " 84 "fixed_normal = false");
86 std::vector<BoundaryID> boundary_ids =
94 const std::vector<Point> & face_normals =
_fe_face->get_normals();
98 for (
const auto & elem :
mesh->element_ptr_range())
99 for (
const auto side :
make_range(elem->n_sides()))
101 if (elem->neighbor_ptr(side))
107 const Point & face_normal = face_normals[0];
109 for (
const auto i :
make_range(boundary_ids.size()))
118 BoundaryInfo & boundary_info =
mesh->get_boundary_info();
119 for (
const auto i :
make_range(boundary_ids.size()))
127 mesh->set_isnt_prepared();
const bool _fixed_normal
Whether to fix the normal or allow it to vary to "paint" around curves.
std::unique_ptr< MeshBase > & _input
the mesh to add the sidesets to
const Real _normal_tol
if normal is specified, then faces are only added if face_normal.normal_hat <= 1 - normal_tol where n...
bool normalsWithinTol(const Point &normal_1, const Point &normal_2, const Real &tol) const
Determines whether two normal vectors are within normal_tol of each other.
std::vector< BoundaryName > _boundary_names
The list of new boundary names.
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::vector< Point > _normals
holds the normals used to generate sidesets
bool hasBreakMeshByBlockGenerator() const
SideSetsFromNormalsGenerator(const InputParameters ¶meters)
static InputParameters validParams()
boundary_id_type BoundaryID
void flood(const Elem *elem, const Point &normal, const boundary_id_type &side_id, MeshBase &mesh)
This method implements a recursive flood routine to paint a sideset of mesh to neighboring faces give...
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.
MooseApp & _app
The MOOSE application this is associated with.
void finalize()
This method finalizes the object, setting names back in the boundary_info object and releasing memory...
registerMooseObject("MooseApp", SideSetsFromNormalsGenerator)
static InputParameters validParams()
bool _using_normal
true if only faces close to "normal" will be added
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A mesh generator to generate new sidesets from all faces matching the normal.
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
std::map< BoundaryID, RealVectorValue > & _boundary_to_normal_map
a map from the boundaries to the normals
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
std::map< boundary_id_type, std::set< const Elem * > > _visited
std::unique_ptr< libMesh::FEBase > _fe_face
void setup(MeshBase &mesh)
This method is used to construct the FE object so we can compute normals of faces.