34#include "libmesh/bounding_box.h"
35#include "libmesh/boundary_info.h"
36#include "libmesh/mesh_tools.h"
37#include "libmesh/parallel.h"
38#include "libmesh/mesh_communication.h"
39#include "libmesh/periodic_boundary_base.h"
40#include "libmesh/fe_base.h"
41#include "libmesh/fe_interface.h"
42#include "libmesh/mesh_communication.h"
43#include "libmesh/mesh_tools.h"
44#include "libmesh/parallel.h"
45#include "libmesh/parallel_elem.h"
46#include "libmesh/parallel_node.h"
47#include "libmesh/parallel_ghost_sync.h"
48#include "libmesh/utility.h"
49#include "libmesh/remote_elem.h"
50#include "libmesh/linear_partitioner.h"
51#include "libmesh/centroid_partitioner.h"
52#include "libmesh/parmetis_partitioner.h"
53#include "libmesh/hilbert_sfc_partitioner.h"
54#include "libmesh/morton_sfc_partitioner.h"
55#include "libmesh/edge_edge2.h"
56#include "libmesh/checkpoint_io.h"
57#include "libmesh/mesh_refinement.h"
58#include "libmesh/quadrature.h"
59#include "libmesh/boundary_info.h"
60#include "libmesh/periodic_boundaries.h"
61#include "libmesh/quadrature_gauss.h"
62#include "libmesh/point_locator_base.h"
63#include "libmesh/default_coupling.h"
64#include "libmesh/ghost_point_neighbors.h"
65#include "libmesh/fe_type.h"
66#include "libmesh/enum_to_string.h"
67#include "libmesh/elem_side_builder.h"
70#if NANOFLANN_VERSION < 0x150
75template <
typename T,
typename U>
87 MooseEnum parallel_type(
"DEFAULT REPLICATED DISTRIBUTED",
"DEFAULT");
90 "DEFAULT: Use libMesh::ReplicatedMesh unless --distributed-mesh is "
91 "specified on the command line "
92 "REPLICATED: Always use libMesh::ReplicatedMesh "
93 "DISTRIBUTED: Always use libMesh::DistributedMesh");
98 "If allow_renumbering=false, node and element numbers are kept fixed until deletion");
103 "Specifies a mesh partitioner to use when splitting the mesh for a parallel computation.");
107 "Specifies the sort direction if using the centroid partitioner. "
108 "Available options: x, y, z, radial");
110 MooseEnum patch_update_strategy(
"never always auto iteration",
"never");
112 "patch_update_strategy",
113 patch_update_strategy,
114 "How often to update the geometric search 'patch'. The default is to "
115 "never update it (which is the most efficient but could be a problem "
116 "with lots of relative motion). 'always' will update the patch for all "
117 "secondary nodes at the beginning of every timestep which might be time "
118 "consuming. 'auto' will attempt to determine at the start of which "
119 "timesteps the patch for all secondary nodes needs to be updated automatically."
120 "'iteration' updates the patch at every nonlinear iteration for a "
121 "subset of secondary nodes for which penetration is not detected. If there "
122 "can be substantial relative motion between the primary and secondary surfaces "
123 "during the nonlinear iterations within a timestep, it is advisable to use "
124 "'iteration' option to ensure accurate contact detection.");
128 "construct_node_list_from_side_list",
130 "Whether or not to generate nodesets from the sidesets (currently often required).");
132 "displace_node_list_by_side_list",
134 "Whether to renumber existing nodesets with ids matching sidesets that "
135 "lack names matching sidesets, when constructing nodesets from sidesets via the default "
136 "'construct_node_list_from_side_list' option, rather than to merge them with the sideset.");
138 "patch_size", 40,
"The number of nodes to consider in the NearestNode neighborhood.");
139 params.
addParam<
unsigned int>(
"ghosting_patch_size",
140 "The number of nearest neighbors considered "
141 "for ghosting purposes when 'iteration' "
142 "patch update strategy is used. Default is "
144 params.
addParam<
unsigned int>(
"max_leaf_size",
146 "The maximum number of points in each leaf of the KDTree used in "
147 "the nearest neighbor search. As the leaf size becomes larger,"
148 "KDTree construction becomes faster but the nearest neighbor search"
151 params.
addParam<
bool>(
"build_all_side_lowerd_mesh",
153 "True to build the lower-dimensional mesh for all sides.");
155 params.
addParam<
bool>(
"skip_refine_when_use_split",
157 "True to skip uniform refinements when using a pre-split mesh.");
159 params.
addParam<std::vector<SubdomainID>>(
161 "The listed subdomain ids will be assumed valid for the mesh. This permits setting up "
162 "subdomain restrictions for subdomains initially containing no elements, which can occur, "
163 "for example, in additive manufacturing simulations which dynamically add and remove "
164 "elements. Names for this subdomains may be provided using add_subdomain_names. In this case "
165 "this list and add_subdomain_names must contain the same number of items.");
166 params.
addParam<std::vector<SubdomainName>>(
167 "add_subdomain_names",
168 "The listed subdomain names will be assumed valid for the mesh. This permits setting up "
169 "subdomain restrictions for subdomains initially containing no elements, which can occur, "
170 "for example, in additive manufacturing simulations which dynamically add and remove "
171 "elements. IDs for this subdomains may be provided using add_subdomain_ids. Otherwise IDs "
172 "are automatically assigned. In case add_subdomain_ids is set too, both lists must contain "
173 "the same number of items.");
175 params.
addParam<std::vector<BoundaryID>>(
177 "The listed sideset ids will be assumed valid for the mesh. This permits setting up boundary "
178 "restrictions for sidesets initially containing no sides. Names for this sidesets may be "
179 "provided using add_sideset_names. In this case this list and add_sideset_names must contain "
180 "the same number of items.");
181 params.
addParam<std::vector<BoundaryName>>(
183 "The listed sideset names will be assumed valid for the mesh. This permits setting up "
184 "boundary restrictions for sidesets initially containing no sides. Ids for this sidesets may "
185 "be provided using add_sideset_ids. In this case this list and add_sideset_ids must contain "
186 "the same number of items.");
188 params.
addParam<std::vector<BoundaryID>>(
190 "The listed nodeset ids will be assumed valid for the mesh. This permits setting up boundary "
191 "restrictions for node initially containing no sides. Names for this nodesets may be "
192 "provided using add_nodeset_names. In this case this list and add_nodeset_names must contain "
193 "the same number of items.");
194 params.
addParam<std::vector<BoundaryName>>(
196 "The listed nodeset names will be assumed valid for the mesh. This permits setting up "
197 "boundary restrictions for nodesets initially containing no sides. Ids for this nodesets may "
198 "be provided using add_nodesets_ids. In this case this list and add_nodesets_ids must "
199 "contain the same number of items.");
213 params.
addParamNamesToGroup(
"patch_update_strategy patch_size max_leaf_size",
"Geometric search");
215 "add_sideset_names add_nodeset_ids add_nodeset_names",
216 "Pre-declaration of future mesh sub-entities");
218 "displace_node_list_by_side_list",
219 "Automatic definition of mesh element sides entities");
230 _use_distributed_mesh(false),
231 _distribution_overridden(false),
232 _parallel_type_overridden(false),
234 _partitioner_name(getParam<
MooseEnum>(
"partitioner")),
235 _partitioner_overridden(false),
236 _custom_partitioner_requested(false),
237 _uniform_refine_level(0),
238 _skip_refine_when_use_split(getParam<bool>(
"skip_refine_when_use_split")),
239 _skip_deletion_repartition_after_refine(false),
241 _patch_size(getParam<unsigned
int>(
"patch_size")),
242 _ghosting_patch_size(isParamValid(
"ghosting_patch_size")
243 ? getParam<unsigned
int>(
"ghosting_patch_size")
245 _max_leaf_size(getParam<unsigned
int>(
"max_leaf_size")),
246 _patch_update_strategy(
247 getParam<
MooseEnum>(
"patch_update_strategy").getEnum<
Moose::PatchUpdateType>()),
248 _regular_orthogonal_mesh(false),
249 _is_split(getParam<bool>(
"_is_split")),
250 _allow_recovery(true),
251 _construct_node_list_from_side_list(getParam<bool>(
"construct_node_list_from_side_list")),
252 _displace_node_list_by_side_list(getParam<bool>(
"displace_node_list_by_side_list")),
254 _allow_remote_element_removal(true),
255 _need_ghost_ghosted_boundaries(true),
256 _is_displaced(false),
259 _rz_coord_axis(getParam<
MooseEnum>(
"rz_coord_axis")),
260 _coord_system_set(false),
261 _doing_p_refinement(false)
264 mooseError(
"Ghosting patch size parameter has to be set in the mesh block "
265 "only when 'iteration' patch update strategy is used.");
271 "You set both 'Mesh/block' and 'Mesh/coord_block'. The value of "
272 "'Mesh/coord_block' will be used.");
279 if (getParam<bool>(
"build_all_side_lowerd_mesh"))
285#ifdef MOOSE_KOKKOS_ENABLED
287 _kokkos_mesh = std::make_unique<Moose::Kokkos::Mesh>(*
this);
295 _built_from_other_mesh(true),
296 _parallel_type(other_mesh._parallel_type),
297 _use_distributed_mesh(other_mesh._use_distributed_mesh),
298 _distribution_overridden(other_mesh._distribution_overridden),
299 _parallel_type_overridden(other_mesh._parallel_type_overridden),
300 _mesh(other_mesh.getMesh().clone()),
301 _partitioner_name(other_mesh._partitioner_name),
302 _partitioner_overridden(other_mesh._partitioner_overridden),
303 _custom_partitioner_requested(other_mesh._custom_partitioner_requested),
304 _uniform_refine_level(other_mesh.uniformRefineLevel()),
305 _skip_refine_when_use_split(other_mesh._skip_refine_when_use_split),
306 _skip_deletion_repartition_after_refine(other_mesh._skip_deletion_repartition_after_refine),
307 _is_nemesis(other_mesh._is_nemesis),
308 _mesh_subdomains(other_mesh._mesh_subdomains),
309 _mesh_boundary_ids(other_mesh._mesh_boundary_ids),
310 _mesh_sideset_ids(other_mesh._mesh_sideset_ids),
311 _mesh_nodeset_ids(other_mesh._mesh_nodeset_ids),
312 _patch_size(other_mesh._patch_size),
313 _ghosting_patch_size(other_mesh._ghosting_patch_size),
314 _max_leaf_size(other_mesh._max_leaf_size),
315 _patch_update_strategy(other_mesh._patch_update_strategy),
316 _regular_orthogonal_mesh(false),
317 _is_split(other_mesh._is_split),
318 _allow_recovery(other_mesh._allow_recovery),
319 _construct_node_list_from_side_list(other_mesh._construct_node_list_from_side_list),
320 _displace_node_list_by_side_list(other_mesh._displace_node_list_by_side_list),
321 _need_delete(other_mesh._need_delete),
322 _allow_remote_element_removal(other_mesh._allow_remote_element_removal),
323 _need_ghost_ghosted_boundaries(other_mesh._need_ghost_ghosted_boundaries),
324 _coord_sys(other_mesh._coord_sys),
325 _rz_coord_axis(other_mesh._rz_coord_axis),
326 _subdomain_id_to_rz_coord_axis(other_mesh._subdomain_id_to_rz_coord_axis),
327 _coord_system_set(other_mesh._coord_system_set),
328 _provided_coord_blocks(other_mesh._provided_coord_blocks),
329 _doing_p_refinement(other_mesh._doing_p_refinement)
332 "The mesh being cloned from must already be fully prepared; we rely on that to "
333 "rebuild our own prepare()-derived caches below");
336 for (std::size_t i = 0; i <
_bounds.size(); ++i)
339 for (std::size_t j = 0; j <
_bounds[i].size(); ++j)
345#ifdef MOOSE_KOKKOS_ENABLED
347 _kokkos_mesh = std::make_unique<Moose::Kokkos::Mesh>(*
this);
401 TIME_SECTION(
"prepare", 2,
"Preparing Mesh",
true);
403 parallel_object_only();
405 mooseAssert(
_mesh,
"The MeshBase has not been constructed");
409 getMesh().allow_renumbering(
false);
411 if (!
_mesh->is_prepared())
413 _mesh->complete_preparation();
422 for (
const auto &
elem :
getMesh().element_ptr_range())
429 const auto & add_subdomain_id = getParam<std::vector<SubdomainID>>(
"add_subdomain_ids");
434 const auto add_subdomain =
435 getParam<SubdomainID, SubdomainName>(
"add_subdomain_ids",
"add_subdomain_names");
436 for (
const auto & [sub_id, sub_name] : add_subdomain)
447 const auto & add_subdomain_names = getParam<std::vector<SubdomainName>>(
"add_subdomain_names");
450 subdomain_id_type offset = 0;
455 for (
const SubdomainName & sub_name : add_subdomain_names)
458 if (
getSubdomainID(sub_name) != libMesh::Elem::invalid_subdomain_id)
460 const auto sub_id = ++offset;
472 const std::set<BoundaryID> & local_bids =
getMesh().get_boundary_info().get_boundary_ids();
475 const std::set<BoundaryID> & local_node_bids =
476 getMesh().get_boundary_info().get_node_boundary_ids();
479 const std::set<BoundaryID> & local_side_bids =
480 getMesh().get_boundary_info().get_side_boundary_ids();
485 auto add_sets = [
this](
const bool sidesets,
auto & set_ids)
487 const std::string
type = sidesets ?
"sideset" :
"nodeset";
488 const std::string id_param =
"add_" +
type +
"_ids";
493 const auto & add_ids = getParam<std::vector<BoundaryID>>(id_param);
495 set_ids.insert(add_ids.begin(), add_ids.end());
498 const auto & add_names = getParam<std::vector<BoundaryName>>(
name_param);
499 mooseAssert(add_names.size() == add_ids.size(),
500 "Id and name sets must be the same size when adding.");
501 for (
const auto i : index_range(add_ids))
508 const auto & add_names = getParam<std::vector<BoundaryName>>(
name_param);
513 boundary_id_type offset = 0;
514 if (!mesh_ids.empty())
515 offset = *mesh_ids.rbegin();
520 for (
const auto &
name : add_names)
525 const auto id = ++offset;
553 "Trying to set coordinate system type information based on the user input file, but "
554 "the coordinate system type information has already been set programmatically! "
555 "Either remove your coordinate system type information from the input file, or contact "
556 "your application developer");
563 const auto rz_coord_blocks = getParam<std::vector<SubdomainName>>(
"rz_coord_blocks");
564 const auto rz_coord_origins = getParam<std::vector<Point>>(
"rz_coord_origins");
565 const auto rz_coord_directions = getParam<std::vector<RealVectorValue>>(
"rz_coord_directions");
566 if (rz_coord_origins.size() == rz_coord_blocks.size() &&
567 rz_coord_directions.size() == rz_coord_blocks.size())
569 std::vector<std::pair<Point, RealVectorValue>> rz_coord_axes;
570 for (
unsigned int i = 0; i < rz_coord_origins.size(); ++i)
571 rz_coord_axes.push_back(std::make_pair(rz_coord_origins[i], rz_coord_directions[i]));
576 mooseError(
"The parameter 'rz_coord_axis' may not be provided if 'rz_coord_blocks', "
577 "'rz_coord_origins', and 'rz_coord_directions' are provided.");
580 mooseError(
"The parameters 'rz_coord_blocks', 'rz_coord_origins', and "
581 "'rz_coord_directions' must all have the same size.");
585 mooseError(
"If any of the parameters 'rz_coord_blocks', 'rz_coord_origins', and "
586 "'rz_coord_directions' are provided, then all must be provided.");
601 mooseDeprecated(
"MooseMesh::prepare(const MeshBase *) is deprecated, please use the "
602 "no-argument MooseMesh::prepare() instead");
603 mooseAssert(!mesh_to_clone,
"Cloning a mesh_to_clone is no longer supported by prepare()");
614 mooseAssert(
_node_to_elem_map.empty(),
"If it hasn't been built, it better well be empty");
627 TIME_SECTION(
"update", 3,
"Updating Mesh",
true);
641 for (
const auto &
elem :
getMesh().active_local_element_ptr_range())
656#ifdef MOOSE_KOKKOS_ENABLED
672 if (!
mesh.is_serial())
674 "Hybrid finite element method must use replicated mesh.\nCurrently lower-dimensional mesh "
675 "does not support mesh re-partitioning and a debug assertion being hit related with "
676 "neighbors of lower-dimensional element, with distributed mesh.");
679 if (!
mesh.is_prepared())
680 mesh.find_neighbors();
683 unsigned int max_n_sides = 0;
686 std::set<Elem *> deleteable_elems;
687 for (
auto &
elem :
mesh.element_ptr_range())
690 deleteable_elems.insert(
elem);
691 else if (
elem->n_sides() > max_n_sides)
692 max_n_sides =
elem->n_sides();
694 for (
auto &
elem : deleteable_elems)
703 mesh.comm().max(max_n_sides);
705 deleteable_elems.clear();
708 std::set<int> interior_side_types;
709 std::set<int> boundary_side_types;
710 for (
const auto &
elem :
mesh.active_element_ptr_range())
711 for (
const auto side :
elem->side_index_range())
713 Elem * neig =
elem->neighbor_ptr(side);
714 std::unique_ptr<Elem> side_elem(
elem->build_side_ptr(side));
716 interior_side_types.insert(side_elem->type());
718 boundary_side_types.insert(side_elem->type());
720 mesh.comm().set_union(interior_side_types);
721 mesh.comm().set_union(boundary_side_types);
724 std::map<ElemType, SubdomainID> interior_block_ids;
725 std::map<ElemType, SubdomainID> boundary_block_ids;
727 auto id = libMesh::Elem::invalid_subdomain_id - 2;
728 for (
const auto & tpid : interior_side_types)
730 const auto type = ElemType(tpid);
731 mesh.set_subdomain_name(
733 interior_block_ids[
type] = id;
736 mooseError(
"Trying to add a mesh block with id ",
id,
" that has existed in the mesh");
740 for (
const auto & tpid : boundary_side_types)
742 const auto type = ElemType(tpid);
743 mesh.set_subdomain_name(
745 boundary_block_ids[
type] = id;
748 mooseError(
"Trying to add a mesh block with id ",
id,
" that has existed in the mesh");
753 dof_id_type max_elem_id =
mesh.max_elem_id();
754 unique_id_type max_unique_id =
mesh.parallel_max_unique_id();
756 std::vector<Elem *> side_elems;
758 for (
const auto &
elem :
mesh.active_element_ptr_range())
761 if (
elem->interior_parent())
764 for (
const auto side :
elem->side_index_range())
766 Elem * neig =
elem->neighbor_ptr(side);
768 bool build_side =
false;
773 mooseAssert(!neig->is_remote(),
"We error if the mesh is not serial");
776 else if (neig->level() ==
elem->level() &&
elem->id() < neig->id())
782 std::unique_ptr<Elem> side_elem(
elem->build_side_ptr(side));
785 side_elem->processor_id() =
elem->processor_id();
789 side_elem->subdomain_id() = interior_block_ids.at(side_elem->type());
791 side_elem->subdomain_id() = boundary_block_ids.at(side_elem->type());
794 side_elem->set_id(max_elem_id +
elem->id() * max_n_sides + side);
795 side_elem->set_unique_id(max_unique_id +
elem->id() * max_n_sides + side);
800 side_elem->set_interior_parent(
elem);
802 side_elems.push_back(side_elem.release());
805 auto pair = std::make_pair(
elem, side);
806 auto link = std::make_pair(pair, side_elems.back());
807 auto ilink = std::make_pair(side_elems.back(), side);
818 for (
auto &
elem : side_elems)
823 const bool skip_partitioning_old =
mesh.skip_partitioning();
824 mesh.skip_partitioning(
true);
826 mesh.allow_find_neighbors(
false);
827 mesh.prepare_for_use();
828 mesh.skip_partitioning(skip_partitioning_old);
834 mooseDeprecated(
"MooseMesh::node() is deprecated, please use MooseMesh::nodeRef() instead");
841 mooseDeprecated(
"MooseMesh::node() is deprecated, please use MooseMesh::nodeRef() instead");
849 mooseAssert(node_ptr,
"Missing node");
874 if (i >
getMesh().max_node_id())
879 auto & node_ptr = it->second;
880 mooseAssert(node_ptr,
"Uninitialized quadrature node");
884 return getMesh().query_node_ptr(i);
896 TIME_SECTION(
"meshChanged", 3,
"Updating Because Mesh Changed");
926 TIME_SECTION(
"cacheChangedLists", 5,
"Caching Changed Lists");
928 ConstElemRange elem_range(
getMesh().local_elements_begin(),
getMesh().local_elements_end(), 1);
953const std::vector<const Elem *> &
958 return elem_to_child_pair->second;
964 TIME_SECTION(
"updateActiveSemiLocalNodeRange", 5,
"Updating ActiveSemiLocalNode Range");
970 for (
const auto &
elem : *active_local_elems)
972 for (
unsigned int n = 0; n <
elem->n_nodes(); ++n)
979 Node *
node =
const_cast<Node *
>(
elem->node_ptr(n));
986 for (
const auto & ghost_elem_id : ghosted_elems)
989 for (
unsigned int n = 0; n <
elem->n_nodes(); n++)
1038 TIME_SECTION(
"buildNodeList", 5,
"Building Node List");
1042 auto bc_tuples =
getMesh().get_boundary_info().build_node_list();
1044 int n = bc_tuples.size();
1047 for (
const auto & t : bc_tuples)
1049 auto node_id = std::get<0>(t);
1050 auto bc_id = std::get<1>(t);
1078 for (
auto &
elem : as_range(
mesh.local_elements_begin(),
mesh.local_elements_end()))
1083 for (
unsigned int side = 0; side <
elem->n_sides(); ++side)
1095 unsigned int n =
getMesh().n_elem_integers() + 1;
1103 _max_ids.resize(n, std::numeric_limits<dof_id_type>::min());
1104 _min_ids.resize(n, std::numeric_limits<dof_id_type>::max());
1106 for (
const auto &
elem :
getMesh().active_local_element_ptr_range())
1107 for (
unsigned int i = 0; i < n; ++i)
1109 auto id = (i == n - 1 ?
elem->subdomain_id() :
elem->get_extra_integer(i));
1115 for (
unsigned int j = 0; j < n; ++j)
1117 auto idj = (j == n - 1 ?
elem->subdomain_id() :
elem->get_extra_integer(j));
1123 for (
unsigned int i = 0; i < n; ++i)
1133std::unordered_map<dof_id_type, std::set<dof_id_type>>
1138 if (!mesh_base.has_elem_integer(from_id_name))
1139 mooseError(
"Mesh does not have the element integer name '", from_id_name,
"'");
1140 if (!mesh_base.has_elem_integer(to_id_name))
1141 mooseError(
"Mesh does not have the element integer name '", to_id_name,
"'");
1143 const auto id1 = mesh_base.get_elem_integer_index(from_id_name);
1144 const auto id2 = mesh_base.get_elem_integer_index(to_id_name);
1146 std::unordered_map<dof_id_type, std::set<dof_id_type>> id_map;
1148 id_map[
id] = std::set<dof_id_type>();
1150 for (
const auto &
elem : mesh_base.active_local_element_ptr_range())
1151 id_map[
elem->get_extra_integer(id1)].insert(
elem->get_extra_integer(id2));
1153 for (
auto & [
id, ids] : id_map)
1162std::set<dof_id_type>
1165 std::set<dof_id_type> unique_ids;
1167 for (
auto &
id : pair.second)
1168 unique_ids.insert(
id);
1172std::set<dof_id_type>
1175 std::set<dof_id_type> unique_ids;
1176 for (
auto & blk : blks)
1180 mooseError(
"Block ", blk,
" is not available on the mesh");
1182 for (
auto & mid : it->second)
1183 unique_ids.insert(mid);
1191 TIME_SECTION(
"buildBndElemList", 5,
"Building Boundary Elements List");
1195 auto bc_tuples =
getMesh().get_boundary_info().build_active_side_list();
1197 int n = bc_tuples.size();
1200 for (
const auto & t : bc_tuples)
1202 auto elem_id = std::get<0>(t);
1203 auto side_id = std::get<1>(t);
1204 auto bc_id = std::get<2>(t);
1211std::unordered_map<dof_id_type, std::vector<dof_id_type>> &
1226 TIME_SECTION(
"nodeToElemMap", 5,
"Building Node To Elem Map");
1230 for (
const auto &
elem :
getMesh().active_element_ptr_range())
1231 for (
unsigned int n = 0; n <
elem->n_nodes(); n++)
1240const std::unordered_map<dof_id_type, std::vector<dof_id_type>> &
1246const ConstElemRange *
1249 return &
const_cast<const MeshBase &
>(
getMesh()).active_local_element_stored_range();
1257 TIME_SECTION(
"getActiveNodeRange", 5);
1260 std::make_unique<NodeRange>(
getMesh().active_nodes_begin(),
getMesh().active_nodes_end());
1270 "_active_semilocal_node_range has not been created yet!");
1280 TIME_SECTION(
"getLocalNodeRange", 5);
1294 TIME_SECTION(
"getBoundaryNodeRange", 5);
1307 TIME_SECTION(
"getBoundaryElementRange", 5);
1315const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
1319 "use MooseMesh::getBoundariesToActiveSemiLocalElemIds");
1323const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
1329std::unordered_set<dof_id_type>
1336 return std::unordered_set<dof_id_type>{};
1340std::unordered_set<dof_id_type>
1344 std::unordered_set<dof_id_type> neighbor_elems;
1347 const auto & [elem_ptr, elem_side, elem_bid] = *bnd_elem;
1348 if (elem_bid == bid)
1350 const auto * neighbor = elem_ptr->neighbor_ptr(elem_side);
1355 if (neighbor->active())
1356 neighbor_elems.insert(neighbor->id());
1359 std::vector<const Elem *> family;
1360 neighbor->active_family_tree_by_neighbor(family, elem_ptr);
1361 for (
const auto & child_neighbor : family)
1362 neighbor_elems.insert(child_neighbor->id());
1368 return neighbor_elems;
1373 const std::set<SubdomainID> & blk_group)
const
1375 mooseAssert(
_bnd_elem_range,
"Boundary element range is not initialized");
1381 bool crosses_subdomains =
false;
1386 const auto & [elem_ptr, elem_side, elem_bid] = *bnd_elem;
1387 if (elem_bid == bid && elem_ptr->processor_id() ==
processor_id())
1390 if (blk_group.find(elem_ptr->subdomain_id()) != blk_group.end())
1392 const auto *
const neighbor = elem_ptr->neighbor_ptr(elem_side);
1396 mooseError(
"Insufficient level of geometrical ghosting to determine "
1397 "if a boundary is internal to the mesh");
1403 if (blk_group.find(neighbor->subdomain_id()) != blk_group.end())
1405 crosses_subdomains =
true;
1412 comm().
max(crosses_subdomains);
1413 return !crosses_subdomains;
1419 TIME_SECTION(
"cacheInfo", 3);
1428 ConstElemRange all_elems(
mesh.elements_begin(),
mesh.elements_end(), 1);
1432 ConstElemRange local_elems(
1433 mesh.active_local_elements_begin(),
mesh.active_local_elements_end(), 1);
1441 for (
const auto blk_id :
mesh.get_mesh_subdomains())
1444 _higher_d_elem_side_to_lower_d_elem = std::move(ci._higher_d_elem_side_to_lower_d_elem);
1445 _lower_d_elem_to_higher_d_elem_side = std::move(ci._lower_d_elem_to_higher_d_elem_side);
1446 _lower_d_interior_blocks = std::move(ci._lower_d_interior_blocks);
1447 _lower_d_boundary_blocks = std::move(ci._lower_d_boundary_blocks);
1448 _neighbor_subdomain_boundary_ids = std::move(csi._neighbor_subdomain_boundary_ids);
1450 _sub_to_data.clear();
1451 for (
auto & [
id, subs] : csi._neighbor_subs)
1452 _sub_to_data[id].neighbor_subs =
std::move(subs);
1453 for (
auto & [
id, bids] : csi._sub_boundary_ids)
1454 _sub_to_data[id].boundary_ids =
std::move(bids);
1456 _communicator.set_union(_lower_d_interior_blocks);
1457 _communicator.set_union(_lower_d_boundary_blocks);
1459 for (
const auto blk_id : _mesh_subdomains)
1461 auto & sub_data = _sub_to_data[blk_id];
1462 _communicator.set_union(sub_data.neighbor_subs);
1463 _communicator.set_union(sub_data.boundary_ids);
1464 _communicator.set_union(_neighbor_subdomain_boundary_ids[blk_id]);
1468const std::set<SubdomainID> &
1475 mooseError(
"Unable to find node: ",
node.id(),
" in any block list.");
1476 return getMesh().get_mesh_subdomains();
1486 mooseError(
"Unable to find node: ",
node.id(),
" in any block list.");
1568 for (
const auto &
node :
getMesh().node_ptr_range())
1572 Node *
node =
nullptr;
1573 for (
unsigned int i = 0; i <
_node_map.size(); ++i)
1575 if (p.relative_fuzzy_equals(*
_node_map[i], tol))
1581 if (
node ==
nullptr)
1587 mooseAssert(
node !=
nullptr,
"Node is NULL");
1593 const unsigned short int side,
1594 const unsigned int qp,
1596 const Point & point)
1610 dof_id_type max_id = std::numeric_limits<unsigned int>::max() - 100;
1613 if (new_id <=
getMesh().max_node_id())
1614 mooseError(
"Quadrature node id collides with existing node id!");
1616 qnode =
new Node(point, new_id);
1642 const unsigned short int side,
1643 const unsigned int qp)
1647 "Elem has no quadrature nodes!");
1650 "Side has no quadrature nodes!");
1653 "qp not found on side!");
1675 if (boundary_name ==
"ANY_BOUNDARY_ID")
1676 mooseError(
"Please use getBoundaryIDs() when passing \"ANY_BOUNDARY_ID\"");
1703std::vector<BoundaryID>
1705 bool generate_unknown)
const
1717std::vector<SubdomainID>
1723std::set<SubdomainID>
1731 const SubdomainName & name,
1732 const bool synchronous)
1740 const SubdomainName & name,
1741 const bool synchronous)
1743 mooseAssert(
name !=
"ANY_BLOCK_ID",
"Cannot set subdomain name to 'ANY_BLOCK_ID'");
1744 mesh.set_subdomain_name(subdomain_id,
name, synchronous);
1750 return getMesh().subdomain_name(subdomain_id);
1753std::vector<SubdomainName>
1756 std::vector<SubdomainName> names(subdomain_ids.size());
1758 for (
unsigned int i = 0; i < subdomain_ids.size(); i++)
1767 BoundaryInfo & boundary_info =
getMesh().get_boundary_info();
1770 if (boundary_info.get_side_boundary_ids().count(boundary_id))
1771 boundary_info.sideset_name(boundary_id) =
name;
1773 boundary_info.nodeset_name(boundary_id) =
name;
1779 const BoundaryInfo & boundary_info =
getMesh().get_boundary_info();
1782 if (boundary_info.get_side_boundary_ids().count(boundary_id))
1783 return boundary_info.get_sideset_name(boundary_id);
1785 return boundary_info.get_nodeset_name(boundary_id);
1792 return name.size() ?
name : std::to_string(boundary_id);
1801 return *(item.first);
1806 unsigned int var_number,
1809 TIME_SECTION(
"buildPeriodicNodeMap", 5);
1812 periodic_node_map.clear();
1815 std::vector<PeriodicNodeInfo> periodic_nodes;
1816 for (
const auto & t :
getMesh().get_boundary_info().build_node_list())
1819 auto node =
_mesh->node_ptr(std::get<0>(t));
1820 mooseAssert(
node !=
nullptr,
1821 "libMesh::BoundaryInfo::build_node_list() returned an ID for a non-existing node");
1822 auto bc_id = std::get<1>(t);
1823 periodic_nodes.emplace_back(
node, bc_id);
1827 std::sort(periodic_nodes.begin(),
1828 periodic_nodes.end(),
1830 { return a.second > b.second; });
1833 using KDTreeType = nanoflann::KDTreeSingleIndexAdaptor<
1834 nanoflann::L2_Simple_Adaptor<Real, PointListAdaptor<PeriodicNodeInfo>, Real, std::size_t>,
1838 const unsigned int max_leaf_size = 20;
1841 auto kd_tree = std::make_unique<KDTreeType>(
1842 LIBMESH_DIM, point_list, nanoflann::KDTreeSingleIndexAdaptorParams(max_leaf_size));
1843 mooseAssert(kd_tree !=
nullptr,
"KDTree was not properly initialized.");
1844 kd_tree->buildIndex();
1848 std::vector<nanoflann::ResultItem<std::size_t, Real>> ret_matches;
1852 BoundaryID current_bc_id = BoundaryInfo::invalid_id;
1853 for (
auto & pair : periodic_nodes)
1856 if (pair.second != current_bc_id)
1858 current_bc_id = pair.second;
1859 periodic = pbs->
boundary(current_bc_id);
1869 ret_matches.clear();
1872 const auto id = pair.first->id();
1878 kd_tree->radiusSearch(&(search_point)(0),
libMesh::TOLERANCE, ret_matches, search_params);
1879 for (
auto & match_pair : ret_matches)
1881 const auto & match = periodic_nodes[match_pair.first];
1884 periodic_node_map.emplace(
id, match.first->id());
1891 unsigned int var_number,
1894 TIME_SECTION(
"buildPeriodicNodeSets", 5);
1896 periodic_node_sets.clear();
1899 for (
const auto & t :
getMesh().get_boundary_info().build_node_list())
1901 auto node_id = std::get<0>(t);
1902 auto bc_id = std::get<1>(t);
1905 if (periodic_node_sets.find(bc_id) != periodic_node_sets.end())
1906 periodic_node_sets[bc_id].insert(node_id);
1911 periodic_node_sets[bc_id].insert(node_id);
1919 TIME_SECTION(
"detectOrthogonalDimRanges", 5);
1924 std::vector<Real> min(3, std::numeric_limits<Real>::max());
1925 std::vector<Real> max(3, std::numeric_limits<Real>::min());
1926 unsigned int dim =
getMesh().mesh_dimension();
1929 for (
const auto &
node :
getMesh().node_ptr_range())
1934 if ((*
node)(i) < min[i])
1935 min[i] = (*node)(i);
1936 if ((*
node)(i) > max[i])
1937 max[i] = (*node)(i);
1945 std::vector<bool> extreme_matches(8,
false);
1946 std::vector<unsigned int> comp_map(3);
1947 for (
const auto &
node :
getMesh().node_ptr_range())
1950 unsigned int coord_match = 0;
1954 if (std::abs((*
node)(i)-min[i]) < tol)
1959 else if (std::abs((*
node)(i)-max[i]) < tol)
1966 if (coord_match == LIBMESH_DIM)
1969 extreme_matches[comp_map[
X] * 4 + comp_map[
Y] * 2 + comp_map[
Z]] =
true;
1974 this->
comm().
max(extreme_matches);
1975 if (std::count(extreme_matches.begin(), extreme_matches.end(),
true) == (1 <<
dim))
1993 TIME_SECTION(
"detectPairedSidesets", 5);
2007 const unsigned int mesh_dim =
getMesh().mesh_dimension();
2010 static constexpr std::array<std::size_t, 3> unit_dims{0, 1, 2};
2012 static const std::array<std::string, 3> unit_dim_names{
"x",
"y",
"z"};
2018 std::array<std::array<std::array<std::set<BoundaryID>, 2>, 3>, 3> ids{};
2021 std::array<std::unique_ptr<FEBase>, 3> fe_faces{};
2022 std::array<std::unique_ptr<libMesh::QGauss>, 3> qfaces{};
2023 for (
const auto side_dim : make_range(mesh_dim))
2027 qfaces[side_dim] = std::unique_ptr<libMesh::QGauss>(
new libMesh::QGauss(side_dim, CONSTANT));
2030 fe_faces[side_dim] = FEBase::build(side_dim + 1, FEType(FIRST,
libMesh::LAGRANGE));
2031 fe_faces[side_dim]->attach_quadrature_rule(qfaces[side_dim].get());
2032 fe_faces[side_dim]->get_normals();
2036 const auto & boundary_info =
getMesh().get_boundary_info();
2038 std::vector<boundary_id_type> face_ids;
2041 std::set<unsigned int> side_dims;
2045 for (
auto &
elem : as_range(
getMesh().level_elements_begin(0),
getMesh().level_elements_end(0)))
2048 if (!
elem->on_boundary())
2051 const auto side_dim =
elem->dim() - 1;
2052 side_dims.insert(side_dim);
2055 for (
const auto s :
elem->side_index_range())
2056 if (!
elem->neighbor_ptr(s))
2059 fe_faces[side_dim]->reinit(
elem, s);
2060 const auto & normal = fe_faces[side_dim]->get_normals()[0];
2066 boundary_info.boundary_ids(
elem, s, face_ids);
2069 for (
const auto unit_dim : unit_dims)
2073 nonzero_dims[unit_dim] =
true;
2075 for (
const auto plus : {
false,
true})
2079 ids[side_dim][unit_dim][plus].insert(face_ids.begin(), face_ids.end());
2099 std::vector<std::tuple<unsigned int, unsigned int, unsigned char, boundary_id_type>> id_data;
2100 for (
const auto side_dim : side_dims)
2101 for (
const auto unit_dim : unit_dims)
2102 for (
const auto plus : {
false,
true})
2103 for (
const auto bd : ids[side_dim][unit_dim][plus])
2104 id_data.emplace_back(side_dim, unit_dim, plus, bd);
2106 for (
const auto & [side_dim, unit_dim, plus_char, bd] : id_data)
2107 ids[side_dim][unit_dim][
bool(plus_char)].insert(bd);
2110 for (
auto & entry : nonzero_dims)
2118 std::ostringstream oss_found, oss_missing;
2119 for (
const auto side_dim : side_dims)
2121 for (
const auto unit_dim : unit_dims)
2122 if (nonzero_dims[unit_dim])
2124 const auto & unit_name = unit_dim_names[unit_dim];
2125 const auto & minus = ids[side_dim][unit_dim][
false];
2126 const auto & plus = ids[side_dim][unit_dim][
true];
2128 if (minus.size() == 1 && plus.size() == 1)
2130 const auto get_boundary_name = [
this](
const auto id)
2133 return name.size() ?
name : std::to_string(
id);
2136 oss_found <<
"\n " << side_dim + 1 <<
"D " << unit_name
2137 <<
"-direction: " << get_boundary_name(*minus.begin()) <<
" <-> "
2138 << get_boundary_name(*plus.begin());
2139 _paired_boundary->emplace_back(std::make_pair(*minus.begin(), *plus.begin()));
2142 oss_missing <<
"\n " << side_dim + 1 <<
"D -" << unit_name <<
"/+" << unit_name
2143 <<
": Found " << minus.size() <<
" -" << unit_name <<
" boundaries and "
2144 << plus.size() <<
" +" << unit_name <<
" boundaries";
2148 std::ostringstream oss;
2149 const auto found = oss_found.str();
2150 const auto missing = oss_missing.str();
2152 oss <<
"The following paired boundaries were automatically detected for periodicity:\n"
2158 oss <<
"Paired boundaries were not automatically detected for the following:\n"
2160 <<
"\n\nAutomatic detection requires that exactly one boundary is found in each unit "
2176 mooseAssert(
_mesh,
"The MeshBase has not been constructed");
2177 mooseAssert(component <
_bounds.size(),
"Requested dimension out of bounds");
2185 mooseAssert(
_mesh,
"The MeshBase has not been constructed");
2186 mooseAssert(component <
_bounds.size(),
"Requested dimension out of bounds");
2193 const unsigned int var_num,
2200 const auto key = std::make_pair(sys_num, var_num);
2205 bool component_found =
false;
2206 for (
const auto component : make_range(
dimension()))
2210 if (boundary_ids && ((boundary_ids->first == primary && boundary_ids->second == secondary) ||
2211 (boundary_ids->first == secondary && boundary_ids->second == primary)))
2213 entry[component] =
true;
2214 component_found =
true;
2218 if (!component_found)
2219 mooseWarning(
"Could not find a match between boundary '",
2223 "' to set periodic boundary conditions for variable (index:",
2225 ") in either the X, Y or Z direction. The periodic dimension of the mesh for this "
2226 "variable will not be stored.");
2229const std::array<bool, 3> &
2232 const auto key = std::make_pair(sys_num, var_num);
2238const std::array<bool, 3> &
2246 const unsigned int var_num,
2247 const unsigned int component)
const
2249 mooseAssert(component <
dimension(),
"Requested dimension out of bounds");
2263 "MooseMesh::isTranslatedPeriodic(const unsigned int, const unsigned int) is deprecated. Use "
2264 "the method that additionally takes the system number or the MooseVariableBase instead."));
2270 const unsigned int var_num,
2276 for (
const auto i : make_range(
dimension()))
2279 if (periodic_dims[i])
2307 mooseDoOnce(
mooseDeprecated(
"MooseMesh::minPeriodicVector(const unsigned int, const Point &, "
2308 "const Point &) is deprecated. Use the method that additionally "
2309 "takes the system number or the MooseVariableBase instead."));
2315 const unsigned int var_num,
2317 const Point & q)
const
2325 const Point & q)
const
2333 mooseDoOnce(
mooseDeprecated(
"MooseMesh::minPeriodicDistance(const unsigned int, const Point &, "
2334 "const Point &) is deprecated. Use the method that additionally "
2335 "takes the system number or the MooseVariableBase instead."));
2339const std::pair<BoundaryID, BoundaryID> *
2343 mooseError(
"Trying to retrieve automatic paired mapping for a mesh that is not regular and "
2346 mooseAssert(component <
dimension(),
"Requested dimension out of bounds");
2349 mooseError(
"MooseMesh::getPairedBoundaryMapping(): Paired boundaries not built; must call "
2350 "detectPairedSidesets() first");
2352 if (component < _paired_boundary->size())
2353 return &(*_paired_boundary)[component];
2361 std::map<ElemType, Elem *> canonical_elems;
2365 for (
const auto &
elem :
getMesh().element_ptr_range())
2369 if (canonical_elems.find(
type) ==
2370 canonical_elems.end())
2374 Elem * stored = canonical_elems[
type];
2375 if (
elem->id() < stored->id())
2381 for (
const auto & can_it : canonical_elems)
2383 Elem *
elem = can_it.second;
2399 for (
unsigned int side = 0; side <
elem->n_sides(); side++)
2407 for (
unsigned int child = 0; child <
elem->n_children(); ++child)
2408 for (
unsigned int side = 0; side <
elem->n_sides();
2410 if (!
elem->is_child_on_side(child, side))
2423 std::map<ElemType, std::pair<Elem *, unsigned int>> elems_and_max_p_level;
2425 for (
const auto &
elem :
getMesh().active_element_ptr_range())
2428 auto & [picked_elem, max_p_level] = elems_and_max_p_level[
type];
2431 max_p_level = std::max(max_p_level,
elem->p_level());
2436 std::vector<Point> volume_ref_points_coarse, volume_ref_points_fine, face_ref_points_coarse,
2437 face_ref_points_fine;
2438 std::vector<unsigned int> p_levels;
2440 for (
auto & [elem_type, elem_p_level_pair] : elems_and_max_p_level)
2442 auto & [moose_elem, max_p_level] = elem_p_level_pair;
2443 const auto dim = moose_elem->dim();
2446 assembly->
reinit(moose_elem);
2447 assembly->
reinit(moose_elem, 0);
2452 ReplicatedMesh
mesh(self_comm);
2454 for (
const auto & nd : moose_elem->node_ref_range())
2457 Elem *
const elem =
mesh.add_elem(Elem::build(elem_type).release());
2458 for (
const auto i :
elem->node_index_range())
2459 elem->set_node(i,
mesh.node_ptr(i));
2461 std::unique_ptr<FEBase> fe_face(FEBase::build(
dim, p_refinable_fe_type));
2463 const auto & face_phys_points = fe_face->get_xyz();
2464 fe_face->attach_quadrature_rule(qrule_face);
2467 volume_ref_points_coarse = qrule->get_points();
2468 fe_face->reinit(
elem, (
unsigned int)0);
2471 p_levels.resize(max_p_level + 1);
2472 std::iota(p_levels.begin(), p_levels.end(), 0);
2475 for (
const auto p_level : p_levels)
2479 volume_ref_points_fine = qrule->get_points();
2480 fe_face->reinit(
elem, (
unsigned int)0);
2483 const auto map_key = std::make_pair(elem_type, p_level);
2489 auto fill_maps = [
this](
const auto & coarse_ref_points,
2490 const auto & fine_ref_points,
2494 mapPoints(fine_ref_points, coarse_ref_points, refine_map);
2495 mapPoints(coarse_ref_points, fine_ref_points, coarsen_map);
2499 volume_ref_points_coarse, volume_ref_points_fine, volume_coarsen_map, volume_refine_map);
2500 fill_maps(face_ref_points_coarse, face_ref_points_fine, face_coarsen_map, face_refine_map);
2503 volume_ref_points_fine.swap(volume_ref_points_coarse);
2504 face_ref_points_fine.swap(face_ref_points_coarse);
2512 TIME_SECTION(
"buildRefinementAndCoarseningMaps", 5,
"Building Refinement And Coarsening Maps");
2527 TIME_SECTION(
"buildRefinementMap", 5,
"Building Refinement Map");
2531 mooseAssert(parent_side == child_side,
2532 "Parent side must match child_side if not passing a specific child!");
2534 std::pair<int, ElemType> the_pair(parent_side,
elem.type());
2537 mooseError(
"Already built a qp refinement map!");
2539 std::vector<std::pair<unsigned int, QpMap>> coarsen_map;
2542 &
elem, qrule, qrule_face, refinement_map, coarsen_map, parent_side, child, child_side);
2546 std::pair<int, int> child_pair(child, child_side);
2552 mooseError(
"Already built a qp refinement map!");
2554 std::vector<std::pair<unsigned int, QpMap>> coarsen_map;
2555 std::vector<std::vector<QpMap>> & refinement_map =
2558 &
elem, qrule, qrule_face, refinement_map, coarsen_map, parent_side, child, child_side);
2562const std::vector<std::vector<QpMap>> &
2567 mooseAssert(parent_side == child_side,
2568 "Parent side must match child_side if not passing a specific child!");
2570 std::pair<int, ElemType> the_pair(parent_side,
elem.type());
2573 mooseError(
"Could not find a suitable qp refinement map!");
2579 std::pair<int, int> child_pair(child, child_side);
2585 mooseError(
"Could not find a suitable qp refinement map!");
2601 TIME_SECTION(
"buildCoarseningMap", 5,
"Building Coarsening Map");
2603 std::pair<int, ElemType> the_pair(input_side,
elem.type());
2606 mooseError(
"Already built a qp coarsening map!");
2608 std::vector<std::vector<QpMap>> refinement_map;
2609 std::vector<std::pair<unsigned int, QpMap>> & coarsen_map =
2616 &
elem, qrule, qrule_face, refinement_map, coarsen_map, input_side, -1, input_side);
2626const std::vector<std::pair<unsigned int, QpMap>> &
2629 std::pair<int, ElemType> the_pair(input_side,
elem.type());
2632 mooseError(
"Could not find a suitable qp refinement map!");
2639 const std::vector<Point> & to,
2640 std::vector<QpMap> & qp_map)
2642 unsigned int n_from = from.size();
2643 unsigned int n_to = to.size();
2645 qp_map.resize(n_from);
2647 for (
unsigned int i = 0; i < n_from; ++i)
2649 const Point & from_point = from[i];
2651 QpMap & current_map = qp_map[i];
2653 for (
unsigned int j = 0; j < n_to; ++j)
2655 const Point & to_point = to[j];
2656 Real
distance = (from_point - to_point).norm();
2661 current_map.
_from = i;
2662 current_map.
_to = j;
2672 std::vector<std::vector<QpMap>> & refinement_map,
2673 std::vector<std::pair<unsigned int, QpMap>> & coarsen_map,
2678 TIME_SECTION(
"findAdaptivityQpMaps", 5);
2681 mesh.skip_partitioning(
true);
2683 unsigned int dim = template_elem->dim();
2686 for (
unsigned int i = 0; i < template_elem->n_nodes(); ++i)
2687 mesh.add_point(template_elem->point(i));
2689 Elem *
elem =
mesh.add_elem(Elem::build(template_elem->type()).release());
2691 for (
unsigned int i = 0; i < template_elem->n_nodes(); ++i)
2692 elem->set_node(i,
mesh.node_ptr(i));
2694 std::unique_ptr<FEBase> fe(FEBase::build(
dim, FEType()));
2696 const std::vector<Point> & q_points_volume = fe->get_xyz();
2698 std::unique_ptr<FEBase> fe_face(FEBase::build(
dim, FEType()));
2700 const std::vector<Point> & q_points_face = fe_face->get_xyz();
2702 fe->attach_quadrature_rule(&qrule);
2703 fe_face->attach_quadrature_rule(&qrule_face);
2706 const std::vector<Point> * q_points;
2708 if (parent_side != -1)
2710 fe_face->reinit(
elem, parent_side);
2711 q_points = &q_points_face;
2716 q_points = &q_points_volume;
2719 std::vector<Point> parent_ref_points;
2728 std::map<unsigned int, std::vector<Point>> child_to_ref_points;
2730 unsigned int n_children =
elem->n_children();
2732 refinement_map.resize(n_children);
2734 std::vector<unsigned int> children;
2737 children.push_back(child);
2740 children.resize(n_children);
2741 for (
unsigned int child = 0; child < n_children; ++child)
2742 children[child] = child;
2745 for (
unsigned int i = 0; i < children.size(); ++i)
2747 unsigned int child = children[i];
2749 if ((parent_side != -1 && !
elem->is_child_on_side(child, parent_side)))
2752 const Elem * child_elem =
elem->child_ptr(child);
2754 if (child_side != -1)
2756 fe_face->reinit(child_elem, child_side);
2757 q_points = &q_points_face;
2761 fe->reinit(child_elem);
2762 q_points = &q_points_volume;
2765 std::vector<Point> child_ref_points;
2768 child_to_ref_points[child] = child_ref_points;
2770 std::vector<QpMap> & qp_map = refinement_map[child];
2773 mapPoints(child_ref_points, parent_ref_points, qp_map);
2776 coarsen_map.resize(parent_ref_points.size());
2779 for (
unsigned int child = 0; child < n_children; child++)
2781 if (parent_side != -1 && !
elem->is_child_on_side(child, child_side))
2784 std::vector<Point> & child_ref_points = child_to_ref_points[child];
2786 std::vector<QpMap> qp_map;
2789 mapPoints(parent_ref_points, child_ref_points, qp_map);
2792 for (
unsigned int parent_qp = 0; parent_qp < parent_ref_points.size(); ++parent_qp)
2794 std::pair<unsigned int, QpMap> & child_and_map = coarsen_map[parent_qp];
2795 unsigned int & closest_child = child_and_map.first;
2796 QpMap & closest_map = child_and_map.second;
2798 QpMap & current_map = qp_map[parent_qp];
2802 closest_child = child;
2803 closest_map = current_map;
2811 const boundary_id_type new_id,
2814 TIME_SECTION(
"changeBoundaryId", 6);
2820 const boundary_id_type old_id,
2821 const boundary_id_type new_id,
2825 BoundaryInfo & boundary_info =
mesh.get_boundary_info();
2828 std::vector<boundary_id_type> old_ids;
2831 for (
auto &
elem : as_range(
mesh.level_elements_begin(0),
mesh.level_elements_end(0)))
2833 unsigned int n_sides =
elem->n_sides();
2834 for (
unsigned int s = 0; s != n_sides; ++s)
2836 boundary_info.boundary_ids(
elem, s, old_ids);
2837 if (std::find(old_ids.begin(), old_ids.end(), old_id) != old_ids.end())
2839 std::vector<boundary_id_type> new_ids(old_ids);
2840 std::replace(new_ids.begin(), new_ids.end(), old_id, new_id);
2843 boundary_info.remove_side(
elem, s);
2844 boundary_info.add_side(
elem, s, new_ids);
2847 boundary_info.add_side(
elem, s, new_ids);
2856 boundary_info.remove_id(old_id);
2859 mesh.unset_has_boundary_id_sets();
2862const RealVectorValue &
2875 mooseError(
"MooseMesh::clone() is no longer supported, use MooseMesh::safeClone() instead.");
2906std::unique_ptr<MeshBase>
2909 std::unique_ptr<MeshBase>
mesh;
2911 mesh = buildTypedMesh<DistributedMesh>(
dim);
2913 mesh = buildTypedMesh<ReplicatedMesh>(
dim);
2921 _mesh = std::move(mesh_base);
2938 mooseError(
"You cannot use the mesh splitter capability with DistributedMesh!");
2940 TIME_SECTION(
"init", 2);
2947 const bool skip_partitioning_later =
getMesh().skip_partitioning();
2948 getMesh().skip_partitioning(
true);
2949 const bool allow_renumbering_later =
getMesh().allow_renumbering();
2950 getMesh().allow_renumbering(
false);
2955 TIME_SECTION(
"readRecoveredMesh", 2);
2959 getMesh().allow_renumbering(allow_renumbering_later);
2960 getMesh().skip_partitioning(skip_partitioning_later);
2966 getMesh().skip_partitioning(
true);
2969 if (getParam<bool>(
"build_all_side_lowerd_mesh"))
2974std::vector<std::filesystem::path>
2978 io.
write(file_base);
2985 return getMesh().mesh_dimension();
2991 const Real abs_zero = 1e-12;
2995 for (
unsigned int dim = LIBMESH_DIM;
dim >= 1; --
dim)
3009 if (
const auto & elem_dims =
mesh.elem_dimensions();
mesh.is_prepared() && elem_dims.size() == 1)
3010 return *elem_dims.begin();
3012 unsigned short dim = 0;
3014 const std::set<SubdomainID> subdomain_ids_set(subdomain_ids.begin(), subdomain_ids.end());
3015 for (
const auto &
elem :
mesh.active_subdomain_set_elements_ptr_range(subdomain_ids_set))
3023std::vector<BoundaryID>
3026 std::vector<BoundaryID> ids;
3027 getMesh().get_boundary_info().boundary_ids(
elem, side, ids);
3031std::vector<std::vector<BoundaryID>>
3034 std::vector<std::vector<BoundaryID>> ids;
3035 getMesh().get_boundary_info().side_boundary_ids(
elem, ids);
3039const std::set<BoundaryID> &
3042 return getMesh().get_boundary_info().get_boundary_ids();
3048 auto & boundary_info =
getMesh().get_boundary_info();
3052 const std::set<boundary_id_type> & side_bcids = boundary_info.get_side_boundary_ids();
3059 const std::set<boundary_id_type> & node_bcids = boundary_info.get_node_boundary_ids();
3063 boundary_id_type next_bcid = 0;
3064 if (!node_bcids.empty())
3065 next_bcid = std::max(next_bcid, cast_int<boundary_id_type>(*node_bcids.rbegin() + 1));
3066 if (!side_bcids.empty())
3067 next_bcid = std::max(next_bcid, cast_int<boundary_id_type>(*side_bcids.rbegin() + 1));
3077 if (next_bcid > 1000 || next_bcid <= 0)
3083 for (
auto bcid : side_bcids)
3084 if (node_bcids.count(bcid) &&
3085 (boundary_info.get_sideset_name(bcid) != boundary_info.get_nodeset_name(bcid)))
3087 boundary_info.renumber_node_id(bcid, next_bcid);
3091 }
while (node_bcids.count(next_bcid) || side_bcids.count(next_bcid));
3099 for (
auto & [
id,
name] : boundary_info.get_sideset_name_map())
3100 boundary_info.nodeset_name(
id) =
name;
3102 boundary_info.build_node_list_from_side_list();
3106std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
3109 return getMesh().get_boundary_info().build_side_list();
3112std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
3115 return getMesh().get_boundary_info().build_active_side_list();
3121 return getMesh().get_boundary_info().side_with_boundary_id(
elem, boundary_id);
3124MeshBase::node_iterator
3127 return getMesh().local_nodes_begin();
3130MeshBase::node_iterator
3133 return getMesh().local_nodes_end();
3136MeshBase::const_node_iterator
3139 return getMesh().local_nodes_begin();
3142MeshBase::const_node_iterator
3145 return getMesh().local_nodes_end();
3148MeshBase::element_iterator
3151 return getMesh().active_local_elements_begin();
3154const MeshBase::element_iterator
3157 return getMesh().active_local_elements_end();
3160MeshBase::const_element_iterator
3163 return getMesh().active_local_elements_begin();
3166const MeshBase::const_element_iterator
3169 return getMesh().active_local_elements_end();
3187 return getMesh().max_node_id();
3193 return getMesh().max_elem_id();
3199 mooseDeprecated(
"MooseMesh::elem() is deprecated, please use MooseMesh::elemPtr() instead");
3206 mooseDeprecated(
"MooseMesh::elem() is deprecated, please use MooseMesh::elemPtr() instead");
3225 return getMesh().query_elem_ptr(i);
3231 return getMesh().query_elem_ptr(i);
3244 mooseError(
"We don't have any right to tell the libmesh mesh that it *is* prepared. Only a "
3245 "call to prepare_for_use should tell us that");
3250 _mesh->unset_is_prepared();
3268const std::set<SubdomainID> &
3274const std::set<BoundaryID> &
3280const std::set<BoundaryID> &
3286const std::set<BoundaryID> &
3300 std::unique_ptr<std::map<BoundaryID, RealVectorValue>> boundary_map)
3308 mooseDeprecated(
"setBoundaryToNormalMap(std::map<BoundaryID, RealVectorValue> * boundary_map) is "
3309 "deprecated, use the unique_ptr version instead");
3338const std::set<unsigned int> &
3344const std::vector<Real> &
3358template <
typename T>
3359struct extra_ghost_elem_inserter
3361 using iterator_category = std::output_iterator_tag;
3362 using value_type = T;
3364 extra_ghost_elem_inserter(DistributedMesh & m) :
mesh(m) {}
3366 void operator=(
const Elem * e) {
mesh.add_extra_ghost_elem(
const_cast<Elem *
>(e)); }
3368 void operator=(Node * n) {
mesh.add_node(n); }
3370 void operator=(Point * p) {
mesh.add_point(*p); }
3372 extra_ghost_elem_inserter & operator++() {
return *
this; }
3374 extra_ghost_elem_inserter operator++(
int) {
return extra_ghost_elem_inserter(*
this); }
3380 extra_ghost_elem_inserter &
operator*() {
return *
this; }
3383 DistributedMesh &
mesh;
3396struct CompareElemsByLevel
3398 bool operator()(
const Elem * a,
const Elem * b)
const
3402 const unsigned int al = a->level(), bl = b->level();
3405 return (al == bl) ? aid < bid : al < bl;
3421 TIME_SECTION(
"GhostGhostedBoundaries", 3);
3423 parallel_object_only();
3425 DistributedMesh &
mesh =
dynamic_cast<DistributedMesh &
>(
getMesh());
3433 std::set<const Elem *, CompareElemsByLevel> boundary_elems_to_ghost;
3434 std::set<Node *> connected_nodes_to_ghost;
3436 std::vector<const Elem *> family_tree;
3438 for (
const auto & t :
mesh.get_boundary_info().build_side_list())
3440 auto elem_id = std::get<0>(t);
3441 auto bc_id = std::get<2>(t);
3445 Elem *
elem =
mesh.elem_ptr(elem_id);
3447#ifdef LIBMESH_ENABLE_AMR
3448 elem->family_tree(family_tree);
3449 Elem * parent =
elem->parent();
3452 family_tree.push_back(parent);
3453 parent = parent->parent();
3456 family_tree.clear();
3457 family_tree.push_back(
elem);
3459 for (
const auto & felem : family_tree)
3461 boundary_elems_to_ghost.insert(felem);
3469 for (
unsigned int n = 0; n < felem->n_nodes(); ++n)
3470 connected_nodes_to_ghost.insert(
const_cast<Node *
>(felem->node_ptr(n)));
3476 const auto prior_ghost_elems =
mesh.extra_ghost_elems();
3478 mesh.comm().allgather_packed_range(&
mesh,
3479 connected_nodes_to_ghost.begin(),
3480 connected_nodes_to_ghost.end(),
3481 extra_ghost_elem_inserter<Node>(
mesh));
3483 mesh.comm().allgather_packed_range(&
mesh,
3484 boundary_elems_to_ghost.begin(),
3485 boundary_elems_to_ghost.end(),
3486 extra_ghost_elem_inserter<Elem>(
mesh));
3488 const auto & current_ghost_elems =
mesh.extra_ghost_elems();
3490 std::set_difference(current_ghost_elems.begin(),
3491 current_ghost_elems.end(),
3492 prior_ghost_elems.begin(),
3493 prior_ghost_elems.end(),
3526 Real inflation_amount = inflation_multiplier * (bbox.max() - bbox.min()).norm();
3527 Point inflation(inflation_amount, inflation_amount, inflation_amount);
3529 bbox.first -= inflation;
3530 bbox.second += inflation;
3548 mooseAssert(
_mesh,
"Mesh hasn't been created");
3555 mooseAssert(
_mesh,
"Mesh hasn't been created");
3563 getMesh().print_info(os, verbosity);
3567const std::vector<dof_id_type> &
3570 std::map<boundary_id_type, std::vector<dof_id_type>>::const_iterator it =
3580 static const std::vector<dof_id_type> empty_vec;
3587 mooseError(
"Unable to nodeset ID: ", nodeset_id,
'.');
3594const std::set<BoundaryID> &
3600 mooseError(
"Unable to find subdomain ID: ", subdomain_id,
'.');
3602 return it->second.boundary_ids;
3609 std::set<BoundaryID> boundary_ids(bnd_ids.begin(), bnd_ids.end());
3610 std::unordered_map<SubdomainID, std::set<BoundaryID>>::const_iterator it =
3613 boundary_ids.insert(it->second.begin(), it->second.end());
3615 return boundary_ids;
3618std::set<SubdomainID>
3621 std::set<SubdomainID> subdomain_ids;
3623 if (data.boundary_ids.find(bid) != data.boundary_ids.end())
3624 subdomain_ids.insert(sub_id);
3626 return subdomain_ids;
3629std::set<SubdomainID>
3632 std::set<SubdomainID> subdomain_ids;
3634 if (it.second.find(bid) != it.second.end())
3635 subdomain_ids.insert(it.first);
3637 return subdomain_ids;
3640std::set<SubdomainID>
3645 if (it.second.find(bid) != it.second.end())
3646 subdomain_ids.insert(it.first);
3648 return subdomain_ids;
3651const std::set<SubdomainID> &
3657 mooseError(
"Unable to find subdomain ID: ", subdomain_id,
'.');
3659 return it->second.neighbor_subs;
3665 bool found_node =
false;
3668 if (it.second.find(node_id) != it.second.end())
3680 bool found_node =
false;
3681 std::map<boundary_id_type, std::set<dof_id_type>>::const_iterator it =
_bnd_node_ids.find(bnd_id);
3683 if (it->second.find(node_id) != it->second.end())
3691 bool found_elem =
false;
3694 if (it.second.find(elem_id) != it.second.end())
3706 bool found_elem =
false;
3709 if (it->second.find(elem_id) != it->second.end())
3720 " with DistributedMesh!\n",
3721 "Consider specifying parallel_type = 'replicated' in your input file\n",
3722 "to prevent it from being run with DistributedMesh.");
3740 bool use_distributed_mesh,
3745 switch (partitioner)
3749 if (use_distributed_mesh)
3750 partitioner =
"parmetis";
3752 partitioner =
"metis";
3766 if (!params.
isParamValid(
"centroid_partitioner_direction"))
3768 "centroid_partitioner_direction",
3769 "If using the centroid partitioner you _must_ specify centroid_partitioner_direction!");
3773 if (direction ==
"x")
3774 mesh_base.partitioner().reset(
3776 else if (direction ==
"y")
3777 mesh_base.partitioner().reset(
3779 else if (direction ==
"z")
3780 mesh_base.partitioner().reset(
3782 else if (direction ==
"radial")
3783 mesh_base.partitioner().reset(
3815 bool mesh_has_second_order_elements =
false;
3817 if ((*it)->default_order() == SECOND)
3819 mesh_has_second_order_elements =
true;
3824 comm().
max(mesh_has_second_order_elements);
3825 return mesh_has_second_order_elements;
3834std::unique_ptr<libMesh::PointLocatorBase>
3837 return getMesh().sub_point_locator();
3844 "This routine has not been implemented for threads. Please query this routine before "
3845 "a threaded region or contact a MOOSE developer to discuss.");
3848 using Keytype = std::pair<const Elem *, unsigned short int>;
3851 std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>> side_list =
3853 std::map<Keytype, std::set<boundary_id_type>> side_map;
3854 for (
auto & [elem_id, side, bc_id] : side_list)
3856 const Elem *
elem =
_mesh->elem_ptr(elem_id);
3857 Keytype key(
elem, side);
3858 auto & bc_set = side_map[key];
3859 bc_set.insert(bc_id);
3873 auto begin =
getMesh().active_elements_begin();
3874 auto end =
getMesh().active_elements_end();
3879 unsigned int num_sides = 0;
3880 for (
const Elem *
elem : as_range(begin, end))
3883 num_sides +=
elem->n_sides();
3891 dof_id_type face_index = 0;
3892 for (
const Elem *
elem : as_range(begin, end))
3894 for (
unsigned int side = 0; side <
elem->n_sides(); ++side)
3897 const Elem * neighbor =
elem->neighbor_ptr(side);
3904 mooseAssert(!neighbor || (neighbor->level() <
elem->level() ? neighbor->active() :
true),
3905 "If the neighbor is coarser than the element, we expect that the neighbor must "
3909 mooseAssert(
elem->default_order() < 4,
"Did not expect such high element orders in FV");
3917 std::set<boundary_id_type> & boundary_ids = fi.boundaryIDs();
3918 boundary_ids.clear();
3924 fi.computeBoundaryCoefficients();
3928 auto lit = side_map.find(Keytype(&fi.elem(), fi.elemSideID()));
3929 if (lit != side_map.end())
3930 boundary_ids.insert(lit->second.begin(), lit->second.end());
3932 if (fi.neighborPtr())
3934 auto rit = side_map.find(Keytype(fi.neighborPtr(), fi.neighborSideID()));
3935 if (rit != side_map.end())
3936 boundary_ids.insert(rit->second.begin(), rit->second.end());
3950 const Elem *
const elem = &fi.elem();
3951 const auto side = fi.elemSideID();
3957 mooseAssert(pair_it.second,
"We should be adding unique FaceInfo objects.");
3961 if (fi.elem().processor_id() == this->processor_id() ||
3962 (fi.neighborPtr() && (fi.neighborPtr()->processor_id() == this->processor_id())))
3968 if (ei.second.elem()->processor_id() == this->
processor_id())
3981 mooseAssert(it->second,
3982 "For some reason, the FaceInfo object is NULL! Try calling "
3983 "`buildFiniteVolumeInfo()` before using this accessor!");
3998 mooseError(
"Trying to compute face- and elem-info coords when the information is dirty");
4003 const SubdomainID elem_subdomain_id = fi.elemSubdomainID();
4004 const SubdomainID neighbor_subdomain_id = fi.neighborSubdomainID();
4007 *
this, elem_subdomain_id, fi.faceCentroid(), fi.faceCoord(), neighbor_subdomain_id);
4012 *
this, ei.second.subdomain_id(), ei.second.centroid(), ei.second.coordFactor());
4019 "default=-3 metis=-2 parmetis=-1 linear=0 centroid hilbert_sfc morton_sfc custom",
"default");
4027 "EDGE EDGE2 EDGE3 EDGE4 QUAD QUAD4 QUAD8 QUAD9 TRI3 TRI6 HEX HEX8 HEX20 HEX27 TET4 TET10 "
4028 "PRISM6 PRISM15 PRISM18 PYRAMID5 PYRAMID13 PYRAMID14");
4037 _mesh->allow_remote_element_removal(allow_remote_element_removal);
4039 if (!allow_remote_element_removal)
4051 mooseError(
"Cannot delete remote elements because we have not yet attached a MeshBase");
4053 _mesh->allow_remote_element_removal(
true);
4055 _mesh->delete_remote_elements();
4063 "Performing writes to faceInfo variable association maps. This must be done unthreaded!");
4067 auto face_lambda = [
this](
const SubdomainID elem_subdomain_id,
4070 std::vector<std::vector<FaceInfo::VarFaceNeighbors>> & face_type_vector)
4073 const auto & variables = sys.getVariables(0);
4075 for (
const auto & var : variables)
4077 const unsigned int var_num = var->number();
4078 const unsigned int sys_num = var->sys().number();
4079 std::set<SubdomainID> var_subdomains = var->blockIDs();
4089 bool var_defined_elem = var_subdomains.find(elem_subdomain_id) != var_subdomains.end();
4090 bool var_defined_neighbor =
4091 var_subdomains.find(neighbor_subdomain_id) != var_subdomains.end();
4092 if (var_defined_elem && var_defined_neighbor)
4094 else if (!var_defined_elem && !var_defined_neighbor)
4099 if (var_defined_elem)
4101 else if (var_defined_neighbor)
4113 const SubdomainID elem_subdomain_id = face.elemSubdomainID();
4114 const SubdomainID neighbor_subdomain_id = face.neighborSubdomainID();
4116 auto & face_type_vector = face.faceType();
4118 face_type_vector.clear();
4119 face_type_vector.resize(num_eqs);
4123 face_lambda(elem_subdomain_id,
4124 neighbor_subdomain_id,
4129 face_lambda(elem_subdomain_id,
4130 neighbor_subdomain_id,
4140 "Performing writes to elemInfo dof indices. This must be done unthreaded!");
4142 auto elem_lambda = [](
const ElemInfo & elem_info,
4144 std::vector<std::vector<dof_id_type>> & dof_vector)
4146 if (sys.nFVVariables())
4149 const auto & variables = sys.getVariables(0);
4151 for (
const auto & var : variables)
4154 const auto & var_subdomains = var->blockIDs();
4157 if (var_subdomains.find(elem_info.
subdomain_id()) != var_subdomains.end())
4159 std::vector<dof_id_type> indices;
4160 var->dofMap().dof_indices(elem_info.
elem(), indices, var->number());
4161 mooseAssert(indices.size() == 1,
"We expect to have only one dof per element!");
4162 dof_vector[sys.number()][var->number()] = indices[0];
4174 auto & elem_info = ei_pair.second;
4178 dof_vector.resize(num_eqs);
4202 TIME_SECTION(
"setCoordSystem", 5,
"Setting Coordinate System");
4205 const std::string param_name =
isParamValid(
"coord_block") ?
"coord_block" :
"block";
4206 mooseWarning(
"Supplied blocks in the 'setCoordSystem' method do not match the value of the "
4209 "' parameter. Did you provide different parameter values for 'Mesh/",
4211 "' and 'Problem/block'?. We will honor the parameter value from 'Mesh/",
4215 "If we are arriving here due to a bad specification in the Problem block, then we "
4216 "should have already set our coordinate system subdomains from the Mesh block");
4220 mooseError(
"Supplied coordinate systems in the 'setCoordSystem' method do not match the value "
4221 "of the 'Mesh/coord_type' parameter. Did you provide different parameter values for "
4222 "'coord_type' to 'Mesh' and 'Problem'?");
4229 if (coord_sys.
size() > 1)
4230 mooseError(
"If you specify ANY_BLOCK_ID as the only block, you must also specify a single "
4231 "coordinate system for it.");
4232 if (!
_mesh->is_prepared())
4234 "You cannot set the coordinate system for ANY_BLOCK_ID before the mesh is prepared. "
4235 "Please call this method after the mesh is prepared.");
4236 const auto coord_type = coord_sys.
size() == 0
4238 : Moose::stringToEnum<Moose::CoordinateSystemType>(coord_sys[0]);
4246 mooseError(
"You cannot specify ANY_BLOCK_ID together with other blocks in the "
4247 "setCoordSystem() method. If you want to set the same coordinate system for all "
4248 "blocks, use ANY_BLOCK_ID as the only block.");
4253 for (
const auto & sub_name :
blocks)
4256 subdomains.insert(sub_id);
4259 if (coord_sys.
size() <= 1)
4262 const auto coord_type = coord_sys.
size() == 0
4264 : Moose::stringToEnum<Moose::CoordinateSystemType>(coord_sys[0]);
4265 for (
const auto sid : subdomains)
4271 mooseError(
"Number of blocks and coordinate systems does not match.");
4273 for (
const auto i : index_range(
blocks))
4277 Moose::stringToEnum<Moose::CoordinateSystemType>(coord_sys[i]);
4281 for (
const auto & sid : subdomains)
4284 "' does not have a coordinate system specified.");
4297 return (*it).second;
4299 mooseError(
"Requested subdomain ", sid,
" does not exist.");
4307 bool result = std::all_of(
4311 typename std::unordered_map<SubdomainID, Moose::CoordinateSystemType>::const_reference
4312 item) { return (item.second == unique_system); });
4314 mooseError(
"The unique coordinate system of the mesh was requested by the mesh contains "
4315 "multiple blocks with different coordinate systems");
4318 mooseError(
"General axisymmetric coordinate axes are being used, and it is currently "
4319 "conservatively assumed that in this case there is no unique coordinate system.");
4321 return unique_system;
4324const std::map<SubdomainID, Moose::CoordinateSystemType> &
4340 const std::vector<SubdomainName> &
blocks,
4341 const std::vector<std::pair<Point, RealVectorValue>> & axes)
4344 mooseAssert(
blocks.size() == axes.size(),
"Blocks and axes vectors must be the same length.");
4345 for (
const auto i : index_range(
blocks))
4348 const auto it =
_coord_sys.find(subdomain_id);
4352 "' has not set a coordinate system. Make sure to call setCoordSystem() before "
4353 "setGeneralAxisymmetricCoordAxes().");
4358 const auto direction = axes[i].second;
4359 if (direction.is_zero())
4360 mooseError(
"Only nonzero vectors may be supplied for RZ directions.");
4363 std::make_pair(axes[i].first, direction.unit());
4368 "' was provided in setGeneralAxisymmetricCoordAxes(), but the coordinate system "
4369 "for this block is not 'RZ'.");
4375 for (
const auto subdomain_id : all_subdomain_ids)
4380 "' was specified to use the 'RZ' coordinate system but was not given in "
4381 "setGeneralAxisymmetricCoordAxes().");
4386const std::pair<Point, RealVectorValue> &
4391 return (*it).second;
4393 mooseError(
"Requested subdomain ", subdomain_id,
" does not exist.");
4415 mooseError(
"getAxisymmetricRadialCoord() should not be called if "
4416 "setGeneralAxisymmetricCoordAxes() has been called.");
4427 for (
const auto &
elem :
getMesh().element_ptr_range())
4432 " which contains 3D elements.");
4434 mooseError(
"An RSPHERICAL coordinate system was requested for subdomain " +
4457 std::map<SubdomainName, SubdomainID> subdomain;
4461 if (!sub_name.empty() && subdomain.count(sub_name) > 0)
4464 " is used for both subdomain with ID=",
4465 subdomain[sub_name],
4468 ", Please rename one of them!");
4470 subdomain[sub_name] = sbd_id;
4474const std::vector<QpMap> &
4477 const std::map<std::pair<ElemType, unsigned int>, std::vector<QpMap>> & map)
const
4481 return libmesh_map_find(map,
4482 std::make_pair(
elem.type(), cast_int<unsigned int>(
elem.p_level() - 1)));
4485const std::vector<QpMap> &
4488 const std::map<std::pair<ElemType, unsigned int>, std::vector<QpMap>> & map)
const
4490 mooseAssert(
elem.active() &&
elem.p_refinement_flag() == Elem::JUST_COARSENED,
4491 "These are the conditions that should be met for requesting a coarsening map");
4492 return libmesh_map_find(map, std::make_pair(
elem.type(),
elem.p_level()));
4495const std::vector<QpMap> &
4501const std::vector<QpMap> &
4507const std::vector<QpMap> &
4513const std::vector<QpMap> &
4522 return _mesh->skip_noncritical_partitioning();
void coordTransformFactor(const SubProblem &s, SubdomainID sub_id, const P &point, C &factor, SubdomainID neighbor_sub_id=libMesh::Elem::invalid_subdomain_id)
Computes a conversion multiplier for use when computing integraals for the current coordinate system ...
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
auto operator*(const T1 &a, const RankFourTensorTempl< T2 > &b) -> typename std::enable_if< libMesh::ScalarTraits< T1 >::value, RankFourTensorTempl< decltype(T1() *T2())> >::type
void ErrorVector unsigned int
Keeps track of stuff related to assembling.
libMesh::QBase *const & writeableQRule()
Returns the reference to the current quadrature being used.
libMesh::QBase *const & writeableQRuleFace()
Returns the reference to the current quadrature being used on a current face.
void setCurrentSubdomainID(SubdomainID i)
set the current subdomain ID
void reinit(const Elem *elem)
Reinitialize objects (JxW, q_points, ...) for an elements.
Helper class for sorting Boundary Nodes so that we always get the same order of application for bound...
bool operator()(const BndNode *const &lhs, const BndNode *const &rhs)
std::vector< const Elem * > _refined_elements
The elements that were just refined.
std::map< const Elem *, std::vector< const Elem * > > _coarsened_element_children
Map of Parent elements to children elements for elements that were just coarsened.
std::vector< const Elem * > _coarsened_elements
The elements that were just coarsened.
Fills lower-d side maps and node-to-block ownership for MooseMesh::cacheInfo().
std::unordered_map< dof_id_type, SubdomainID > _node_block
The subdomain of the elements incident on a node, for the nodes whose incident elements all agree,...
std::unordered_map< dof_id_type, std::set< SubdomainID > > _interface_node_blocks
The full subdomain set of the nodes whose incident elements disagree, that is the nodes on a subdomai...
Fills subdomain neighbor and attached boundary-id caches for MooseMesh::cacheInfo().
Class used for caching additional information for elements such as the volume and centroid.
SubdomainID subdomain_id() const
We return the subdomain ID of the corresponding libmesh element.
const Elem * elem() const
const std::vector< std::vector< dof_id_type > > & dofIndices() const
virtual libMesh::EquationSystems & es() override
AuxiliarySystem & getAuxiliarySystem()
virtual std::size_t numSolverSystems() const override
bool hasKokkosObjects() const
SolverSystem & getSolverSystem(unsigned int sys_num)
Get non-constant reference to a solver system.
This data structure is used to store geometric and variable related metadata about each cell face in ...
bool isKokkosAvailable() const
Get whether Kokkos is available.
bool isSplitMesh() const
Whether or not this is a split mesh operation.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
static const std::string & checkpointSuffix()
The file suffix for the checkpoint mesh.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
bool getDistributedMeshOnCommandLine() const
Returns true if the user specified –distributed-mesh (or –parallel-mesh, for backwards compatibility)...
FEProblemBase & feProblem() const
std::string getRestartRecoverFileBase() const
The file_base for the recovery file.
bool isRecovering() const
Whether or not this is a "recover" calculation.
const std::string & type() const
Get the type of this class.
static const std::string name_param
The name of the parameter that contains the object name.
const std::string & name() const
Get the name of the class.
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 ...
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
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...
const InputParameters & _pars
The object's parameters.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
std::set< SubdomainID > getInterfaceConnectedBlocks(const BoundaryID bid) const
Get the list of subdomains contacting the given boundary.
virtual bnd_node_iterator bndNodesBegin()
Return iterators to the beginning/end of the boundary nodes list.
const Moose::PatchUpdateType & getPatchUpdateStrategy() const
Get the current patch update strategy.
std::vector< std::vector< bool > > _id_identical_flag
Flags to indicate whether or not any two extra element integers are the same.
bool _need_delete
Whether we need to delete remote elements after init'ing the EquationSystems.
void setBoundaryName(BoundaryID boundary_id, BoundaryName name)
This method sets the boundary name of the boundary based on the id parameter.
virtual bnd_node_iterator bndNodesEnd()
bool isBoundaryElem(dof_id_type elem_id) const
Returns true if the requested element is in the list of boundary elements, false otherwise.
void setupFiniteVolumeMeshData() const
Sets up the additional data needed for finite volume computations.
const std::set< BoundaryID > & getSubdomainBoundaryIds(const SubdomainID subdomain_id) const
Get the list of boundary ids associated with the given subdomain id.
void printInfo(std::ostream &os=libMesh::out, const unsigned int verbosity=0) const
Calls print_info() on the underlying Mesh.
const Elem * getLowerDElem(const Elem *, unsigned short int) const
Returns a const pointer to a lower dimensional element that corresponds to a side of a higher dimensi...
virtual std::vector< std::filesystem::path > writeRecoveryFiles(const std::filesystem::path &file_base)
Write the mesh files needed for recovery/checkpointing.
bool _allow_recovery
Whether or not this Mesh is allowed to read a recovery file.
MeshBase::node_iterator localNodesEnd()
unsigned int _max_p_level
Maximum p-refinement level of all elements.
std::map< const Elem *, std::vector< const Elem * > > _coarsened_element_children
Map of Parent elements to child elements for elements that were just coarsened.
std::unordered_set< dof_id_type > getBoundaryActiveSemiLocalElemIds(BoundaryID bid) const
Return all ids of elements which have a side which is part of a sideset.
std::unique_ptr< ConstElemPointerRange > _coarsened_elements
The elements that were just coarsened.
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
face_info_iterator ownedFaceInfoEnd()
unsigned int sideWithBoundaryID(const Elem *const elem, const BoundaryID boundary_id) const
Calls BoundaryInfo::side_with_boundary_id().
void meshChanged()
Declares that the MooseMesh has changed, invalidates cached data and rebuilds caches.
virtual const Node & nodeRef(const dof_id_type i) const
const std::vector< QpMap > & getPRefinementMap(const Elem &elem) const
Get the map describing for each volumetric quadrature point (qp) on the refined level which qp on the...
bool _displace_node_list_by_side_list
Whether or not to displace unrelated nodesets by nodesets constructed from sidesets.
void changeBoundaryId(const boundary_id_type old_id, const boundary_id_type new_id, bool delete_prev)
Change all the boundary IDs for a given side from old_id to new_id.
const std::vector< const Elem * > & coarsenedElementChildren(const Elem *elem) const
Get the newly removed children element ids for an element that was just coarsened.
void mapPoints(const std::vector< Point > &from, const std::vector< Point > &to, std::vector< QpMap > &qp_map)
Find the closest points that map "from" to "to" and fill up "qp_map".
libMesh::BoundingBox getInflatedProcessorBoundingBox(Real inflation_multiplier=0.01) const
Get a (slightly inflated) processor bounding box.
RealVectorValue minPeriodicVector(const unsigned int sys_num, const unsigned int var_num, Point p, Point q) const
Returns the minimum vector between two points on the mesh taking into account periodicity for the giv...
std::set< Node * > _semilocal_node_list
Used for generating the semilocal node range.
Real minPeriodicDistance(const unsigned int sys_num, const unsigned int var_num, const Point &p, const Point &q) const
Returns the distance between two points on the mesh taking into account periodicity for the given var...
std::unordered_map< dof_id_type, ElemInfo > _elem_to_elem_info
Map connecting elems with their corresponding ElemInfo, we use the element ID as the key.
unsigned int uniformRefineLevel() const
Returns the level of uniform refinement requested (zero if AMR is disabled).
virtual dof_id_type maxElemId() const
const std::vector< std::pair< unsigned int, QpMap > > & getCoarseningMap(const Elem &elem, int input_side)
Get the coarsening map for a given element type.
bool possiblyRebuildNodeToElemMap()
rebuild the node to element map if it's been requsted previously
std::vector< const FaceInfo * > _face_info
Holds only those FaceInfo objects that have processor_id equal to this process's id,...
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
static const std::array< bool, 3 > periodic_dim_default
Default value for the automatically detected paired boundaries for each unit dimension,...
virtual Elem * elem(const dof_id_type i)
Various accessors (pointers/references) for Elem "i".
std::unique_ptr< ConstElemPointerRange > _refined_elements
The elements that were just refined.
bool _custom_partitioner_requested
bool _need_ghost_ghosted_boundaries
A parallel mesh generator such as DistributedRectilinearMeshGenerator already make everything ready.
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > buildSideList()
Calls BoundaryInfo::build_side_list(), returns a std::vector of (elem-id, side-id,...
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
void updateCoordTransform()
Update the coordinate transformation object based on our coordinate system data.
elem_info_iterator ownedElemInfoEnd()
virtual MooseMesh & clone() const
Clone method.
std::unordered_map< SubdomainID, std::pair< Point, RealVectorValue > > _subdomain_id_to_rz_coord_axis
Map of subdomain ID to general axisymmetric axis.
virtual Elem * elemPtr(const dof_id_type i)
virtual void onMeshChanged()
Declares a callback function that is executed at the conclusion of meshChanged().
bool _coord_system_set
Whether the coordinate system has been set.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
MooseEnum _partitioner_name
The partitioner used on this mesh.
bool _parallel_type_overridden
void buildRefinementAndCoarseningMaps(Assembly *assembly)
Create the refinement and coarsening maps necessary for projection of stateful material properties wh...
void detectPairedSidesets()
This routine detects paired sidesets of a regular orthogonal mesh (.i.e.
bool hasSingleSubdomain() const
Whether the elements of the mesh all have the same subdomain, according to the subdomain set that lib...
virtual void buildMesh()=0
Must be overridden by child classes.
std::map< std::pair< libMesh::ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_coarsening_map
std::set< BoundaryID > _mesh_boundary_ids
A set of boundary IDs currently present in the mesh.
const std::vector< Real > & getGhostedBoundaryInflation() const
Return a writable reference to the _ghosted_boundaries_inflation vector.
virtual void init()
Initialize the Mesh object.
virtual const Node & node(const dof_id_type i) const
Various accessors (pointers/references) for Node "i".
std::vector< SubdomainName > getSubdomainNames(const std::vector< SubdomainID > &subdomain_ids) const
Get the associated subdomainNames for the subdomain ids that are passed in.
Real dimensionWidth(unsigned int component) const
Returns the width of the requested dimension.
std::map< std::pair< libMesh::ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_coarsening_side_map
void prepare()
Calls prepare_for_use() if the underlying MeshBase object isn't prepared, then communicates various b...
void computeMaxPerElemAndSide()
Compute the maximum numbers per element and side.
virtual dof_id_type nActiveLocalElem() const
void update()
Calls buildNodeListFromSideList(), buildNodeList(), and buildBndElemList().
std::map< boundary_id_type, std::vector< dof_id_type > > _node_set_nodes
list of nodes that belongs to a specified nodeset: indexing [nodeset_id] -> [array of node ids]
std::set< dof_id_type > getElemIDsOnBlocks(unsigned int elem_id_index, const std::set< SubdomainID > &blks) const
Return all the unique element IDs for an extra element integer with its index on a set of subdomains.
std::vector< FaceInfo > _all_face_info
FaceInfo object storing information for face based loops.
const std::string & getBoundaryName(const BoundaryID boundary_id) const
Return the name of the boundary given the id.
std::unique_ptr< libMesh::MeshBase > _mesh
Pointer to underlying libMesh mesh object.
void determineUseDistributedMesh()
Determine whether to use a distributed mesh.
std::vector< Node * > _node_map
Vector of all the Nodes in the mesh for determining when to add a new point.
std::unique_ptr< libMesh::StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > > _bnd_elem_range
bool hasDetectedPairedSidesets() const
Whether or not detectedPairedSidesets() has been called.
std::map< SubdomainID, Moose::CoordinateSystemType > & _coord_sys
Type of coordinate system per subdomain.
std::map< std::pair< int, libMesh::ElemType >, std::vector< std::vector< QpMap > > > _elem_type_to_refinement_map
Holds mappings for volume to volume and parent side to child side Map key:
std::unique_ptr< libMesh::StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > > _bnd_node_range
const MeshBase * getMeshPtr() const
ParallelType _parallel_type
Can be set to DISTRIBUTED, REPLICATED, or DEFAULT.
Moose::CoordinateSystemType getUniqueCoordSystem() const
Get the coordinate system from the mesh, it must be the same in all subdomains otherwise this will er...
std::pair< const Node *, BoundaryID > PeriodicNodeInfo
Helper type for building periodic node maps.
void buildNodeListFromSideList()
Calls BoundaryInfo::build_node_list_from_side_list().
void setMeshBoundaryIDs(std::set< BoundaryID > boundary_IDs)
Sets the set of BoundaryIDs Is called by AddAllSideSetsByNormals.
const std::map< SubdomainID, Moose::CoordinateSystemType > & getCoordSystem() const
Get the map from subdomain ID to coordinate system type, e.g.
unsigned int _max_h_level
Maximum h-refinement level of all elements.
virtual unsigned int effectiveSpatialDimension() const
Returns the effective spatial dimension determined by the coordinates actually used by the mesh.
bool prepared() const
Setter/getter for whether the mesh is prepared.
std::vector< std::unordered_map< SubdomainID, std::set< dof_id_type > > > _block_id_mapping
Unique element integer IDs for each subdomain and each extra element integers.
std::map< std::pair< int, libMesh::ElemType >, std::vector< std::pair< unsigned int, QpMap > > > _elem_type_to_coarsening_map
Holds mappings for volume to volume and parent side to child side Map key:
std::unordered_map< std::pair< const Elem *, unsigned short int >, const Elem * > _higher_d_elem_side_to_lower_d_elem
Holds a map from a high-order element side to its corresponding lower-d element.
std::unordered_map< dof_id_type, std::set< dof_id_type > > getElemIDMapping(const std::string &from_id_name, const std::string &to_id_name) const
bool _use_distributed_mesh
False by default.
void addGhostedBoundary(BoundaryID boundary_id)
This will add the boundary ids to be ghosted to this processor.
unsigned int getHigherDSide(const Elem *elem) const
Returns the local side ID of the interior parent aligned with the lower dimensional element.
std::set< SubdomainID > _mesh_subdomains
A set of subdomain IDs currently present in the mesh.
static MooseEnum partitioning()
returns MooseMesh partitioning options so other classes can use it
virtual dof_id_type maxNodeId() const
Calls max_node/elem_id() on the underlying libMesh mesh object.
void setCoordData(const MooseMesh &other_mesh)
Set the coordinate system data to that of other_mesh.
void checkDuplicateSubdomainNames()
Loop through all subdomain IDs and check if there is name duplication used for the subdomains with sa...
std::map< dof_id_type, std::map< unsigned int, std::map< dof_id_type, Node * > > > _elem_to_side_to_qp_to_quadrature_nodes
bool _regular_orthogonal_mesh
Boolean indicating whether this mesh was detected to be regular and orthogonal.
SemiLocalNodeRange * getActiveSemiLocalNodeRange() const
ConstElemPointerRange * refinedElementRange() const
Return a range that is suitable for threaded execution over elements that were just refined.
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
void clearQuadratureNodes()
Clear out any existing quadrature nodes.
void cacheFaceInfoVariableOwnership() const
Cache if variables live on the elements connected by the FaceInfo objects.
virtual Real getMaxInDimension(unsigned int component) const
void buildFiniteVolumeInfo() const
Builds the face and elem info vectors that store meta-data needed for looping over and doing calculat...
static InputParameters validParams()
Typical "Moose-style" constructor and copy constructor.
const std::set< BoundaryID > & meshNodesetIds() const
Returns a read-only reference to the set of nodesets currently present in the Mesh.
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
libMesh::ConstNodeRange * getLocalNodeRange()
void setIsCustomPartitionerRequested(bool cpr)
void deleteRemoteElements()
Delete remote elements.
bool allowRemoteElementRemoval() const
Whether we are allow remote element removal.
elem_info_iterator ownedElemInfoBegin()
Iterators to owned faceInfo objects.
std::vector< BndElement * > _bnd_elems
array of boundary elems
void ghostGhostedBoundaries()
Actually do the ghosting of boundaries that need to be ghosted to this processor.
const std::vector< QpMap > & getPCoarseningMap(const Elem &elem) const
Get the map describing for each volumetric quadrature point (qp) on the coarse level which qp on the ...
bool _is_nemesis
True if a Nemesis Mesh was read in.
void updateActiveSemiLocalNodeRange(std::set< dof_id_type > &ghosted_elems)
Clears the "semi-local" node list and rebuilds it.
virtual bool skipNoncriticalPartitioning() const
void checkCoordinateSystems()
Performs a sanity check for every element in the mesh.
void buildRefinementMap(const Elem &elem, libMesh::QBase &qrule, libMesh::QBase &qrule_face, int parent_side, int child, int child_side)
Build the refinement map for a given element type.
const std::vector< const FaceInfo * > & faceInfo() const
Accessor for local FaceInfo objects.
void buildElemIDInfo()
Build extra data for faster access to the information of extra element integers.
virtual bnd_elem_iterator bndElemsBegin()
Return iterators to the beginning/end of the boundary elements list.
unsigned int getBlocksMaxDimension(const std::vector< SubdomainName > &blocks) const
Returns the maximum element dimension on the given blocks.
const std::vector< QpMap > & getPCoarseningSideMap(const Elem &elem) const
Get the map describing for each side quadrature point (qp) on the coarse level which qp on the previo...
virtual Elem * queryElemPtr(const dof_id_type i)
const std::set< unsigned int > & getGhostedBoundaries() const
Return a writable reference to the set of ghosted boundary IDs.
void cacheFVElementalDoFs() const
Cache the DoF indices for FV variables on each element.
virtual std::unique_ptr< libMesh::PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default),...
bool _partitioner_overridden
const std::set< BoundaryID > & getBoundaryIDs() const
Returns a const reference to a set of all user-specified boundary IDs.
std::vector< std::vector< Real > > _bounds
The bounds in each dimension of the mesh for regular orthogonal meshes.
std::set< SubdomainID > _lower_d_boundary_blocks
Mesh blocks for boundary lower-d elements in different types.
const ElemInfo & elemInfo(const dof_id_type id) const
Accessor for the elemInfo object for a given element ID.
void setBoundaryToNormalMap(std::unique_ptr< std::map< BoundaryID, RealVectorValue > > boundary_map)
Sets the mapping between BoundaryID and normal vector Is called by AddAllSideSetsByNormals.
bool isCustomPartitionerRequested() const
Setter and getter for _custom_partitioner_requested.
const std::vector< QpMap > & getPRefinementSideMap(const Elem &elem) const
Get the map describing for each side quadrature point (qp) on the refined level which qp on the previ...
void computeFiniteVolumeCoords() const
Compute the face coordinate value for all FaceInfo and ElemInfo objects.
bool _moose_mesh_prepared
True if prepare has been called on the mesh.
const std::unordered_map< boundary_id_type, std::unordered_set< dof_id_type > > & getBoundariesToActiveSemiLocalElemIds() const
Returns a map of boundaries to ids of elements on the boundary.
bool _doing_p_refinement
Whether we have p-refinement (whether exclusively p- or hp-refinement)
bool _skip_deletion_repartition_after_refine
Whether or not skip remote deletion and repartition after uniform refinements.
void buildNodeList()
Calls BoundaryInfo::build_node_list()/build_side_list() and makes separate copies of Nodes/Elems in t...
virtual dof_id_type nNodes() const
Calls n_nodes/elem() on the underlying libMesh mesh object.
std::vector< Node * > _extreme_nodes
A vector containing the nodes at the corners of a regular orthogonal mesh.
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
std::unique_ptr< libMesh::Partitioner > _custom_partitioner
The custom partitioner.
std::optional< std::vector< std::pair< BoundaryID, BoundaryID > > > _paired_boundary
A vector holding the paired boundaries for a regular orthogonal mesh.
const std::vector< dof_id_type > & getNodeList(boundary_id_type nodeset_id) const
Return a writable reference to a vector of node IDs that belong to nodeset_id.
std::set< SubdomainID > getBoundaryConnectedSecondaryBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary of its secondary side.
std::unordered_map< std::pair< const Elem *, unsigned int >, FaceInfo * > _elem_side_to_face_info
Map from elem-side pair to FaceInfo.
const std::vector< QpMap > & getPRefinementMapHelper(const Elem &elem, const std::map< std::pair< libMesh::ElemType, unsigned int >, std::vector< QpMap > > &) const
unsigned int _max_nodes_per_elem
The maximum number of nodes per element.
static MooseEnum elemTypes()
returns MooseMesh element type options
std::set< BoundaryID > _mesh_nodeset_ids
void setGeneralAxisymmetricCoordAxes(const std::vector< SubdomainName > &blocks, const std::vector< std::pair< Point, RealVectorValue > > &axes)
Sets the general coordinate axes for axisymmetric blocks.
unsigned int getPatchSize() const
Getter for the patch_size parameter.
void addPeriodicVariable(const unsigned int sys_num, const unsigned int var_num, const BoundaryID primary, const BoundaryID secondary)
For "regular orthogonal" meshes, determine if variable var_num is periodic with respect to the primar...
void cacheChangedLists()
Cache information about what elements were refined and coarsened in the previous step.
bool isTranslatedPeriodic(const unsigned int sys_num, const unsigned int var_num, const unsigned int component) const
Returns whether this generated mesh is periodic in the given dimension for the given variable on the ...
const std::pair< Point, RealVectorValue > & getGeneralAxisymmetricCoordAxis(SubdomainID subdomain_id) const
Gets the general axisymmetric coordinate axis for a block.
std::map< std::pair< libMesh::ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_refinement_side_map
bool _allow_remote_element_removal
Whether to allow removal of remote elements.
bool _construct_node_list_from_side_list
Whether or not to allow generation of nodesets from sidesets.
std::set< BoundaryID > getSubdomainInterfaceBoundaryIds(const SubdomainID subdomain_id) const
Get the list of boundaries that contact the given subdomain.
const Node * addUniqueNode(const Point &p, Real tol=1e-6)
Add a new node to the mesh.
const std::set< BoundaryID > & meshBoundaryIds() const
Returns a read-only reference to the set of boundary IDs currently present in the Mesh.
std::vector< BndNode * > _bnd_nodes
array of boundary nodes
std::unordered_map< dof_id_type, std::vector< dof_id_type > > _node_to_elem_map
A map of all of the current nodes to the elements that they are connected to.
void buildPeriodicNodeSets(std::map< BoundaryID, std::set< dof_id_type > > &periodic_node_sets, unsigned int var_number, libMesh::PeriodicBoundaries *pbs) const
This routine builds a datastructure of node ids organized by periodic boundary ids.
std::unique_ptr< MooseAppCoordTransform > _coord_transform
A coordinate transformation object that describes how to transform this problem's coordinate system i...
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
std::map< libMesh::ElemType, std::map< std::pair< int, int >, std::vector< std::vector< QpMap > > > > _elem_type_to_child_side_refinement_map
Holds mappings for "internal" child sides to parent volume. The second key is (child,...
void buildPeriodicNodeMap(std::multimap< dof_id_type, dof_id_type > &periodic_node_map, unsigned int var_number, libMesh::PeriodicBoundaries *pbs) const
This routine builds a multimap of boundary ids to matching boundary ids across all periodic boundarie...
const RealVectorValue & getNormalByBoundaryID(BoundaryID id) const
Returns the normal vector associated with a given BoundaryID.
std::unordered_map< SubdomainID, SubdomainData > _sub_to_data
Holds a map from subdomain ids to associated data.
const MooseUnits & lengthUnit() const
std::unique_ptr< std::map< BoundaryID, RealVectorValue > > _boundary_to_normal_map
The boundary to normal map - valid only when AddAllSideSetsByNormals is active.
std::unique_ptr< libMesh::NodeRange > _active_node_range
std::set< SubdomainID > _lower_d_interior_blocks
Mesh blocks for interior lower-d elements in different types.
void setPatchUpdateStrategy(Moose::PatchUpdateType patch_update_strategy)
Set the patch size update strategy.
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
void setPartitionerHelper(MeshBase *mesh=nullptr)
const std::pair< BoundaryID, BoundaryID > * getPairedBoundaryMapping(unsigned int component) const
This function attempts to return the paired boundary ids for the given component.
const std::set< BoundaryID > & meshSidesetIds() const
Returns a read-only reference to the set of sidesets currently present in the Mesh.
std::map< boundary_id_type, std::set< dof_id_type > > _bnd_node_ids
Map of sets of node IDs in each boundary.
unsigned int _rz_coord_axis
Storage for RZ axis selection.
ConstElemPointerRange * coarsenedElementRange() const
Return a range that is suitable for threaded execution over elements that were just coarsened.
std::unordered_map< SubdomainID, std::set< BoundaryID > > _neighbor_subdomain_boundary_ids
Holds a map from neighbor subomdain ids to the boundary ids that are attached to it.
std::unordered_map< boundary_id_type, std::unordered_set< dof_id_type > > _bnd_elem_ids
Map of set of elem IDs connected to each boundary.
unsigned int _uniform_refine_level
The level of uniform refinement requested (set to zero if AMR is disabled)
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
void buildCoarseningMap(const Elem &elem, libMesh::QBase &qrule, libMesh::QBase &qrule_face, int input_side)
Build the coarsening map for a given element type.
bool hasSecondOrderElements()
check if the mesh has SECOND order elements
std::unordered_map< const Elem *, unsigned short int > _lower_d_elem_to_higher_d_elem_side
bool _finite_volume_info_dirty
std::unordered_set< dof_id_type > getBoundaryActiveNeighborElemIds(BoundaryID bid) const
Return all ids of neighbors of elements which have a side which is part of a sideset.
virtual const Node * nodePtr(const dof_id_type i) const
std::map< dof_id_type, Node * > _quadrature_nodes
const std::unordered_map< boundary_id_type, std::unordered_set< dof_id_type > > & getBoundariesToElems() const
Returns a map of boundaries to ids of elements on the boundary.
const std::vector< QpMap > & getPCoarseningMapHelper(const Elem &elem, const std::map< std::pair< libMesh::ElemType, unsigned int >, std::vector< QpMap > > &) const
libMesh::NodeRange * getActiveNodeRange()
std::vector< SubdomainName > _provided_coord_blocks
Set for holding user-provided coordinate system type block names.
unsigned int _patch_size
The number of nodes to consider in the NearestNode neighborhood.
void setCustomPartitioner(libMesh::Partitioner *partitioner)
Setter for custom partitioner.
libMesh::StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
void setMeshBase(std::unique_ptr< MeshBase > mesh_base)
Method to set the mesh_base object.
std::unique_ptr< libMesh::ConstNodeRange > _local_node_range
void setSubdomainName(SubdomainID subdomain_id, const SubdomainName &name, const bool synchronous=false)
This method sets the name for subdomain_id to name.
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
virtual bnd_elem_iterator bndElemsEnd()
MeshBase::node_iterator localNodesBegin()
Calls local_nodes_begin/end() on the underlying libMesh mesh object.
const std::vector< std::vector< QpMap > > & getRefinementMap(const Elem &elem, int parent_side, int child, int child_side)
Get the refinement map for a given element type.
void setCoordSystem(const std::vector< SubdomainName > &blocks, const MultiMooseEnum &coord_sys)
Set the coordinate system for the provided blocks to coord_sys.
Node * addQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp, BoundaryID bid, const Point &point)
Adds a fictitious "QuadratureNode".
void buildLowerDMesh()
Build lower-d mesh for all sides.
bool doingPRefinement() const
Query whether the kind of adaptivity we're doing includes p-refinement.
virtual const Node * queryNodePtr(const dof_id_type i) const
std::map< std::pair< unsigned int, unsigned int >, std::array< bool, 3 > > _periodic_dim
A map from (system number, vector number) to which dimensions are periodic in a regular orthogonal me...
std::vector< dof_id_type > _max_ids
Maximum integer ID for each extra element integer.
std::unique_ptr< Moose::Kokkos::Mesh > _kokkos_mesh
Pointer to Kokkos mesh object.
void findAdaptivityQpMaps(const Elem *template_elem, libMesh::QBase &qrule, libMesh::QBase &qrule_face, std::vector< std::vector< QpMap > > &refinement_map, std::vector< std::pair< unsigned int, QpMap > > &coarsen_map, int parent_side, int child, int child_side)
Given an elem type, get maps that tell us what qp's are closest to each other between a parent and it...
unsigned int _max_nodes_per_side
The maximum number of nodes per side.
bool _node_to_elem_map_built
Whether _node_to_elem_map has been built.
const MeshBase::element_iterator activeLocalElementsEnd()
std::set< BoundaryID > _mesh_sideset_ids
std::vector< Real > _ghosted_boundaries_inflation
void setGhostedBoundaryInflation(const std::vector< Real > &inflation)
This sets the inflation amount for the bounding box for each partition for use in ghosting boundaries...
std::string getBoundaryString(const BoundaryID boundary_id) const
Return the name of the boundary given the id, if it exists.
std::set< SubdomainID > getBoundaryConnectedBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary.
const std::array< bool, 3 > & queryPeriodicDimensions(const unsigned int sys_num, const unsigned int var_num) const
Query the translated periodic dimension flags for the given variable on the given system.
const bool _is_split
Whether or not we are using a (pre-)split mesh (automatically DistributedMesh)
std::unique_ptr< SemiLocalNodeRange > _active_semilocal_node_range
Ranges for use with threading, cached so they don't have to get rebuilt all the time (which takes tim...
void setUniformRefineLevel(unsigned int, bool deletion=true)
Set uniform refinement level.
Moose::PatchUpdateType _patch_update_strategy
The patch update strategy.
virtual Real getMinInDimension(unsigned int component) const
Returns the min or max of the requested dimension respectively.
bool isBoundaryFullyExternalToSubdomains(BoundaryID bid, const std::set< SubdomainID > &blk_group) const
Returns whether a boundary (given by its id) is not crossing through a group of blocks,...
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
std::unordered_map< dof_id_type, SubdomainID > _node_block
The subdomain of the elements incident on a node, for the nodes whose incident elements all agree,...
void setAxisymmetricCoordAxis(const MooseEnum &rz_coord_axis)
For axisymmetric simulations, set the symmetry coordinate axis.
void needsPrepareForUse()
If this method is called, we will call libMesh's prepare_for_use method when we call Moose's prepare ...
const libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems,...
std::map< std::pair< libMesh::ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_refinement_map
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
Method to construct a libMesh::MeshBase object that is normally set and used by the MooseMesh object ...
bool _built_from_other_mesh
Whether or not this mesh was built from another mesh.
virtual dof_id_type nElem() const
const std::set< SubdomainID > & getBlockConnectedBlocks(const SubdomainID subdomain_id) const
Get the list of subdomains neighboring a given subdomain.
std::set< Elem * > _ghost_elems_from_ghost_boundaries
Set of elements ghosted by ghostGhostedBoundaries.
std::vector< const ElemInfo * > _elem_info
Holds only those ElemInfo objects that have processor_id equal to this process's id,...
std::unordered_map< dof_id_type, std::set< SubdomainID > > _interface_node_blocks
The full subdomain set of the nodes whose incident elements disagree, that is the nodes on a subdomai...
bool usingGeneralAxisymmetricCoordAxes() const
Returns true if general axisymmetric coordinate axes are being used.
std::set< dof_id_type > getAllElemIDs(unsigned int elem_id_index) const
Return all the unique element IDs for an extra element integer with its index.
std::vector< BndNode > _extra_bnd_nodes
void buildHRefinementAndCoarseningMaps(Assembly *assembly)
std::set< unsigned int > _ghosted_boundaries
std::vector< dof_id_type > _min_ids
Minimum integer ID for each extra element integer.
libMesh::StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > * getBoundaryElementRange()
std::unordered_map< SubdomainID, std::set< SubdomainID > > _block_singletons
For each subdomain, a std::set containing just that subdomain ID, e.g.
bool isBoundaryNode(dof_id_type node_id) const
Returns true if the requested node is in the list of boundary nodes, false otherwise.
RealVectorValue _half_range
A convenience vector used to hold values in each dimension representing half of the range.
MeshBase::element_iterator activeLocalElementsBegin()
Calls active_local_nodes_begin/end() on the underlying libMesh mesh object.
unsigned int _max_sides_per_elem
The maximum number of sides per element.
bool isSemiLocal(Node *const node) const
Returns true if the node is semi-local.
void buildPRefinementAndCoarseningMaps(Assembly *assembly)
static void setPartitioner(MeshBase &mesh_base, MooseEnum &partitioner, bool use_distributed_mesh, const InputParameters ¶ms, MooseObject &context_obj)
Method for setting the partitioner on the passed in mesh_base object.
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > buildActiveSideList() const
Calls BoundaryInfo::build_active_side_list.
bool detectOrthogonalDimRanges(Real tol=1e-6)
This routine determines whether the Mesh is a regular orthogonal mesh (i.e.
std::unordered_map< dof_id_type, std::vector< dof_id_type > > & internalNodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected.
Every object that can be built by the factory should be derived from this class.
static InputParameters validParams()
MooseApp & _app
The MOOSE application this is associated with.
Physical unit management class with runtime unit string parsing, unit checking, unit conversion,...
SystemBase & sys()
Get the system this variable is part of.
unsigned int number() const
Get variable number coming from libMesh.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
Interface for objects interacting with the PerfGraph.
const Point & getPoint(const PointObject &item) const
get a Point reference from the PointData object at index idx in the list
Helper object for holding qp mapping info.
unsigned int _from
The qp to map from.
unsigned int _to
The qp to map to.
Real _distance
The distance between them.
A class for creating restricted objects.
void mooseWarning(Args &&... args) const
void paramWarning(const std::string ¶m, Args... args) const
void mooseDeprecated(Args &&... args) const
Base class for a system (of equations)
unsigned int number() const
Gets the number of this system.
void max(const T &r, T &o, Request &req) const
void min(const T &r, T &o, Request &req) const
void set_union(T &data, const unsigned int root_id) const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
virtual void write(const std::string &name) override
static constexpr dof_id_type invalid_id
unsigned int n_systems() const
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
void uniformly_refine(unsigned int n=1)
void uniformly_p_refine(unsigned int n=1)
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
PeriodicBoundaryBase * boundary(boundary_id_type id)
bool is_my_variable(unsigned int var_num) const
virtual Point get_corresponding_pos(const Point &pt) const=0
boundary_id_type pairedboundary
std::vector< subdomain_id_type > getSubdomainIDs(const libMesh::MeshBase &mesh, const std::vector< SubdomainName > &subdomain_name)
Get the associated subdomainIDs for the subdomain names that are passed in.
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.
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
Gets the boundary ID associated with the given BoundaryName.
SubdomainID getSubdomainID(const SubdomainName &subdomain_name, const MeshBase &mesh)
Gets the subdomain ID associated with the given SubdomainName.
bool elemHasFaceInfo(const Elem &elem, const Elem *const neighbor)
This function infers based on elements if the faceinfo between them belongs to the element or not.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
PatchUpdateType
Type of patch update strategy for modeling node-face constraints or contact.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
std::string stringify(const T &t)
conversion to string
const BoundaryID INVALID_BOUNDARY_ID
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
std::string enum_to_string(const T e)
bool absolute_fuzzy_equals(const T &var1, const T2 &var2, const Real tol=TOLERANCE *TOLERANCE)
const unsigned int invalid_uint
const RemoteElem * remote_elem
static constexpr Real TOLERANCE
std::pair< T, U > ResultItem
SearchParams SearchParameters
const boundary_id_type side_id
BoundaryID _bnd_id
boundary id for the node
libMesh::Node * _node
pointer to the node
The definition of the bnd_elem_iterator struct.
The definition of the bnd_node_iterator struct.
The definition of the elem_info_iterator struct.
The definition of the face_info_iterator struct.
Real distance(const Point &p)
const dof_id_type n_nodes