16 #include "libmesh/elem.h" 25 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to modify");
27 "The names of the boundaries to create");
29 params.
addParam<std::vector<unsigned int>>(
"nodes",
30 "The nodes you want to be in the nodeset " 31 "(Either this parameter or \"coord\" must be " 33 params.
addParam<std::vector<std::vector<Real>>>(
36 "The nodes with coordinates you want to be in the " 37 "nodeset. Separate multple coords with ';' (Either this parameter or \"nodes\" must be " 40 "tolerance", TOLERANCE,
"The tolerance in which two nodes are considered identical");
42 "Creates a new node set and a new boundary made with the nodes the user provides.");
52 std::unique_ptr<MeshBase>
55 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
58 std::vector<BoundaryName> boundary_names = getParam<std::vector<BoundaryName>>(
"new_boundary");
59 std::vector<boundary_id_type> boundary_ids =
63 BoundaryInfo & boundary_info =
mesh->get_boundary_info();
67 for (
const auto & node_id :
getParam<std::vector<unsigned int>>(
"nodes"))
70 if (!
mesh->query_node_ptr(node_id))
73 for (
const auto & boundary_id : boundary_ids)
74 boundary_info.add_node(node_id, boundary_id);
78 const auto dim =
mesh->mesh_dimension();
80 std::unique_ptr<PointLocatorBase> locator =
mesh->sub_point_locator();
81 locator->enable_out_of_mesh_mode();
83 const auto tolerance = getParam<Real>(
"tolerance");
84 for (
const auto & c :
getParam<std::vector<std::vector<Real>>>(
"coord"))
91 " does not have enough components for a ",
99 " has too many components. Did you maybe forget to separate multiple coordinates " 102 for (
unsigned int j = 0; j < c.size(); ++j)
106 bool on_node =
false;
107 bool found_elem =
false;
108 const Elem * elem = (*locator)(p);
112 for (
unsigned int j = 0; j < elem->n_nodes(); ++j)
114 const Node * node = elem->node_ptr(j);
115 if (p.absolute_fuzzy_equals(*node, tolerance))
117 for (
const auto & boundary_id : boundary_ids)
118 boundary_info.add_node(node, boundary_id);
129 if (!
mesh->is_replicated())
136 mooseError(
"Unable to locate the following point within the domain, please check its " 144 for (
unsigned int i = 0; i < boundary_ids.size(); ++i)
145 boundary_info.nodeset_name(boundary_ids[i]) = boundary_names[i];
149 mesh->set_isnt_prepared();
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
const Parallel::Communicator & comm() const
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.
bool hasBreakMeshByBlockGenerator() const
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
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 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 ...
static InputParameters validParams()
std::string stringify(const T &t)
conversion to string
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
MeshGenerators are objects that can modify or add to an existing mesh.