16 #include "libmesh/mesh.h" 17 #include "libmesh/mesh_generation.h" 18 #include "libmesh/mesh_serializer.h" 19 #include "libmesh/string_to_enum.h" 20 #include "libmesh/quadrature_gauss.h" 21 #include "libmesh/point_locator_base.h" 22 #include "libmesh/enum_point_locator_type.h" 23 #include "libmesh/distributed_mesh.h" 24 #include "libmesh/elem.h" 25 #include "libmesh/fe_base.h" 26 #include "libmesh/mesh_tools.h" 37 params.
addClassDescription(
"Adds a new sideset starting at the specified point containing all " 38 "connected element faces with the same normal.");
40 "points",
"A list of points from which to start painting sidesets");
56 mooseError(
"point list and boundary list are not the same length");
60 std::unique_ptr<MeshBase>
63 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
70 std::vector<BoundaryID> boundary_ids =
77 std::unique_ptr<libMesh::PointLocatorBase> pl =
82 std::set<const Elem *> candidate_elements;
83 (*pl)(
_points[i], candidate_elements);
85 const Elem * elem_to_flood =
nullptr;
86 Point normal_to_flood;
88 for (
const Elem * elem : candidate_elements)
89 for (
const auto side :
make_range(elem->n_sides()))
91 if (elem->neighbor_ptr(side))
95 std::unique_ptr<const Elem> elem_side = elem->side_ptr(side);
97 if (elem_side->contains_point(
_points[i]))
101 const std::vector<Point> & normals =
_fe_face->get_normals();
108 mooseError(
"Two ambiguous potential sideset sources found for boundary `",
122 elem_to_flood = elem;
123 normal_to_flood = normals[0];
128 flood(elem_to_flood, normal_to_flood, boundary_ids[i], *
mesh);
132 MeshTools::libmesh_assert_valid_boundary_ids(*
mesh);
140 mesh->set_isnt_prepared();
std::unique_ptr< MeshBase > & _input
the mesh to add the sidesets to
const unsigned int invalid_uint
const Real _normal_tol
if normal is specified, then faces are only added if face_normal.normal_hat <= 1 - normal_tol where n...
static InputParameters validParams()
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.
registerMooseObject("MooseApp", SideSetsFromPointsGenerator)
std::vector< Point > _points
holds the points used to generate sidesets
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...
A mesh generator to generate new sidesets from all faces connected to points with the same normal as ...
SideSetsFromPointsGenerator(const InputParameters ¶meters)
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.
void finalize()
This method finalizes the object, setting names back in the boundary_info object and releasing memory...
static InputParameters validParams()
bool _using_normal
true if only faces close to "normal" will be added
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.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
std::map< boundary_id_type, std::set< const Elem * > > _visited
std::unique_ptr< libMesh::FEBase > _fe_face
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
void setup(MeshBase &mesh)
This method is used to construct the FE object so we can compute normals of faces.
auto index_range(const T &sizable)