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" 51 _boundary_to_normal_map(
56 std::unique_ptr<MeshBase>
59 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
60 if (!
mesh->is_replicated())
61 mooseError(
"AllSideSetsByNormalsGenerator is not implemented for distributed meshes");
71 for (
const auto & elem :
mesh->element_ptr_range())
72 for (
const auto side :
make_range(elem->n_sides()))
74 const std::vector<Point> & normals =
_fe_face->get_normals();
79 const std::map<BoundaryID, RealVectorValue>::value_type * item =
nullptr;
88 flood(elem, normals[0], item->first, *
mesh);
100 mesh->set_isnt_prepared();
107 std::set<boundary_id_type>::iterator it;
registerMooseObject("MooseApp", AllSideSetsByNormalsGenerator)
std::unique_ptr< MeshBase > & _input
the mesh to add the sidesets to
boundary_id_type getNextBoundaryID()
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::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::set< boundary_id_type > _mesh_boundary_ids
A pointer to the Mesh's boundary set, this datastructure will be modified through this modifier...
static InputParameters validParams()
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
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...
This class will add sidesets to the entire mesh based on unique normals.
AllSideSetsByNormalsGenerator(const InputParameters ¶meters)
void finalize()
This method finalizes the object, setting names back in the boundary_info object and releasing memory...
static InputParameters validParams()
std::map< BoundaryID, RealVectorValue > & _boundary_to_normal_map
Mesh meta data for holding the map from boundary IDs to the normals of the corresponding boundaries...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
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...
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.