56 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
59 std::vector<BoundaryName> boundary_names = getParam<std::vector<BoundaryName>>(
"new_boundary");
60 std::vector<boundary_id_type> boundary_ids =
64 BoundaryInfo & boundary_info =
mesh->get_boundary_info();
68 for (
const auto & node_id : getParam<std::vector<unsigned int>>(
"nodes"))
71 if (!
mesh->query_node_ptr(node_id))
74 for (
const auto & boundary_id : boundary_ids)
75 boundary_info.add_node(node_id, boundary_id);
79 const auto dim =
mesh->mesh_dimension();
81 std::unique_ptr<libMesh::PointLocatorBase> locator =
mesh->sub_point_locator();
82 locator->enable_out_of_mesh_mode();
84 const auto tolerance = getParam<Real>(
"tolerance");
85 const bool use_closest_node = getParam<bool>(
"use_closest_node");
86 const auto coords = getParam<std::vector<std::vector<Real>>>(
"coord");
87 if (use_closest_node && coords.empty())
88 paramError(
"coord",
"A coordinate should be specified to use 'use_closest_node'");
89 for (
const auto & c : coords)
96 " does not have enough components for a ",
104 " has too many components. Did you maybe forget to separate multiple coordinates "
107 for (
unsigned int j = 0; j < c.size(); ++j)
111 bool on_node =
false;
112 bool found_elem =
false;
113 const Elem * elem = (*locator)(p);
117 for (
unsigned int j = 0; j < elem->n_nodes(); ++j)
119 const Node * node = elem->node_ptr(j);
120 if (p.absolute_fuzzy_equals(*node, tolerance))
122 for (
const auto & boundary_id : boundary_ids)
123 boundary_info.add_node(node, boundary_id);
134 if (!
mesh->is_replicated())
141 if (use_closest_node && !on_node)
146 Real dmin(std::numeric_limits<Real>::max());
147 dof_id_type dmin_id(std::numeric_limits<dof_id_type>::max());
149 for (
const auto & node_iter : as_range(
mesh->local_nodes_begin(),
mesh->local_nodes_end()))
151 Real dist = (*node_iter - p).norm_sq();
155 dmin_id = node_iter->id();
160 processor_id_type dmin_proc_id;
164 const Node * node =
mesh->query_node_ptr(dmin_id);
166 for (
const auto & boundary_id : boundary_ids)
167 boundary_info.add_node(node, boundary_id);
171 mooseError(
"Unable to locate the following point within the domain, please check its "
178 "\nSet use_closest_node=true if you want to find the closest node.");
181 for (
unsigned int i = 0; i < boundary_ids.size(); ++i)
182 boundary_info.nodeset_name(boundary_ids[i]) = boundary_names[i];
184 mesh->unset_is_prepared();
185 return dynamic_pointer_cast<MeshBase>(
mesh);
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.