www.mooseframework.org
MooseMesh.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "MooseMesh.h"
11 #include "Factory.h"
13 #include "MooseUtils.h"
14 #include "MooseApp.h"
15 #include "RelationshipManager.h"
16 #include "PointListAdaptor.h"
17 #include "Executioner.h"
18 #include "NonlinearSystemBase.h"
19 #include "AuxiliarySystem.h"
20 #include "Assembly.h"
21 #include "SubProblem.h"
22 #include "MooseVariableBase.h"
23 #include "MooseMeshUtils.h"
24 #include "MooseAppCoordTransform.h"
25 
26 #include <utility>
27 
28 // libMesh
29 #include "libmesh/bounding_box.h"
30 #include "libmesh/boundary_info.h"
31 #include "libmesh/mesh_tools.h"
32 #include "libmesh/parallel.h"
33 #include "libmesh/mesh_communication.h"
34 #include "libmesh/periodic_boundary_base.h"
35 #include "libmesh/fe_base.h"
36 #include "libmesh/fe_interface.h"
37 #include "libmesh/mesh_inserter_iterator.h"
38 #include "libmesh/mesh_communication.h"
39 #include "libmesh/mesh_inserter_iterator.h"
40 #include "libmesh/mesh_tools.h"
41 #include "libmesh/parallel.h"
42 #include "libmesh/parallel_elem.h"
43 #include "libmesh/parallel_node.h"
44 #include "libmesh/parallel_ghost_sync.h"
45 #include "libmesh/utility.h"
46 #include "libmesh/remote_elem.h"
47 #include "libmesh/linear_partitioner.h"
48 #include "libmesh/centroid_partitioner.h"
49 #include "libmesh/parmetis_partitioner.h"
50 #include "libmesh/hilbert_sfc_partitioner.h"
51 #include "libmesh/morton_sfc_partitioner.h"
52 #include "libmesh/edge_edge2.h"
53 #include "libmesh/mesh_refinement.h"
54 #include "libmesh/quadrature.h"
55 #include "libmesh/boundary_info.h"
56 #include "libmesh/periodic_boundaries.h"
57 #include "libmesh/quadrature_gauss.h"
58 #include "libmesh/point_locator_base.h"
59 #include "libmesh/default_coupling.h"
60 #include "libmesh/ghost_point_neighbors.h"
61 #include "libmesh/fe_type.h"
62 
63 static const int GRAIN_SIZE =
64  1; // the grain_size does not have much influence on our execution speed
65 
66 // Make newer nanoflann API compatible with older nanoflann versions
67 #if NANOFLANN_VERSION < 0x150
68 namespace nanoflann
69 {
70 typedef SearchParams SearchParameters;
71 
72 template <typename T, typename U>
73 using ResultItem = std::pair<T, U>;
74 }
75 #endif
76 
79 {
81 
82  MooseEnum parallel_type("DEFAULT REPLICATED DISTRIBUTED", "DEFAULT");
83  params.addParam<MooseEnum>("parallel_type",
84  parallel_type,
85  "DEFAULT: Use libMesh::ReplicatedMesh unless --distributed-mesh is "
86  "specified on the command line "
87  "REPLICATED: Always use libMesh::ReplicatedMesh "
88  "DISTRIBUTED: Always use libMesh::DistributedMesh");
89 
90  params.addParam<bool>(
91  "allow_renumbering",
92  true,
93  "If allow_renumbering=false, node and element numbers are kept fixed until deletion");
94 
95  params.addParam<bool>("nemesis",
96  false,
97  "If nemesis=true and file=foo.e, actually reads "
98  "foo.e.N.0, foo.e.N.1, ... foo.e.N.N-1, "
99  "where N = # CPUs, with NemesisIO.");
100 
101  MooseEnum dims("1=1 2 3", "1");
102  params.addParam<MooseEnum>("dim",
103  dims,
104  "This is only required for certain mesh formats where "
105  "the dimension of the mesh cannot be autodetected. "
106  "In particular you must supply this for GMSH meshes. "
107  "Note: This is completely ignored for ExodusII meshes!");
108 
109  params.addParam<MooseEnum>(
110  "partitioner",
111  partitioning(),
112  "Specifies a mesh partitioner to use when splitting the mesh for a parallel computation.");
113  MooseEnum direction("x y z radial");
114  params.addParam<MooseEnum>("centroid_partitioner_direction",
115  direction,
116  "Specifies the sort direction if using the centroid partitioner. "
117  "Available options: x, y, z, radial");
118 
119  MooseEnum patch_update_strategy("never always auto iteration", "never");
120  params.addParam<MooseEnum>(
121  "patch_update_strategy",
122  patch_update_strategy,
123  "How often to update the geometric search 'patch'. The default is to "
124  "never update it (which is the most efficient but could be a problem "
125  "with lots of relative motion). 'always' will update the patch for all "
126  "secondary nodes at the beginning of every timestep which might be time "
127  "consuming. 'auto' will attempt to determine at the start of which "
128  "timesteps the patch for all secondary nodes needs to be updated automatically."
129  "'iteration' updates the patch at every nonlinear iteration for a "
130  "subset of secondary nodes for which penetration is not detected. If there "
131  "can be substantial relative motion between the primary and secondary surfaces "
132  "during the nonlinear iterations within a timestep, it is advisable to use "
133  "'iteration' option to ensure accurate contact detection.");
134 
135  // Note: This parameter is named to match 'construct_side_list_from_node_list' in SetupMeshAction
136  params.addParam<bool>(
137  "construct_node_list_from_side_list",
138  true,
139  "Whether or not to generate nodesets from the sidesets (usually a good idea).");
140  params.addParam<unsigned int>(
141  "patch_size", 40, "The number of nodes to consider in the NearestNode neighborhood.");
142  params.addParam<unsigned int>("ghosting_patch_size",
143  "The number of nearest neighbors considered "
144  "for ghosting purposes when 'iteration' "
145  "patch update strategy is used. Default is "
146  "5 * patch_size.");
147  params.addParam<unsigned int>("max_leaf_size",
148  10,
149  "The maximum number of points in each leaf of the KDTree used in "
150  "the nearest neighbor search. As the leaf size becomes larger,"
151  "KDTree construction becomes faster but the nearest neighbor search"
152  "becomes slower.");
153 
154  params.addParam<bool>("build_all_side_lowerd_mesh",
155  false,
156  "True to build the lower-dimensional mesh for all sides.");
157 
158  params.addParam<bool>("skip_refine_when_use_split",
159  true,
160  "True to skip uniform refinements when using a pre-split mesh.");
161 
162  params.addParam<std::vector<SubdomainID>>(
163  "add_subdomain_ids",
164  "The listed subdomains will be assumed valid for the mesh. This permits setting up subdomain "
165  "restrictions for subdomains initially containing no elements, which can occur, for example, "
166  "in additive manufacturing simulations which dynamically add and remove elements.");
167 
169 
170  // This indicates that the derived mesh type accepts a MeshGenerator, and should be set to true in
171  // derived types that do so.
172  params.addPrivateParam<bool>("_mesh_generator_mesh", false);
173 
174  // Whether or not the mesh is pre split
175  params.addPrivateParam<bool>("_is_split", false);
176 
177  params.registerBase("MooseMesh");
178 
179  // groups
180  params.addParamNamesToGroup(
181  "dim nemesis patch_update_strategy construct_node_list_from_side_list patch_size",
182  "Advanced");
183  params.addParamNamesToGroup("partitioner centroid_partitioner_direction", "Partitioning");
184 
185  return params;
186 }
187 
189  : MooseObject(parameters),
190  Restartable(this, "Mesh"),
191  PerfGraphInterface(this),
192  _parallel_type(getParam<MooseEnum>("parallel_type").getEnum<MooseMesh::ParallelType>()),
193  _use_distributed_mesh(false),
194  _distribution_overridden(false),
195  _parallel_type_overridden(false),
196  _mesh(nullptr),
197  _partitioner_name(getParam<MooseEnum>("partitioner")),
198  _partitioner_overridden(false),
199  _custom_partitioner_requested(false),
200  _uniform_refine_level(0),
201  _skip_refine_when_use_split(getParam<bool>("skip_refine_when_use_split")),
202  _skip_deletion_repartition_after_refine(false),
203  _is_nemesis(getParam<bool>("nemesis")),
204  _node_to_elem_map_built(false),
205  _node_to_active_semilocal_elem_map_built(false),
206  _patch_size(getParam<unsigned int>("patch_size")),
207  _ghosting_patch_size(isParamValid("ghosting_patch_size")
208  ? getParam<unsigned int>("ghosting_patch_size")
209  : 5 * _patch_size),
210  _max_leaf_size(getParam<unsigned int>("max_leaf_size")),
211  _patch_update_strategy(
212  getParam<MooseEnum>("patch_update_strategy").getEnum<Moose::PatchUpdateType>()),
213  _regular_orthogonal_mesh(false),
214  _is_split(getParam<bool>("_is_split")),
215  _has_lower_d(false),
216  _allow_recovery(true),
217  _construct_node_list_from_side_list(getParam<bool>("construct_node_list_from_side_list")),
218  _need_delete(false),
219  _allow_remote_element_removal(true),
220  _need_ghost_ghosted_boundaries(true),
221  _is_displaced(false),
222  _rz_coord_axis(getParam<MooseEnum>("rz_coord_axis")),
223  _coord_system_set(false),
224  _doing_p_refinement(false)
225 {
226  if (isParamValid("ghosting_patch_size") && (_patch_update_strategy != Moose::Iteration))
227  mooseError("Ghosting patch size parameter has to be set in the mesh block "
228  "only when 'iteration' patch update strategy is used.");
229 
230  if (isParamValid("coord_block"))
231  {
232  if (isParamValid("block"))
233  paramWarning("block",
234  "You set both 'Mesh/block' and 'Mesh/coord_block'. The value of "
235  "'Mesh/coord_block' will be used.");
236 
237  _provided_coord_blocks = getParam<std::vector<SubdomainName>>("coord_block");
238  }
239  else if (isParamValid("block"))
240  _provided_coord_blocks = getParam<std::vector<SubdomainName>>("block");
241 
242  if (getParam<bool>("build_all_side_lowerd_mesh"))
243  // Do not initially allow removal of remote elements
245 
247 }
248 
249 MooseMesh::MooseMesh(const MooseMesh & other_mesh)
250  : MooseObject(other_mesh._pars),
251  Restartable(this, "Mesh"),
252  PerfGraphInterface(this, "CopiedMesh"),
253  _built_from_other_mesh(true),
254  _parallel_type(other_mesh._parallel_type),
255  _use_distributed_mesh(other_mesh._use_distributed_mesh),
256  _distribution_overridden(other_mesh._distribution_overridden),
257  _parallel_type_overridden(other_mesh._parallel_type_overridden),
258  _mesh(other_mesh.getMesh().clone()),
259  _partitioner_name(other_mesh._partitioner_name),
260  _partitioner_overridden(other_mesh._partitioner_overridden),
261  _custom_partitioner_requested(other_mesh._custom_partitioner_requested),
262  _uniform_refine_level(other_mesh.uniformRefineLevel()),
263  _skip_refine_when_use_split(other_mesh._skip_refine_when_use_split),
264  _skip_deletion_repartition_after_refine(other_mesh._skip_deletion_repartition_after_refine),
265  _is_nemesis(false),
266  _node_to_elem_map_built(false),
267  _node_to_active_semilocal_elem_map_built(false),
268  _patch_size(other_mesh._patch_size),
269  _ghosting_patch_size(other_mesh._ghosting_patch_size),
270  _max_leaf_size(other_mesh._max_leaf_size),
271  _patch_update_strategy(other_mesh._patch_update_strategy),
272  _regular_orthogonal_mesh(false),
273  _is_split(other_mesh._is_split),
274  _has_lower_d(other_mesh._has_lower_d),
275  _allow_recovery(other_mesh._allow_recovery),
276  _construct_node_list_from_side_list(other_mesh._construct_node_list_from_side_list),
277  _need_delete(other_mesh._need_delete),
278  _allow_remote_element_removal(other_mesh._allow_remote_element_removal),
279  _need_ghost_ghosted_boundaries(other_mesh._need_ghost_ghosted_boundaries),
280  _coord_sys(other_mesh._coord_sys),
281  _rz_coord_axis(other_mesh._rz_coord_axis),
282  _subdomain_id_to_rz_coord_axis(other_mesh._subdomain_id_to_rz_coord_axis),
283  _coord_system_set(other_mesh._coord_system_set),
284  _provided_coord_blocks(other_mesh._provided_coord_blocks),
285  _doing_p_refinement(other_mesh._doing_p_refinement)
286 {
287  // Note: this calls BoundaryInfo::operator= without changing the
288  // ownership semantics of either Mesh's BoundaryInfo object.
289  getMesh().get_boundary_info() = other_mesh.getMesh().get_boundary_info();
290 
291  const std::set<SubdomainID> & subdomains = other_mesh.meshSubdomains();
292  for (const auto & sbd_id : subdomains)
293  setSubdomainName(sbd_id, other_mesh.getMesh().subdomain_name(sbd_id));
294 
295  // Get references to BoundaryInfo objects to make the code below cleaner...
296  const BoundaryInfo & other_boundary_info = other_mesh.getMesh().get_boundary_info();
297  BoundaryInfo & boundary_info = getMesh().get_boundary_info();
298 
299  // Use the other BoundaryInfo object to build the list of side boundary ids
300  std::vector<BoundaryID> side_boundaries;
301  other_boundary_info.build_side_boundary_ids(side_boundaries);
302 
303  // Assign those boundary ids in our BoundaryInfo object
304  for (const auto & side_bnd_id : side_boundaries)
305  boundary_info.sideset_name(side_bnd_id) = other_boundary_info.get_sideset_name(side_bnd_id);
306 
307  // Do the same thing for node boundary ids
308  std::vector<BoundaryID> node_boundaries;
309  other_boundary_info.build_node_boundary_ids(node_boundaries);
310 
311  for (const auto & node_bnd_id : node_boundaries)
312  boundary_info.nodeset_name(node_bnd_id) = other_boundary_info.get_nodeset_name(node_bnd_id);
313 
314  _bounds.resize(other_mesh._bounds.size());
315  for (std::size_t i = 0; i < _bounds.size(); ++i)
316  {
317  _bounds[i].resize(other_mesh._bounds[i].size());
318  for (std::size_t j = 0; j < _bounds[i].size(); ++j)
319  _bounds[i][j] = other_mesh._bounds[i][j];
320  }
321 
323 }
324 
326 {
327  freeBndNodes();
328  freeBndElems();
330 }
331 
332 void
334 {
335  // free memory
336  for (auto & bnode : _bnd_nodes)
337  delete bnode;
338 
339  for (auto & it : _node_set_nodes)
340  it.second.clear();
341 
342  _node_set_nodes.clear();
343 
344  for (auto & it : _bnd_node_ids)
345  it.second.clear();
346 
347  _bnd_node_ids.clear();
348 }
349 
350 void
352 {
353  // free memory
354  for (auto & belem : _bnd_elems)
355  delete belem;
356 
357  for (auto & it : _bnd_elem_ids)
358  it.second.clear();
359 
360  _bnd_elem_ids.clear();
361 }
362 
363 bool
364 MooseMesh::prepare(const MeshBase * const mesh_to_clone)
365 {
366  TIME_SECTION("prepare", 2, "Preparing Mesh", true);
367 
368  bool called_prepare_for_use = false;
369 
370  mooseAssert(_mesh, "The MeshBase has not been constructed");
371 
372  if (!dynamic_cast<DistributedMesh *>(&getMesh()) || _is_nemesis)
373  // For whatever reason we do not want to allow renumbering here nor ever in the future?
374  getMesh().allow_renumbering(false);
375 
376  if (mesh_to_clone)
377  {
378  mooseAssert(mesh_to_clone->is_prepared(),
379  "The mesh we wish to clone from must already be prepared");
380  _mesh = mesh_to_clone->clone();
381  _moose_mesh_prepared = false;
382  }
383  else if (!_mesh->is_prepared())
384  {
385  _mesh->prepare_for_use();
386  _moose_mesh_prepared = false;
387  called_prepare_for_use = true;
388  }
389 
391  return called_prepare_for_use;
392 
393  // Collect (local) subdomain IDs
394  _mesh_subdomains.clear();
395  for (const auto & elem : getMesh().element_ptr_range())
396  _mesh_subdomains.insert(elem->subdomain_id());
397 
398  // add explicitly requested subdomains
399  if (isParamValid("add_subdomain_ids"))
400  {
401  const auto add_subdomain_id = getParam<std::vector<SubdomainID>>("add_subdomain_ids");
402  _mesh_subdomains.insert(add_subdomain_id.begin(), add_subdomain_id.end());
403  }
404 
405  // Make sure nodesets have been generated
407 
408  // Collect (local) boundary IDs
409  const std::set<BoundaryID> & local_bids = getMesh().get_boundary_info().get_boundary_ids();
410  _mesh_boundary_ids.insert(local_bids.begin(), local_bids.end());
411 
412  const std::set<BoundaryID> & local_node_bids =
413  getMesh().get_boundary_info().get_node_boundary_ids();
414  _mesh_nodeset_ids.insert(local_node_bids.begin(), local_node_bids.end());
415 
416  const std::set<BoundaryID> & local_side_bids =
417  getMesh().get_boundary_info().get_side_boundary_ids();
418  _mesh_sideset_ids.insert(local_side_bids.begin(), local_side_bids.end());
419 
420  // Communicate subdomain and boundary IDs if this is a parallel mesh
421  if (!getMesh().is_serial())
422  {
427  }
428 
430  {
431  if (!_coord_system_set)
432  setCoordSystem(_provided_coord_blocks, getParam<MultiMooseEnum>("coord_type"));
433  else if (_pars.isParamSetByUser("coord_type"))
434  mooseError(
435  "Trying to set coordinate system type information based on the user input file, but "
436  "the coordinate system type information has already been set programmatically! "
437  "Either remove your coordinate system type information from the input file, or contact "
438  "your application developer");
439  }
440 
441  // Set general axisymmetric axes if provided
442  if (isParamValid("rz_coord_blocks") && isParamValid("rz_coord_origins") &&
443  isParamValid("rz_coord_directions"))
444  {
445  const auto rz_coord_blocks = getParam<std::vector<SubdomainName>>("rz_coord_blocks");
446  const auto rz_coord_origins = getParam<std::vector<Point>>("rz_coord_origins");
447  const auto rz_coord_directions = getParam<std::vector<RealVectorValue>>("rz_coord_directions");
448  if (rz_coord_origins.size() == rz_coord_blocks.size() &&
449  rz_coord_directions.size() == rz_coord_blocks.size())
450  {
451  std::vector<std::pair<Point, RealVectorValue>> rz_coord_axes;
452  for (unsigned int i = 0; i < rz_coord_origins.size(); ++i)
453  rz_coord_axes.push_back(std::make_pair(rz_coord_origins[i], rz_coord_directions[i]));
454 
455  setGeneralAxisymmetricCoordAxes(rz_coord_blocks, rz_coord_axes);
456 
457  if (isParamSetByUser("rz_coord_axis"))
458  mooseError("The parameter 'rz_coord_axis' may not be provided if 'rz_coord_blocks', "
459  "'rz_coord_origins', and 'rz_coord_directions' are provided.");
460  }
461  else
462  mooseError("The parameters 'rz_coord_blocks', 'rz_coord_origins', and "
463  "'rz_coord_directions' must all have the same size.");
464  }
465  else if (isParamValid("rz_coord_blocks") || isParamValid("rz_coord_origins") ||
466  isParamValid("rz_coord_directions"))
467  mooseError("If any of the parameters 'rz_coord_blocks', 'rz_coord_origins', and "
468  "'rz_coord_directions' are provided, then all must be provided.");
469 
471 
472  update();
473 
474  // Check if there is subdomain name duplication for the same subdomain ID
476 
477  _moose_mesh_prepared = true;
478 
479  return called_prepare_for_use;
480 }
481 
482 void
484 {
485  TIME_SECTION("update", 3, "Updating Mesh", true);
486 
487  // Rebuild the boundary conditions
489 
490  // Update the node to elem map
491  _node_to_elem_map.clear();
492  _node_to_elem_map_built = false;
495 
496  buildNodeList();
498  cacheInfo();
499  buildElemIDInfo();
500 
502 }
503 
504 void
506 {
507  auto & mesh = getMesh();
508 
509  if (!mesh.is_serial())
510  mooseError(
511  "Hybrid finite element method must use replicated mesh.\nCurrently lower-dimensional mesh "
512  "does not support mesh re-partitioning and a debug assertion being hit related with "
513  "neighbors of lower-dimensional element, with distributed mesh.");
514 
515  // Lower-D element build requires neighboring element information
516  if (!mesh.is_prepared())
517  mesh.find_neighbors();
518 
519  // maximum number of sides of all elements
520  unsigned int max_n_sides = 0;
521 
522  // remove existing lower-d element first
523  std::set<Elem *> deleteable_elems;
524  for (auto & elem : mesh.element_ptr_range())
525  if (elem->subdomain_id() == Moose::INTERNAL_SIDE_LOWERD_ID ||
526  elem->subdomain_id() == Moose::BOUNDARY_SIDE_LOWERD_ID)
527  deleteable_elems.insert(elem);
528  else if (elem->n_sides() > max_n_sides)
529  max_n_sides = elem->n_sides();
530 
531  for (auto & elem : deleteable_elems)
532  mesh.delete_elem(elem);
533 
534  mesh.comm().max(max_n_sides);
535 
536  deleteable_elems.clear();
537 
538  dof_id_type max_elem_id = mesh.max_elem_id();
539  unique_id_type max_unique_id = mesh.parallel_max_unique_id();
540 
541  std::vector<Elem *> side_elems;
543  for (const auto & elem : mesh.active_element_ptr_range())
544  {
545  // skip existing lower-d elements
546  if (elem->interior_parent())
547  continue;
548 
549  for (const auto side : elem->side_index_range())
550  {
551  Elem * neig = elem->neighbor_ptr(side);
552 
553  bool build_side = false;
554  if (!neig)
555  build_side = true;
556  else
557  {
558  mooseAssert(!neig->is_remote(), "We error if the mesh is not serial");
559  if (!neig->active())
560  build_side = true;
561  else if (neig->level() == elem->level() && elem->id() < neig->id())
562  build_side = true;
563  }
564 
565  if (build_side)
566  {
567  std::unique_ptr<Elem> side_elem(elem->build_side_ptr(side, false));
568 
569  // The side will be added with the same processor id as the parent.
570  side_elem->processor_id() = elem->processor_id();
571 
572  // Add subdomain ID
573  if (neig)
574  side_elem->subdomain_id() = Moose::INTERNAL_SIDE_LOWERD_ID;
575  else
576  side_elem->subdomain_id() = Moose::BOUNDARY_SIDE_LOWERD_ID;
577 
578  // set ids consistently across processors (these ids will be temporary)
579  side_elem->set_id(max_elem_id + elem->id() * max_n_sides + side);
580  side_elem->set_unique_id(max_unique_id + elem->id() * max_n_sides + side);
581 
582  // Also assign the side's interior parent, so it is always
583  // easy to figure out the Elem we came from.
584  // Note: the interior parent could be a ghost element.
585  side_elem->set_interior_parent(elem);
586 
587  side_elems.push_back(side_elem.release());
588 
589  // add link between higher d element to lower d element
590  auto pair = std::make_pair(elem, side);
591  auto link = std::make_pair(pair, side_elems.back());
592  auto ilink = std::make_pair(side_elems.back(), side);
595  }
596  }
597  }
598 
599  // finally, add the lower-dimensional element to the mesh
600  // Note: lower-d interior element will exist on a processor if its associated interior
601  // parent exists on a processor whether or not being a ghost. Lower-d elements will
602  // get its interior parent's processor id.
603  for (auto & elem : side_elems)
604  mesh.add_elem(elem);
605 
607  mesh.subdomain_name(Moose::INTERNAL_SIDE_LOWERD_ID) = "INTERNAL_SIDE_LOWERD_SUBDOMAIN";
609  mesh.subdomain_name(Moose::BOUNDARY_SIDE_LOWERD_ID) = "BOUNDARY_SIDE_LOWERD_SUBDOMAIN";
610 
611  // we do all the stuff in prepare_for_use such as renumber_nodes_and_elements(),
612  // update_parallel_id_counts(), cache_elem_dims(), etc. except partitioning here.
613  const bool skip_partitioning_old = mesh.skip_partitioning();
614  mesh.skip_partitioning(true);
615  // Finding neighbors is ambiguous for lower-dimensional elements on interior faces
616  mesh.allow_find_neighbors(false);
617  mesh.prepare_for_use();
618  mesh.skip_partitioning(skip_partitioning_old);
619 }
620 
621 const Node &
623 {
624  mooseDeprecated("MooseMesh::node() is deprecated, please use MooseMesh::nodeRef() instead");
625  return nodeRef(i);
626 }
627 
628 Node &
630 {
631  mooseDeprecated("MooseMesh::node() is deprecated, please use MooseMesh::nodeRef() instead");
632  return nodeRef(i);
633 }
634 
635 const Node &
637 {
638  const auto node_ptr = queryNodePtr(i);
639  mooseAssert(node_ptr, "Missing node");
640  return *node_ptr;
641 }
642 
643 Node &
645 {
646  return const_cast<Node &>(const_cast<const MooseMesh *>(this)->nodeRef(i));
647 }
648 
649 const Node *
651 {
652  return &nodeRef(i);
653 }
654 
655 Node *
657 {
658  return &nodeRef(i);
659 }
660 
661 const Node *
663 {
664  if (i > getMesh().max_node_id())
665  {
666  auto it = _quadrature_nodes.find(i);
667  if (it == _quadrature_nodes.end())
668  return nullptr;
669  auto & node_ptr = it->second;
670  mooseAssert(node_ptr, "Uninitialized quadrature node");
671  return node_ptr;
672  }
673 
674  return getMesh().query_node_ptr(i);
675 }
676 
677 Node *
679 {
680  return const_cast<Node *>(const_cast<const MooseMesh *>(this)->queryNodePtr(i));
681 }
682 
683 void
685 {
686  TIME_SECTION("meshChanged", 3, "Updating Because Mesh Changed");
687 
688  update();
689 
690  // Delete all of the cached ranges
691  _active_local_elem_range.reset();
692  _active_node_range.reset();
694  _local_node_range.reset();
695  _bnd_node_range.reset();
696  _bnd_elem_range.reset();
697 
698  // Rebuild the ranges
704 
705  // Call the callback function onMeshChanged
706  onMeshChanged();
707 }
708 
709 void
711 {
712 }
713 
714 void
716 {
717  TIME_SECTION("cacheChangedLists", 5, "Caching Changed Lists");
718 
719  ConstElemRange elem_range(getMesh().local_elements_begin(), getMesh().local_elements_end(), 1);
720  CacheChangedListsThread cclt(*this);
721  Threads::parallel_reduce(elem_range, cclt);
722 
724 
725  _refined_elements = std::make_unique<ConstElemPointerRange>(cclt._refined_elements.begin(),
726  cclt._refined_elements.end());
727  _coarsened_elements = std::make_unique<ConstElemPointerRange>(cclt._coarsened_elements.begin(),
728  cclt._coarsened_elements.end());
730 }
731 
734 {
735  return _refined_elements.get();
736 }
737 
740 {
741  return _coarsened_elements.get();
742 }
743 
744 const std::vector<const Elem *> &
745 MooseMesh::coarsenedElementChildren(const Elem * elem) const
746 {
747  auto elem_to_child_pair = _coarsened_element_children.find(elem);
748  mooseAssert(elem_to_child_pair != _coarsened_element_children.end(), "Missing element in map");
749  return elem_to_child_pair->second;
750 }
751 
752 void
753 MooseMesh::updateActiveSemiLocalNodeRange(std::set<dof_id_type> & ghosted_elems)
754 {
755  TIME_SECTION("updateActiveSemiLocalNodeRange", 5, "Updating ActiveSemiLocalNode Range");
756 
757  _semilocal_node_list.clear();
758 
759  // First add the nodes connected to local elems
760  ConstElemRange * active_local_elems = getActiveLocalElementRange();
761  for (const auto & elem : *active_local_elems)
762  {
763  for (unsigned int n = 0; n < elem->n_nodes(); ++n)
764  {
765  // Since elem is const here but we require a non-const Node * to
766  // store in the _semilocal_node_list (otherwise things like
767  // UpdateDisplacedMeshThread don't work), we are using a
768  // const_cast. A more long-term fix would be to have
769  // getActiveLocalElementRange return a non-const ElemRange.
770  Node * node = const_cast<Node *>(elem->node_ptr(n));
771 
772  _semilocal_node_list.insert(node);
773  }
774  }
775 
776  // Now add the nodes connected to ghosted_elems
777  for (const auto & ghost_elem_id : ghosted_elems)
778  {
779  Elem * elem = getMesh().elem_ptr(ghost_elem_id);
780  for (unsigned int n = 0; n < elem->n_nodes(); n++)
781  {
782  Node * node = elem->node_ptr(n);
783 
784  _semilocal_node_list.insert(node);
785  }
786  }
787 
788  // Now create the actual range
789  _active_semilocal_node_range = std::make_unique<SemiLocalNodeRange>(_semilocal_node_list.begin(),
790  _semilocal_node_list.end());
791 }
792 
793 bool
794 MooseMesh::isSemiLocal(Node * const node) const
795 {
796  return _semilocal_node_list.find(node) != _semilocal_node_list.end();
797 }
798 
804 {
805 public:
807 
808  bool operator()(const BndNode * const & lhs, const BndNode * const & rhs)
809  {
810  if (lhs->_bnd_id < rhs->_bnd_id)
811  return true;
812 
813  if (lhs->_bnd_id > rhs->_bnd_id)
814  return false;
815 
816  if (lhs->_node->id() < rhs->_node->id())
817  return true;
818 
819  if (lhs->_node->id() > rhs->_node->id())
820  return false;
821 
822  return false;
823  }
824 };
825 
826 void
828 {
829  TIME_SECTION("buildNodeList", 5, "Building Node List");
830 
831  freeBndNodes();
832 
833  auto bc_tuples = getMesh().get_boundary_info().build_node_list();
834 
835  int n = bc_tuples.size();
836  _bnd_nodes.clear();
837  _bnd_nodes.reserve(n);
838  for (const auto & t : bc_tuples)
839  {
840  auto node_id = std::get<0>(t);
841  auto bc_id = std::get<1>(t);
842 
843  _bnd_nodes.push_back(new BndNode(getMesh().node_ptr(node_id), bc_id));
844  _node_set_nodes[bc_id].push_back(node_id);
845  _bnd_node_ids[bc_id].insert(node_id);
846  }
847 
848  _bnd_nodes.reserve(_bnd_nodes.size() + _extra_bnd_nodes.size());
849  for (unsigned int i = 0; i < _extra_bnd_nodes.size(); i++)
850  {
851  BndNode * bnode = new BndNode(_extra_bnd_nodes[i]._node, _extra_bnd_nodes[i]._bnd_id);
852  _bnd_nodes.push_back(bnode);
853  _bnd_node_ids[std::get<1>(bc_tuples[i])].insert(_extra_bnd_nodes[i]._node->id());
854  }
855 
856  // This sort is here so that boundary conditions are always applied in the same order
857  std::sort(_bnd_nodes.begin(), _bnd_nodes.end(), BndNodeCompare());
858 }
859 
860 void
862 {
863  unsigned int n = getMesh().n_elem_integers() + 1;
864 
865  _block_id_mapping.clear();
866  _max_ids.clear();
867  _min_ids.clear();
868  _id_identical_flag.clear();
869 
870  _block_id_mapping.resize(n);
873  _id_identical_flag.resize(n, std::vector<bool>(n, true));
874  for (const auto & elem : getMesh().active_local_element_ptr_range())
875  for (unsigned int i = 0; i < n; ++i)
876  {
877  auto id = (i == n - 1 ? elem->subdomain_id() : elem->get_extra_integer(i));
878  _block_id_mapping[i][elem->subdomain_id()].insert(id);
879  if (id > _max_ids[i])
880  _max_ids[i] = id;
881  if (id < _min_ids[i])
882  _min_ids[i] = id;
883  for (unsigned int j = 0; j < n; ++j)
884  {
885  auto idj = (j == n - 1 ? elem->subdomain_id() : elem->get_extra_integer(j));
886  if (i != j && _id_identical_flag[i][j] && id != idj)
887  _id_identical_flag[i][j] = false;
888  }
889  }
890 
891  for (unsigned int i = 0; i < n; ++i)
892  {
893  for (auto & blk : meshSubdomains())
894  comm().set_union(_block_id_mapping[i][blk]);
896  }
897  comm().max(_max_ids);
898  comm().min(_min_ids);
899 }
900 
901 std::unordered_map<dof_id_type, std::set<dof_id_type>>
902 MooseMesh::getElemIDMapping(const std::string & from_id_name, const std::string & to_id_name) const
903 {
904  auto & mesh_base = getMesh();
905 
906  if (!mesh_base.has_elem_integer(from_id_name))
907  mooseError("Mesh does not have the element integer name '", from_id_name, "'");
908  if (!mesh_base.has_elem_integer(to_id_name))
909  mooseError("Mesh does not have the element integer name '", to_id_name, "'");
910 
911  const auto id1 = mesh_base.get_elem_integer_index(from_id_name);
912  const auto id2 = mesh_base.get_elem_integer_index(to_id_name);
913 
914  std::unordered_map<dof_id_type, std::set<dof_id_type>> id_map;
915  for (const auto id : getAllElemIDs(id1))
916  id_map[id] = std::set<dof_id_type>();
917 
918  for (const auto & elem : mesh_base.active_local_element_ptr_range())
919  id_map[elem->get_extra_integer(id1)].insert(elem->get_extra_integer(id2));
920 
921  for (auto & [id, ids] : id_map)
922  {
923  libmesh_ignore(id); // avoid overzealous gcc 9.4 unused var warning
924  comm().set_union(ids);
925  }
926 
927  return id_map;
928 }
929 
930 std::set<dof_id_type>
931 MooseMesh::getAllElemIDs(unsigned int elem_id_index) const
932 {
933  std::set<dof_id_type> unique_ids;
934  for (auto & pair : _block_id_mapping[elem_id_index])
935  for (auto & id : pair.second)
936  unique_ids.insert(id);
937  return unique_ids;
938 }
939 
940 std::set<dof_id_type>
941 MooseMesh::getElemIDsOnBlocks(unsigned int elem_id_index, const std::set<SubdomainID> & blks) const
942 {
943  std::set<dof_id_type> unique_ids;
944  for (auto & blk : blks)
945  {
946  auto it = _block_id_mapping[elem_id_index].find(blk);
947  if (it == _block_id_mapping[elem_id_index].end())
948  mooseError("Block ", blk, " is not available on the mesh");
949 
950  for (auto & mid : it->second)
951  unique_ids.insert(mid);
952  }
953  return unique_ids;
954 }
955 
956 void
958 {
959  TIME_SECTION("buildBndElemList", 5, "Building Boundary Elements List");
960 
961  freeBndElems();
962 
963  auto bc_tuples = getMesh().get_boundary_info().build_active_side_list();
964 
965  int n = bc_tuples.size();
966  _bnd_elems.clear();
967  _bnd_elems.reserve(n);
968  for (const auto & t : bc_tuples)
969  {
970  auto elem_id = std::get<0>(t);
971  auto side_id = std::get<1>(t);
972  auto bc_id = std::get<2>(t);
973 
974  _bnd_elems.push_back(new BndElement(getMesh().elem_ptr(elem_id), side_id, bc_id));
975  _bnd_elem_ids[bc_id].insert(elem_id);
976  }
977 }
978 
979 const std::map<dof_id_type, std::vector<dof_id_type>> &
981 {
982  if (!_node_to_elem_map_built) // Guard the creation with a double checked lock
983  {
984  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
985 
987  {
988  // This is allowing the timing to be run even with threads
989  // This is safe because all threads will be waiting on this section when it runs
990  // NOTE: Do not copy this construction to other places without thinking REALLY hard about it
991  // The PerfGraph is NOT threadsafe and will cause all kinds of havok if care isn't taken
992  auto in_threads = Threads::in_threads;
993  Threads::in_threads = false;
994  TIME_SECTION("nodeToElemMap", 5, "Building Node To Elem Map");
995  Threads::in_threads = in_threads;
996 
997  for (const auto & elem : getMesh().active_element_ptr_range())
998  for (unsigned int n = 0; n < elem->n_nodes(); n++)
999  _node_to_elem_map[elem->node_id(n)].push_back(elem->id());
1000 
1001  _node_to_elem_map_built = true; // MUST be set at the end for double-checked locking to work!
1002  }
1003  }
1004  return _node_to_elem_map;
1005 }
1006 
1007 const std::map<dof_id_type, std::vector<dof_id_type>> &
1009 {
1010  if (!_node_to_active_semilocal_elem_map_built) // Guard the creation with a double checked lock
1011  {
1012  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1013 
1014  // This is allowing the timing to be run even with threads
1015  // This is safe because all threads will be waiting on this section when it runs
1016  // NOTE: Do not copy this construction to other places without thinking REALLY hard about it
1017  // The PerfGraph is NOT threadsafe and will cause all kinds of havok if care isn't taken
1018  auto in_threads = Threads::in_threads;
1019  Threads::in_threads = false;
1020  TIME_SECTION("nodeToActiveSemilocalElemMap", 5, "Building SemiLocalElemMap");
1021  Threads::in_threads = in_threads;
1022 
1024  {
1025  for (const auto & elem :
1026  as_range(getMesh().semilocal_elements_begin(), getMesh().semilocal_elements_end()))
1027  if (elem->active())
1028  for (unsigned int n = 0; n < elem->n_nodes(); n++)
1029  _node_to_active_semilocal_elem_map[elem->node_id(n)].push_back(elem->id());
1030 
1032  true; // MUST be set at the end for double-checked locking to work!
1033  }
1034  }
1035 
1037 }
1038 
1041 {
1043  {
1044  TIME_SECTION("getActiveLocalElementRange", 5);
1045 
1046  _active_local_elem_range = std::make_unique<ConstElemRange>(
1047  getMesh().active_local_elements_begin(), getMesh().active_local_elements_end(), GRAIN_SIZE);
1048  }
1049 
1050  return _active_local_elem_range.get();
1051 }
1052 
1053 NodeRange *
1055 {
1056  if (!_active_node_range)
1057  {
1058  TIME_SECTION("getActiveNodeRange", 5);
1059 
1060  _active_node_range = std::make_unique<NodeRange>(
1061  getMesh().active_nodes_begin(), getMesh().active_nodes_end(), GRAIN_SIZE);
1062  }
1063 
1064  return _active_node_range.get();
1065 }
1066 
1069 {
1070  mooseAssert(_active_semilocal_node_range,
1071  "_active_semilocal_node_range has not been created yet!");
1072 
1073  return _active_semilocal_node_range.get();
1074 }
1075 
1078 {
1079  if (!_local_node_range)
1080  {
1081  TIME_SECTION("getLocalNodeRange", 5);
1082 
1083  _local_node_range = std::make_unique<ConstNodeRange>(
1084  getMesh().local_nodes_begin(), getMesh().local_nodes_end(), GRAIN_SIZE);
1085  }
1086 
1087  return _local_node_range.get();
1088 }
1089 
1092 {
1093  if (!_bnd_node_range)
1094  {
1095  TIME_SECTION("getBoundaryNodeRange", 5);
1096 
1097  _bnd_node_range =
1098  std::make_unique<ConstBndNodeRange>(bndNodesBegin(), bndNodesEnd(), GRAIN_SIZE);
1099  }
1100 
1101  return _bnd_node_range.get();
1102 }
1103 
1106 {
1107  if (!_bnd_elem_range)
1108  {
1109  TIME_SECTION("getBoundaryElementRange", 5);
1110 
1111  _bnd_elem_range =
1112  std::make_unique<ConstBndElemRange>(bndElemsBegin(), bndElemsEnd(), GRAIN_SIZE);
1113  }
1114 
1115  return _bnd_elem_range.get();
1116 }
1117 
1118 const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
1120 {
1121  mooseDeprecated("MooseMesh::getBoundariesToElems is deprecated, "
1122  "use MooseMesh::getBoundariesToActiveSemiLocalElemIds");
1124 }
1125 
1126 const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
1128 {
1129  return _bnd_elem_ids;
1130 }
1131 
1132 std::unordered_set<dof_id_type>
1134 {
1135  // The boundary to element map is computed on every mesh update
1136  const auto it = _bnd_elem_ids.find(bid);
1137  if (it == _bnd_elem_ids.end())
1138  // Boundary is not local to this domain, return an empty set
1139  return std::unordered_set<dof_id_type>{};
1140  return it->second;
1141 }
1142 
1143 std::unordered_set<dof_id_type>
1145 {
1146  // Vector of boundary elems is updated every mesh update
1147  std::unordered_set<dof_id_type> neighbor_elems;
1148  for (const auto & bnd_elem : _bnd_elems)
1149  {
1150  const auto & [elem_ptr, elem_side, elem_bid] = *bnd_elem;
1151  if (elem_bid == bid)
1152  {
1153  const auto * neighbor = elem_ptr->neighbor_ptr(elem_side);
1154  // Dont add fully remote elements, ghosted is fine
1155  if (neighbor && neighbor != libMesh::remote_elem)
1156  {
1157  // handle mesh refinement, only return active elements near the boundary
1158  if (neighbor->active())
1159  neighbor_elems.insert(neighbor->id());
1160  else
1161  {
1162  std::vector<const Elem *> family;
1163  neighbor->active_family_tree_by_neighbor(family, elem_ptr);
1164  for (const auto & child_neighbor : family)
1165  neighbor_elems.insert(child_neighbor->id());
1166  }
1167  }
1168  }
1169  }
1170 
1171  return neighbor_elems;
1172 }
1173 
1174 bool
1176  const std::set<SubdomainID> & blk_group) const
1177 {
1178  mooseAssert(_bnd_elem_range, "Boundary element range is not initialized");
1179 
1180  // Loop over all side elements of the mesh, select those on the boundary
1181  for (const auto & bnd_elem : *_bnd_elem_range)
1182  {
1183  const auto & [elem_ptr, elem_side, elem_bid] = *bnd_elem;
1184  if (elem_bid == bid)
1185  {
1186  // If an element is internal to the group of subdomain, check the neighbor
1187  if (blk_group.find(elem_ptr->subdomain_id()) != blk_group.end())
1188  {
1189  const auto * const neighbor = elem_ptr->neighbor_ptr(elem_side);
1190 
1191  // If we did not ghost the neighbor, we cannot decide
1192  if (neighbor == libMesh::remote_elem)
1193  mooseError("Insufficient level of geometrical ghosting to determine "
1194  "if a boundary is internal to the mesh");
1195  // If the neighbor does not exist, then we are on the edge of the mesh
1196  if (!neighbor)
1197  continue;
1198  // If the neighbor is also in the group of subdomain,
1199  // then the boundary cuts the subdomains
1200  if (blk_group.find(neighbor->subdomain_id()) != blk_group.end())
1201  return false;
1202  }
1203  }
1204  }
1205  return true;
1206 }
1207 
1208 void
1210 {
1211  TIME_SECTION("cacheInfo", 3);
1212 
1213  _has_lower_d = false;
1214  _sub_to_data.clear();
1216  _block_node_list.clear();
1218 
1219  // TODO: Thread this!
1220  for (const auto & elem : getMesh().element_ptr_range())
1221  {
1222  const Elem * ip_elem = elem->interior_parent();
1223 
1224  if (ip_elem)
1225  {
1226  if (elem->active())
1227  _sub_to_data[elem->subdomain_id()].is_lower_d = true;
1228  unsigned int ip_side = ip_elem->which_side_am_i(elem);
1229 
1230  // For some grid sequencing tests: ip_side == libMesh::invalid_uint
1231  if (ip_side != libMesh::invalid_uint)
1232  {
1233  auto pair = std::make_pair(ip_elem, ip_side);
1235  std::pair<std::pair<const Elem *, unsigned short int>, const Elem *>(pair, elem));
1236  }
1237  }
1238 
1239  for (unsigned int nd = 0; nd < elem->n_nodes(); ++nd)
1240  {
1241  Node & node = *elem->node_ptr(nd);
1242  _block_node_list[node.id()].insert(elem->subdomain_id());
1243  }
1244  }
1245 
1246  for (const auto & elem : getMesh().active_local_element_ptr_range())
1247  {
1248  SubdomainID subdomain_id = elem->subdomain_id();
1249  auto & sub_data = _sub_to_data[subdomain_id];
1250  for (unsigned int side = 0; side < elem->n_sides(); side++)
1251  {
1252  std::vector<BoundaryID> boundary_ids = getBoundaryIDs(elem, side);
1253  sub_data.boundary_ids.insert(boundary_ids.begin(), boundary_ids.end());
1254 
1255  Elem * neig = elem->neighbor_ptr(side);
1256  if (neig)
1257  {
1258  _neighbor_subdomain_boundary_ids[neig->subdomain_id()].insert(boundary_ids.begin(),
1259  boundary_ids.end());
1260  SubdomainID neighbor_subdomain_id = neig->subdomain_id();
1261  if (neighbor_subdomain_id != subdomain_id)
1262  sub_data.neighbor_subs.insert(neighbor_subdomain_id);
1263  }
1264  }
1265  }
1266 
1267  for (const auto blk_id : _mesh_subdomains)
1268  {
1269  auto & sub_data = _sub_to_data[blk_id];
1270  _communicator.set_union(sub_data.neighbor_subs);
1271  _communicator.set_union(sub_data.boundary_ids);
1272  _communicator.max(sub_data.is_lower_d);
1273  if (sub_data.is_lower_d)
1274  _has_lower_d = true;
1276  }
1277 }
1278 
1279 const std::set<SubdomainID> &
1280 MooseMesh::getNodeBlockIds(const Node & node) const
1281 {
1282  std::map<dof_id_type, std::set<SubdomainID>>::const_iterator it =
1283  _block_node_list.find(node.id());
1284 
1285  if (it == _block_node_list.end())
1286  mooseError("Unable to find node: ", node.id(), " in any block list.");
1287 
1288  return it->second;
1289 }
1290 
1293 {
1294  return face_info_iterator(
1295  _face_info.begin(),
1296  _face_info.end(),
1298 }
1299 
1302 {
1303  return face_info_iterator(
1304  _face_info.end(),
1305  _face_info.end(),
1307 }
1308 
1311 {
1312  return elem_info_iterator(_elem_info.begin(),
1313  _elem_info.end(),
1314  Predicates::NotNull<std::vector<const ElemInfo *>::iterator>());
1315 }
1316 
1319 {
1320  return elem_info_iterator(_elem_info.end(),
1321  _elem_info.end(),
1322  Predicates::NotNull<std::vector<const ElemInfo *>::iterator>());
1323 }
1324 
1325 // default begin() accessor
1328 {
1329  Predicates::NotNull<bnd_node_iterator_imp> p;
1330  return bnd_node_iterator(_bnd_nodes.begin(), _bnd_nodes.end(), p);
1331 }
1332 
1333 // default end() accessor
1336 {
1337  Predicates::NotNull<bnd_node_iterator_imp> p;
1338  return bnd_node_iterator(_bnd_nodes.end(), _bnd_nodes.end(), p);
1339 }
1340 
1341 // default begin() accessor
1344 {
1345  Predicates::NotNull<bnd_elem_iterator_imp> p;
1346  return bnd_elem_iterator(_bnd_elems.begin(), _bnd_elems.end(), p);
1347 }
1348 
1349 // default end() accessor
1352 {
1353  Predicates::NotNull<bnd_elem_iterator_imp> p;
1354  return bnd_elem_iterator(_bnd_elems.end(), _bnd_elems.end(), p);
1355 }
1356 
1357 const Node *
1358 MooseMesh::addUniqueNode(const Point & p, Real tol)
1359 {
1364  if (getMesh().n_nodes() != _node_map.size())
1365  {
1366  _node_map.clear();
1367  _node_map.reserve(getMesh().n_nodes());
1368  for (const auto & node : getMesh().node_ptr_range())
1369  _node_map.push_back(node);
1370  }
1371 
1372  Node * node = nullptr;
1373  for (unsigned int i = 0; i < _node_map.size(); ++i)
1374  {
1375  if (p.relative_fuzzy_equals(*_node_map[i], tol))
1376  {
1377  node = _node_map[i];
1378  break;
1379  }
1380  }
1381  if (node == nullptr)
1382  {
1383  node = getMesh().add_node(new Node(p));
1384  _node_map.push_back(node);
1385  }
1386 
1387  mooseAssert(node != nullptr, "Node is NULL");
1388  return node;
1389 }
1390 
1391 Node *
1393  const unsigned short int side,
1394  const unsigned int qp,
1395  BoundaryID bid,
1396  const Point & point)
1397 {
1398  Node * qnode;
1399 
1400  if (_elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side].find(qp) ==
1401  _elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side].end())
1402  {
1403  // Create a new node id starting from the max node id and counting down. This will be the least
1404  // likely to collide with an existing node id.
1405  // Note that we are using numeric_limits<unsigned>::max even
1406  // though max_id is stored as a dof_id_type. I tried this with
1407  // numeric_limits<dof_id_type>::max and it broke several tests in
1408  // MOOSE. So, this is some kind of a magic number that we will
1409  // just continue to use...
1411  dof_id_type new_id = max_id - _quadrature_nodes.size();
1412 
1413  if (new_id <= getMesh().max_node_id())
1414  mooseError("Quadrature node id collides with existing node id!");
1415 
1416  qnode = new Node(point, new_id);
1417 
1418  // Keep track of this new node in two different ways for easy lookup
1419  _quadrature_nodes[new_id] = qnode;
1420  _elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side][qp] = qnode;
1421 
1422  if (elem->active())
1423  {
1424  _node_to_elem_map[new_id].push_back(elem->id());
1425  _node_to_active_semilocal_elem_map[new_id].push_back(elem->id());
1426  }
1427  }
1428  else
1429  qnode = _elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side][qp];
1430 
1431  BndNode * bnode = new BndNode(qnode, bid);
1432  _bnd_nodes.push_back(bnode);
1433  _bnd_node_ids[bid].insert(qnode->id());
1434 
1435  _extra_bnd_nodes.push_back(*bnode);
1436 
1437  // Do this so the range will be regenerated next time it is accessed
1438  _bnd_node_range.reset();
1439 
1440  return qnode;
1441 }
1442 
1443 Node *
1445  const unsigned short int side,
1446  const unsigned int qp)
1447 {
1448  mooseAssert(_elem_to_side_to_qp_to_quadrature_nodes.find(elem->id()) !=
1450  "Elem has no quadrature nodes!");
1451  mooseAssert(_elem_to_side_to_qp_to_quadrature_nodes[elem->id()].find(side) !=
1453  "Side has no quadrature nodes!");
1454  mooseAssert(_elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side].find(qp) !=
1455  _elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side].end(),
1456  "qp not found on side!");
1457 
1458  return _elem_to_side_to_qp_to_quadrature_nodes[elem->id()][side][qp];
1459 }
1460 
1461 void
1463 {
1464  // Delete all the quadrature nodes
1465  for (auto & it : _quadrature_nodes)
1466  delete it.second;
1467 
1468  _quadrature_nodes.clear();
1470  _extra_bnd_nodes.clear();
1471 }
1472 
1473 BoundaryID
1474 MooseMesh::getBoundaryID(const BoundaryName & boundary_name) const
1475 {
1476  if (boundary_name == "ANY_BOUNDARY_ID")
1477  mooseError("Please use getBoundaryIDs() when passing \"ANY_BOUNDARY_ID\"");
1478 
1479  return MooseMeshUtils::getBoundaryID(boundary_name, getMesh());
1480 }
1481 
1482 const Elem *
1483 MooseMesh::getLowerDElem(const Elem * elem, unsigned short int side) const
1484 {
1485  auto it = _higher_d_elem_side_to_lower_d_elem.find(std::make_pair(elem, side));
1486 
1487  if (it != _higher_d_elem_side_to_lower_d_elem.end())
1488  return it->second;
1489  else
1490  return nullptr;
1491 }
1492 
1493 unsigned int
1494 MooseMesh::getHigherDSide(const Elem * elem) const
1495 {
1496  auto it = _lower_d_elem_to_higher_d_elem_side.find(elem);
1497 
1498  if (it != _lower_d_elem_to_higher_d_elem_side.end())
1499  return it->second;
1500  else
1501  return libMesh::invalid_uint;
1502 }
1503 
1504 std::vector<BoundaryID>
1505 MooseMesh::getBoundaryIDs(const std::vector<BoundaryName> & boundary_name,
1506  bool generate_unknown) const
1507 {
1509  getMesh(), boundary_name, generate_unknown, _mesh_boundary_ids);
1510 }
1511 
1513 MooseMesh::getSubdomainID(const SubdomainName & subdomain_name) const
1514 {
1515  return MooseMeshUtils::getSubdomainID(subdomain_name, getMesh());
1516 }
1517 
1518 std::vector<SubdomainID>
1519 MooseMesh::getSubdomainIDs(const std::vector<SubdomainName> & subdomain_name) const
1520 {
1521  return MooseMeshUtils::getSubdomainIDs(getMesh(), subdomain_name);
1522 }
1523 
1524 void
1525 MooseMesh::setSubdomainName(SubdomainID subdomain_id, const SubdomainName & name)
1526 {
1527  getMesh().subdomain_name(subdomain_id) = name;
1528 }
1529 
1530 void
1531 MooseMesh::setSubdomainName(MeshBase & mesh, SubdomainID subdomain_id, const SubdomainName & name)
1532 {
1533  mesh.subdomain_name(subdomain_id) = name;
1534 }
1535 
1536 const std::string &
1538 {
1539  return getMesh().subdomain_name(subdomain_id);
1540 }
1541 
1542 std::vector<SubdomainName>
1543 MooseMesh::getSubdomainNames(const std::vector<SubdomainID> & subdomain_ids) const
1544 {
1545  std::vector<SubdomainName> names(subdomain_ids.size());
1546 
1547  for (unsigned int i = 0; i < subdomain_ids.size(); i++)
1548  names[i] = getSubdomainName(subdomain_ids[i]);
1549 
1550  return names;
1551 }
1552 
1553 void
1554 MooseMesh::setBoundaryName(BoundaryID boundary_id, BoundaryName name)
1555 {
1556  BoundaryInfo & boundary_info = getMesh().get_boundary_info();
1557 
1558  // We need to figure out if this boundary is a sideset or nodeset
1559  if (boundary_info.get_side_boundary_ids().count(boundary_id))
1560  boundary_info.sideset_name(boundary_id) = name;
1561  else
1562  boundary_info.nodeset_name(boundary_id) = name;
1563 }
1564 
1565 const std::string &
1567 {
1568  BoundaryInfo & boundary_info = getMesh().get_boundary_info();
1569 
1570  // We need to figure out if this boundary is a sideset or nodeset
1571  if (boundary_info.get_side_boundary_ids().count(boundary_id))
1572  return boundary_info.get_sideset_name(boundary_id);
1573  else
1574  return boundary_info.get_nodeset_name(boundary_id);
1575 }
1576 
1577 // specialization for PointListAdaptor<MooseMesh::PeriodicNodeInfo>
1578 template <>
1579 inline const Point &
1581  const MooseMesh::PeriodicNodeInfo & item) const
1582 {
1583  return *(item.first);
1584 }
1585 
1586 void
1587 MooseMesh::buildPeriodicNodeMap(std::multimap<dof_id_type, dof_id_type> & periodic_node_map,
1588  unsigned int var_number,
1589  PeriodicBoundaries * pbs) const
1590 {
1591  TIME_SECTION("buildPeriodicNodeMap", 5);
1592 
1593  // clear existing map
1594  periodic_node_map.clear();
1595 
1596  // get periodic nodes
1597  std::vector<PeriodicNodeInfo> periodic_nodes;
1598  for (const auto & t : getMesh().get_boundary_info().build_node_list())
1599  {
1600  // unfortunately libMesh does not give us a pointer, so we have to look it up ourselves
1601  auto node = _mesh->node_ptr(std::get<0>(t));
1602  mooseAssert(node != nullptr,
1603  "libMesh::BoundaryInfo::build_node_list() returned an ID for a non-existing node");
1604  auto bc_id = std::get<1>(t);
1605  periodic_nodes.emplace_back(node, bc_id);
1606  }
1607 
1608  // sort by boundary id
1609  std::sort(periodic_nodes.begin(),
1610  periodic_nodes.end(),
1611  [](const PeriodicNodeInfo & a, const PeriodicNodeInfo & b) -> bool
1612  { return a.second > b.second; });
1613 
1614  // build kd-tree
1615  using KDTreeType = nanoflann::KDTreeSingleIndexAdaptor<
1616  nanoflann::L2_Simple_Adaptor<Real, PointListAdaptor<PeriodicNodeInfo>, Real, std::size_t>,
1618  LIBMESH_DIM,
1619  std::size_t>;
1620  const unsigned int max_leaf_size = 20; // slightly affects runtime
1621  auto point_list =
1622  PointListAdaptor<PeriodicNodeInfo>(periodic_nodes.begin(), periodic_nodes.end());
1623  auto kd_tree = std::make_unique<KDTreeType>(
1624  LIBMESH_DIM, point_list, nanoflann::KDTreeSingleIndexAdaptorParams(max_leaf_size));
1625  mooseAssert(kd_tree != nullptr, "KDTree was not properly initialized.");
1626  kd_tree->buildIndex();
1627 
1628  // data structures for kd-tree search
1629  nanoflann::SearchParameters search_params;
1630  std::vector<nanoflann::ResultItem<std::size_t, Real>> ret_matches;
1631 
1632  // iterate over periodic nodes (boundary ids are in contiguous blocks)
1633  PeriodicBoundaryBase * periodic = nullptr;
1634  BoundaryID current_bc_id = BoundaryInfo::invalid_id;
1635  for (auto & pair : periodic_nodes)
1636  {
1637  // entering a new block of boundary IDs
1638  if (pair.second != current_bc_id)
1639  {
1640  current_bc_id = pair.second;
1641  periodic = pbs->boundary(current_bc_id);
1642  if (periodic && !periodic->is_my_variable(var_number))
1643  periodic = nullptr;
1644  }
1645 
1646  // variable is not periodic at this node, skip
1647  if (!periodic)
1648  continue;
1649 
1650  // clear result buffer
1651  ret_matches.clear();
1652 
1653  // id of the current node
1654  const auto id = pair.first->id();
1655 
1656  // position where we expect a periodic partner for the current node and boundary
1657  Point search_point = periodic->get_corresponding_pos(*pair.first);
1658 
1659  // search at the expected point
1660  kd_tree->radiusSearch(&(search_point)(0), libMesh::TOLERANCE, ret_matches, search_params);
1661  for (auto & match_pair : ret_matches)
1662  {
1663  const auto & match = periodic_nodes[match_pair.first];
1664  // add matched node if the boundary id is the corresponding id in the periodic pair
1665  if (match.second == periodic->pairedboundary)
1666  periodic_node_map.emplace(id, match.first->id());
1667  }
1668  }
1669 }
1670 
1671 void
1672 MooseMesh::buildPeriodicNodeSets(std::map<BoundaryID, std::set<dof_id_type>> & periodic_node_sets,
1673  unsigned int var_number,
1674  PeriodicBoundaries * pbs) const
1675 {
1676  TIME_SECTION("buildPeriodicNodeSets", 5);
1677 
1678  periodic_node_sets.clear();
1679 
1680  // Loop over all the boundary nodes adding the periodic nodes to the appropriate set
1681  for (const auto & t : getMesh().get_boundary_info().build_node_list())
1682  {
1683  auto node_id = std::get<0>(t);
1684  auto bc_id = std::get<1>(t);
1685 
1686  // Is this current node on a known periodic boundary?
1687  if (periodic_node_sets.find(bc_id) != periodic_node_sets.end())
1688  periodic_node_sets[bc_id].insert(node_id);
1689  else // This still might be a periodic node but we just haven't seen this boundary_id yet
1690  {
1691  const PeriodicBoundaryBase * periodic = pbs->boundary(bc_id);
1692  if (periodic && periodic->is_my_variable(var_number))
1693  periodic_node_sets[bc_id].insert(node_id);
1694  }
1695  }
1696 }
1697 
1698 bool
1700 {
1701  TIME_SECTION("detectOrthogonalDimRanges", 5);
1702 
1704  return true;
1705 
1706  std::vector<Real> min(3, std::numeric_limits<Real>::max());
1707  std::vector<Real> max(3, std::numeric_limits<Real>::min());
1708  unsigned int dim = getMesh().mesh_dimension();
1709 
1710  // Find the bounding box of our mesh
1711  for (const auto & node : getMesh().node_ptr_range())
1712  // Check all coordinates, we don't know if this mesh might be lying in a higher dim even if the
1713  // mesh dimension is lower.
1714  for (const auto i : make_range(Moose::dim))
1715  {
1716  if ((*node)(i) < min[i])
1717  min[i] = (*node)(i);
1718  if ((*node)(i) > max[i])
1719  max[i] = (*node)(i);
1720  }
1721 
1722  this->comm().max(max);
1723  this->comm().min(min);
1724 
1725  _extreme_nodes.resize(8); // 2^LIBMESH_DIM
1726  // Now make sure that there are actual nodes at all of the extremes
1727  std::vector<bool> extreme_matches(8, false);
1728  std::vector<unsigned int> comp_map(3);
1729  for (const auto & node : getMesh().node_ptr_range())
1730  {
1731  // See if the current node is located at one of the extremes
1732  unsigned int coord_match = 0;
1733 
1734  for (const auto i : make_range(Moose::dim))
1735  {
1736  if (std::abs((*node)(i)-min[i]) < tol)
1737  {
1738  comp_map[i] = MIN;
1739  ++coord_match;
1740  }
1741  else if (std::abs((*node)(i)-max[i]) < tol)
1742  {
1743  comp_map[i] = MAX;
1744  ++coord_match;
1745  }
1746  }
1747 
1748  if (coord_match == LIBMESH_DIM) // Found a coordinate at one of the extremes
1749  {
1750  _extreme_nodes[comp_map[X] * 4 + comp_map[Y] * 2 + comp_map[Z]] = node;
1751  extreme_matches[comp_map[X] * 4 + comp_map[Y] * 2 + comp_map[Z]] = true;
1752  }
1753  }
1754 
1755  // See if we matched all of the extremes for the mesh dimension
1756  this->comm().max(extreme_matches);
1757  if (std::count(extreme_matches.begin(), extreme_matches.end(), true) == (1 << dim))
1758  _regular_orthogonal_mesh = true;
1759 
1760  // Set the bounds
1761  _bounds.resize(LIBMESH_DIM);
1762  for (const auto i : make_range(Moose::dim))
1763  {
1764  _bounds[i].resize(2);
1765  _bounds[i][MIN] = min[i];
1766  _bounds[i][MAX] = max[i];
1767  }
1768 
1769  return _regular_orthogonal_mesh;
1770 }
1771 
1772 void
1774 {
1775  TIME_SECTION("detectPairedSidesets", 5);
1776 
1777  // Loop over level-0 elements (since boundary condition information
1778  // is only directly stored for them) and find sidesets with normals
1779  // that point in the -x, +x, -y, +y, and -z, +z direction. If there
1780  // is a unique sideset id for each direction, then the paired
1781  // sidesets consist of (-x,+x), (-y,+y), (-z,+z). If there are
1782  // multiple sideset ids for a given direction, then we can't pick a
1783  // single pair for that direction. In that case, we'll just return
1784  // as was done in the original algorithm.
1785 
1786  // Points used for direction comparison
1787  const Point minus_x(-1, 0, 0), plus_x(1, 0, 0), minus_y(0, -1, 0), plus_y(0, 1, 0),
1788  minus_z(0, 0, -1), plus_z(0, 0, 1);
1789 
1790  // we need to test all element dimensions from dim down to 1
1791  const unsigned int dim = getMesh().mesh_dimension();
1792 
1793  // boundary id sets for elements of different dimensions
1794  std::vector<std::set<BoundaryID>> minus_x_ids(dim), plus_x_ids(dim), minus_y_ids(dim),
1795  plus_y_ids(dim), minus_z_ids(dim), plus_z_ids(dim);
1796 
1797  std::vector<std::unique_ptr<FEBase>> fe_faces(dim);
1798  std::vector<std::unique_ptr<QGauss>> qfaces(dim);
1799  for (unsigned side_dim = 0; side_dim < dim; ++side_dim)
1800  {
1801  // Face is assumed to be flat, therefore normal is assumed to be
1802  // constant over the face, therefore only compute it at 1 qp.
1803  qfaces[side_dim] = std::unique_ptr<QGauss>(new QGauss(side_dim, CONSTANT));
1804 
1805  // A first-order Lagrange FE for the face.
1806  fe_faces[side_dim] = FEBase::build(side_dim + 1, FEType(FIRST, LAGRANGE));
1807  fe_faces[side_dim]->attach_quadrature_rule(qfaces[side_dim].get());
1808  }
1809 
1810  // We need this to get boundary ids for each boundary face we encounter.
1811  BoundaryInfo & boundary_info = getMesh().get_boundary_info();
1812  std::vector<boundary_id_type> face_ids;
1813 
1814  for (auto & elem : as_range(getMesh().level_elements_begin(0), getMesh().level_elements_end(0)))
1815  {
1816  // dimension of the current element and its normals
1817  unsigned int side_dim = elem->dim() - 1;
1818  const std::vector<Point> & normals = fe_faces[side_dim]->get_normals();
1819 
1820  // loop over element sides
1821  for (unsigned int s = 0; s < elem->n_sides(); s++)
1822  {
1823  // If side is on the boundary
1824  if (elem->neighbor_ptr(s) == nullptr)
1825  {
1826  std::unique_ptr<Elem> side = elem->build_side_ptr(s);
1827 
1828  fe_faces[side_dim]->reinit(elem, s);
1829 
1830  // Get the boundary ID(s) for this side. If there is more
1831  // than 1 boundary id, then we already can't determine a
1832  // unique pairing of sides in this direction, but we'll just
1833  // keep going to keep the logic simple.
1834  boundary_info.boundary_ids(elem, s, face_ids);
1835 
1836  // x-direction faces
1837  if (normals[0].absolute_fuzzy_equals(minus_x))
1838  minus_x_ids[side_dim].insert(face_ids.begin(), face_ids.end());
1839  else if (normals[0].absolute_fuzzy_equals(plus_x))
1840  plus_x_ids[side_dim].insert(face_ids.begin(), face_ids.end());
1841 
1842  // y-direction faces
1843  else if (normals[0].absolute_fuzzy_equals(minus_y))
1844  minus_y_ids[side_dim].insert(face_ids.begin(), face_ids.end());
1845  else if (normals[0].absolute_fuzzy_equals(plus_y))
1846  plus_y_ids[side_dim].insert(face_ids.begin(), face_ids.end());
1847 
1848  // z-direction faces
1849  else if (normals[0].absolute_fuzzy_equals(minus_z))
1850  minus_z_ids[side_dim].insert(face_ids.begin(), face_ids.end());
1851  else if (normals[0].absolute_fuzzy_equals(plus_z))
1852  plus_z_ids[side_dim].insert(face_ids.begin(), face_ids.end());
1853  }
1854  }
1855  }
1856 
1857  // For a distributed mesh, boundaries may be distributed as well. We therefore collect information
1858  // from everyone. If the mesh is already serial, then there is no need to do an allgather. Note
1859  // that this is just going to gather information about what the periodic bc ids are. We are not
1860  // gathering any remote elements or anything like that. It's just that the GhostPointNeighbors
1861  // ghosting functor currently relies on the fact that every process agrees on whether we have
1862  // periodic boundaries; every process that thinks there are periodic boundaries will call
1863  // MeshBase::sub_point_locator which makes a parallel_object_only() assertion (right or wrong). So
1864  // we all need to go there (or not go there)
1865  if (_use_distributed_mesh && !_mesh->is_serial())
1866  {
1867  // Pack all data together so that we send them via one communication
1868  // pair: boundary side --> boundary ids.
1869  std::vector<std::pair<boundary_id_type, boundary_id_type>> vecdata;
1870  // We check boundaries on all dimensions
1871  for (unsigned side_dim = 0; side_dim < dim; ++side_dim)
1872  {
1873  // "6" means: we have at most 6 boundaries. It is true for generated simple mesh
1874  // "detectPairedSidesets" is designed for only simple meshes
1875  for (auto bd = minus_x_ids[side_dim].begin(); bd != minus_x_ids[side_dim].end(); bd++)
1876  vecdata.emplace_back(side_dim * 6 + 0, *bd);
1877 
1878  for (auto bd = plus_x_ids[side_dim].begin(); bd != plus_x_ids[side_dim].end(); bd++)
1879  vecdata.emplace_back(side_dim * 6 + 1, *bd);
1880 
1881  for (auto bd = minus_y_ids[side_dim].begin(); bd != minus_y_ids[side_dim].end(); bd++)
1882  vecdata.emplace_back(side_dim * 6 + 2, *bd);
1883 
1884  for (auto bd = plus_y_ids[side_dim].begin(); bd != plus_y_ids[side_dim].end(); bd++)
1885  vecdata.emplace_back(side_dim * 6 + 3, *bd);
1886 
1887  for (auto bd = minus_z_ids[side_dim].begin(); bd != minus_z_ids[side_dim].end(); bd++)
1888  vecdata.emplace_back(side_dim * 6 + 4, *bd);
1889 
1890  for (auto bd = plus_z_ids[side_dim].begin(); bd != plus_z_ids[side_dim].end(); bd++)
1891  vecdata.emplace_back(side_dim * 6 + 5, *bd);
1892  }
1893 
1894  _communicator.allgather(vecdata, false);
1895 
1896  // Unpack data, and add them into minus/plus_x/y_ids
1897  for (auto pair = vecdata.begin(); pair != vecdata.end(); pair++)
1898  {
1899  // Convert data from the long vector, and add data to separated sets
1900  auto side_dim = pair->first / 6;
1901  auto side = pair->first % 6;
1902 
1903  switch (side)
1904  {
1905  case 0:
1906  minus_x_ids[side_dim].insert(pair->second);
1907  break;
1908  case 1:
1909  plus_x_ids[side_dim].insert(pair->second);
1910  break;
1911  case 2:
1912  minus_y_ids[side_dim].insert(pair->second);
1913  break;
1914  case 3:
1915  plus_y_ids[side_dim].insert(pair->second);
1916  break;
1917  case 4:
1918  minus_z_ids[side_dim].insert(pair->second);
1919  break;
1920  case 5:
1921  plus_z_ids[side_dim].insert(pair->second);
1922  break;
1923  default:
1924  mooseError("Unknown boundary side ", side);
1925  }
1926  }
1927 
1928  } // end if (_use_distributed_mesh && !_need_ghost_ghosted_boundaries)
1929 
1930  for (unsigned side_dim = 0; side_dim < dim; ++side_dim)
1931  {
1932  // If unique pairings were found, fill up the _paired_boundary data
1933  // structure with that information.
1934  if (minus_x_ids[side_dim].size() == 1 && plus_x_ids[side_dim].size() == 1)
1935  _paired_boundary.emplace_back(
1936  std::make_pair(*(minus_x_ids[side_dim].begin()), *(plus_x_ids[side_dim].begin())));
1937 
1938  if (minus_y_ids[side_dim].size() == 1 && plus_y_ids[side_dim].size() == 1)
1939  _paired_boundary.emplace_back(
1940  std::make_pair(*(minus_y_ids[side_dim].begin()), *(plus_y_ids[side_dim].begin())));
1941 
1942  if (minus_z_ids[side_dim].size() == 1 && plus_z_ids[side_dim].size() == 1)
1943  _paired_boundary.emplace_back(
1944  std::make_pair(*(minus_z_ids[side_dim].begin()), *(plus_z_ids[side_dim].begin())));
1945  }
1946 }
1947 
1948 Real
1949 MooseMesh::dimensionWidth(unsigned int component) const
1950 {
1951  return getMaxInDimension(component) - getMinInDimension(component);
1952 }
1953 
1954 Real
1955 MooseMesh::getMinInDimension(unsigned int component) const
1956 {
1957  mooseAssert(_mesh, "The MeshBase has not been constructed");
1958  mooseAssert(component < _bounds.size(), "Requested dimension out of bounds");
1959 
1960  return _bounds[component][MIN];
1961 }
1962 
1963 Real
1964 MooseMesh::getMaxInDimension(unsigned int component) const
1965 {
1966  mooseAssert(_mesh, "The MeshBase has not been constructed");
1967  mooseAssert(component < _bounds.size(), "Requested dimension out of bounds");
1968 
1969  return _bounds[component][MAX];
1970 }
1971 
1972 void
1973 MooseMesh::addPeriodicVariable(unsigned int var_num, BoundaryID primary, BoundaryID secondary)
1974 {
1976  return;
1977 
1978  _periodic_dim[var_num].resize(dimension());
1979 
1980  _half_range = Point(dimensionWidth(0) / 2.0, dimensionWidth(1) / 2.0, dimensionWidth(2) / 2.0);
1981 
1982  for (unsigned int component = 0; component < dimension(); ++component)
1983  {
1984  const std::pair<BoundaryID, BoundaryID> * boundary_ids = getPairedBoundaryMapping(component);
1985 
1986  if (boundary_ids != nullptr &&
1987  ((boundary_ids->first == primary && boundary_ids->second == secondary) ||
1988  (boundary_ids->first == secondary && boundary_ids->second == primary)))
1989  _periodic_dim[var_num][component] = true;
1990  }
1991 }
1992 
1993 bool
1994 MooseMesh::isTranslatedPeriodic(unsigned int nonlinear_var_num, unsigned int component) const
1995 {
1996  mooseAssert(component < dimension(), "Requested dimension out of bounds");
1997 
1998  if (_periodic_dim.find(nonlinear_var_num) != _periodic_dim.end())
1999  return _periodic_dim.at(nonlinear_var_num)[component];
2000  else
2001  return false;
2002 }
2003 
2005 MooseMesh::minPeriodicVector(unsigned int nonlinear_var_num, Point p, Point q) const
2006 {
2007  for (unsigned int i = 0; i < dimension(); ++i)
2008  {
2009  // check to see if we're closer in real or periodic space in x, y, and z
2010  if (isTranslatedPeriodic(nonlinear_var_num, i))
2011  {
2012  // Need to test order before differencing
2013  if (p(i) > q(i))
2014  {
2015  if (p(i) - q(i) > _half_range(i))
2016  p(i) -= _half_range(i) * 2;
2017  }
2018  else
2019  {
2020  if (q(i) - p(i) > _half_range(i))
2021  p(i) += _half_range(i) * 2;
2022  }
2023  }
2024  }
2025 
2026  return q - p;
2027 }
2028 
2029 Real
2030 MooseMesh::minPeriodicDistance(unsigned int nonlinear_var_num, Point p, Point q) const
2031 {
2032  return minPeriodicVector(nonlinear_var_num, p, q).norm();
2033 }
2034 
2035 const std::pair<BoundaryID, BoundaryID> *
2037 {
2039  mooseError("Trying to retrieve automatic paired mapping for a mesh that is not regular and "
2040  "orthogonal");
2041 
2042  mooseAssert(component < dimension(), "Requested dimension out of bounds");
2043 
2044  if (_paired_boundary.empty())
2046 
2047  if (component < _paired_boundary.size())
2048  return &_paired_boundary[component];
2049  else
2050  return nullptr;
2051 }
2052 
2053 void
2055 {
2056  std::map<ElemType, Elem *> canonical_elems;
2057 
2058  // First, loop over all elements and find a canonical element for each type
2059  // Doing it this way guarantees that this is going to work in parallel
2060  for (const auto & elem : getMesh().element_ptr_range()) // TODO: Thread this
2061  {
2062  ElemType type = elem->type();
2063 
2064  if (canonical_elems.find(type) ==
2065  canonical_elems.end()) // If we haven't seen this type of elem before save it
2066  canonical_elems[type] = elem;
2067  else
2068  {
2069  Elem * stored = canonical_elems[type];
2070  if (elem->id() < stored->id()) // Arbitrarily keep the one with a lower id
2071  canonical_elems[type] = elem;
2072  }
2073  }
2074  // Now build the maps using these templates
2075  // Note: This MUST be done NOT threaded!
2076  for (const auto & can_it : canonical_elems)
2077  {
2078  Elem * elem = can_it.second;
2079 
2080  // Need to do this just once to get the right qrules put in place
2081  assembly->setCurrentSubdomainID(elem->subdomain_id());
2082  assembly->reinit(elem);
2083  assembly->reinit(elem, 0);
2084  auto && qrule = assembly->writeableQRule();
2085  auto && qrule_face = assembly->writeableQRuleFace();
2086 
2087  // Volume to volume projection for refinement
2088  buildRefinementMap(*elem, *qrule, *qrule_face, -1, -1, -1);
2089 
2090  // Volume to volume projection for coarsening
2091  buildCoarseningMap(*elem, *qrule, *qrule_face, -1);
2092 
2093  // Map the sides of children
2094  for (unsigned int side = 0; side < elem->n_sides(); side++)
2095  {
2096  // Side to side for sides that match parent's sides
2097  buildRefinementMap(*elem, *qrule, *qrule_face, side, -1, side);
2098  buildCoarseningMap(*elem, *qrule, *qrule_face, side);
2099  }
2100 
2101  // Child side to parent volume mapping for "internal" child sides
2102  for (unsigned int child = 0; child < elem->n_children(); ++child)
2103  for (unsigned int side = 0; side < elem->n_sides();
2104  ++side) // Assume children have the same number of sides!
2105  if (!elem->is_child_on_side(child, side)) // Otherwise we already computed that map
2106  buildRefinementMap(*elem, *qrule, *qrule_face, -1, child, side);
2107  }
2108 }
2109 
2110 void
2112 {
2117 
2118  std::map<ElemType, std::pair<Elem *, unsigned int>> elems_and_max_p_level;
2119 
2120  for (const auto & elem : getMesh().active_element_ptr_range())
2121  {
2122  const auto type = elem->type();
2123  auto & [picked_elem, max_p_level] = elems_and_max_p_level[type];
2124  if (!picked_elem)
2125  picked_elem = elem;
2126  max_p_level = std::max(max_p_level, elem->p_level());
2127  }
2128 
2129  // The only requirement on the FEType is that it can be arbitrarily p-refined
2130  const FEType p_refinable_fe_type(CONSTANT, MONOMIAL);
2131  std::vector<Point> volume_ref_points_coarse, volume_ref_points_fine, face_ref_points_coarse,
2132  face_ref_points_fine;
2133  std::vector<unsigned int> p_levels;
2134 
2135  for (auto & [elem_type, elem_p_level_pair] : elems_and_max_p_level)
2136  {
2137  auto & [moose_elem, max_p_level] = elem_p_level_pair;
2138  const auto dim = moose_elem->dim();
2139  // Need to do this just once to get the right qrules put in place
2140  assembly->setCurrentSubdomainID(moose_elem->subdomain_id());
2141  assembly->reinit(moose_elem);
2142  assembly->reinit(moose_elem, 0);
2143  auto & qrule = assembly->writeableQRule();
2144  auto & qrule_face = assembly->writeableQRuleFace();
2145 
2146  libMesh::Parallel::Communicator self_comm{};
2147  ReplicatedMesh mesh(self_comm);
2148  mesh.set_mesh_dimension(dim);
2149  for (const auto & nd : moose_elem->node_ref_range())
2150  mesh.add_point(nd);
2151 
2152  Elem * const elem = mesh.add_elem(Elem::build(elem_type).release());
2153  for (const auto i : elem->node_index_range())
2154  elem->set_node(i) = mesh.node_ptr(i);
2155 
2156  std::unique_ptr<FEBase> fe(FEBase::build(dim, p_refinable_fe_type));
2157  std::unique_ptr<FEBase> fe_face(FEBase::build(dim, p_refinable_fe_type));
2158  fe_face->get_phi();
2159  const auto & face_phys_points = fe_face->get_xyz();
2160 
2161  fe->attach_quadrature_rule(qrule);
2162  fe_face->attach_quadrature_rule(qrule_face);
2163  fe->reinit(elem);
2164  volume_ref_points_coarse = qrule->get_points();
2165  fe_face->reinit(elem, (unsigned int)0);
2166  FEInterface::inverse_map(
2167  dim, p_refinable_fe_type, elem, face_phys_points, face_ref_points_coarse);
2168 
2169  p_levels.resize(max_p_level + 1);
2170  std::iota(p_levels.begin(), p_levels.end(), 0);
2171  MeshRefinement mesh_refinement(mesh);
2172 
2173  for (const auto p_level : p_levels)
2174  {
2175  mesh_refinement.uniformly_p_refine(1);
2176  fe->reinit(elem);
2177  volume_ref_points_fine = qrule->get_points();
2178  fe_face->reinit(elem, (unsigned int)0);
2179  FEInterface::inverse_map(
2180  dim, p_refinable_fe_type, elem, face_phys_points, face_ref_points_fine);
2181 
2182  const auto map_key = std::make_pair(elem_type, p_level);
2183  auto & volume_refine_map = _elem_type_to_p_refinement_map[map_key];
2184  auto & face_refine_map = _elem_type_to_p_refinement_side_map[map_key];
2185  auto & volume_coarsen_map = _elem_type_to_p_coarsening_map[map_key];
2186  auto & face_coarsen_map = _elem_type_to_p_coarsening_side_map[map_key];
2187 
2188  auto fill_maps = [this](const auto & coarse_ref_points,
2189  const auto & fine_ref_points,
2190  auto & coarsen_map,
2191  auto & refine_map)
2192  {
2193  mapPoints(fine_ref_points, coarse_ref_points, refine_map);
2194  mapPoints(coarse_ref_points, fine_ref_points, coarsen_map);
2195  };
2196 
2197  fill_maps(
2198  volume_ref_points_coarse, volume_ref_points_fine, volume_coarsen_map, volume_refine_map);
2199  fill_maps(face_ref_points_coarse, face_ref_points_fine, face_coarsen_map, face_refine_map);
2200 
2201  // With this level's maps filled our fine points now become our coarse points
2202  volume_ref_points_fine.swap(volume_ref_points_coarse);
2203  face_ref_points_fine.swap(face_ref_points_coarse);
2204  }
2205  }
2206 }
2207 
2208 void
2210 {
2211  TIME_SECTION("buildRefinementAndCoarseningMaps", 5, "Building Refinement And Coarsening Maps");
2212  if (doingPRefinement())
2214  else
2216 }
2217 
2218 void
2220  QBase & qrule,
2221  QBase & qrule_face,
2222  int parent_side,
2223  int child,
2224  int child_side)
2225 {
2226  TIME_SECTION("buildRefinementMap", 5, "Building Refinement Map");
2227 
2228  if (child == -1) // Doing volume mapping or parent side mapping
2229  {
2230  mooseAssert(parent_side == child_side,
2231  "Parent side must match child_side if not passing a specific child!");
2232 
2233  std::pair<int, ElemType> the_pair(parent_side, elem.type());
2234 
2235  if (_elem_type_to_refinement_map.find(the_pair) != _elem_type_to_refinement_map.end())
2236  mooseError("Already built a qp refinement map!");
2237 
2238  std::vector<std::pair<unsigned int, QpMap>> coarsen_map;
2239  std::vector<std::vector<QpMap>> & refinement_map = _elem_type_to_refinement_map[the_pair];
2241  &elem, qrule, qrule_face, refinement_map, coarsen_map, parent_side, child, child_side);
2242  }
2243  else // Need to map a child side to parent volume qps
2244  {
2245  std::pair<int, int> child_pair(child, child_side);
2246 
2247  if (_elem_type_to_child_side_refinement_map.find(elem.type()) !=
2249  _elem_type_to_child_side_refinement_map[elem.type()].find(child_pair) !=
2251  mooseError("Already built a qp refinement map!");
2252 
2253  std::vector<std::pair<unsigned int, QpMap>> coarsen_map;
2254  std::vector<std::vector<QpMap>> & refinement_map =
2255  _elem_type_to_child_side_refinement_map[elem.type()][child_pair];
2257  &elem, qrule, qrule_face, refinement_map, coarsen_map, parent_side, child, child_side);
2258  }
2259 }
2260 
2261 const std::vector<std::vector<QpMap>> &
2262 MooseMesh::getRefinementMap(const Elem & elem, int parent_side, int child, int child_side)
2263 {
2264  if (child == -1) // Doing volume mapping or parent side mapping
2265  {
2266  mooseAssert(parent_side == child_side,
2267  "Parent side must match child_side if not passing a specific child!");
2268 
2269  std::pair<int, ElemType> the_pair(parent_side, elem.type());
2270 
2271  if (_elem_type_to_refinement_map.find(the_pair) == _elem_type_to_refinement_map.end())
2272  mooseError("Could not find a suitable qp refinement map!");
2273 
2274  return _elem_type_to_refinement_map[the_pair];
2275  }
2276  else // Need to map a child side to parent volume qps
2277  {
2278  std::pair<int, int> child_pair(child, child_side);
2279 
2280  if (_elem_type_to_child_side_refinement_map.find(elem.type()) ==
2282  _elem_type_to_child_side_refinement_map[elem.type()].find(child_pair) ==
2284  mooseError("Could not find a suitable qp refinement map!");
2285 
2286  return _elem_type_to_child_side_refinement_map[elem.type()][child_pair];
2287  }
2288 
2295 }
2296 
2297 void
2298 MooseMesh::buildCoarseningMap(const Elem & elem, QBase & qrule, QBase & qrule_face, int input_side)
2299 {
2300  TIME_SECTION("buildCoarseningMap", 5, "Building Coarsening Map");
2301 
2302  std::pair<int, ElemType> the_pair(input_side, elem.type());
2303 
2304  if (_elem_type_to_coarsening_map.find(the_pair) != _elem_type_to_coarsening_map.end())
2305  mooseError("Already built a qp coarsening map!");
2306 
2307  std::vector<std::vector<QpMap>> refinement_map;
2308  std::vector<std::pair<unsigned int, QpMap>> & coarsen_map =
2309  _elem_type_to_coarsening_map[the_pair];
2310 
2311  // The -1 here is for a specific child. We don't do that for coarsening maps
2312  // Also note that we're always mapping the same side to the same side (which is guaranteed by
2313  // libMesh).
2315  &elem, qrule, qrule_face, refinement_map, coarsen_map, input_side, -1, input_side);
2316 
2323 }
2324 
2325 const std::vector<std::pair<unsigned int, QpMap>> &
2326 MooseMesh::getCoarseningMap(const Elem & elem, int input_side)
2327 {
2328  std::pair<int, ElemType> the_pair(input_side, elem.type());
2329 
2330  if (_elem_type_to_coarsening_map.find(the_pair) == _elem_type_to_coarsening_map.end())
2331  mooseError("Could not find a suitable qp refinement map!");
2332 
2333  return _elem_type_to_coarsening_map[the_pair];
2334 }
2335 
2336 void
2337 MooseMesh::mapPoints(const std::vector<Point> & from,
2338  const std::vector<Point> & to,
2339  std::vector<QpMap> & qp_map)
2340 {
2341  unsigned int n_from = from.size();
2342  unsigned int n_to = to.size();
2343 
2344  qp_map.resize(n_from);
2345 
2346  for (unsigned int i = 0; i < n_from; ++i)
2347  {
2348  const Point & from_point = from[i];
2349 
2350  QpMap & current_map = qp_map[i];
2351 
2352  for (unsigned int j = 0; j < n_to; ++j)
2353  {
2354  const Point & to_point = to[j];
2355  Real distance = (from_point - to_point).norm();
2356 
2357  if (distance < current_map._distance)
2358  {
2359  current_map._distance = distance;
2360  current_map._from = i;
2361  current_map._to = j;
2362  }
2363  }
2364  }
2365 }
2366 
2367 void
2368 MooseMesh::findAdaptivityQpMaps(const Elem * template_elem,
2369  QBase & qrule,
2370  QBase & qrule_face,
2371  std::vector<std::vector<QpMap>> & refinement_map,
2372  std::vector<std::pair<unsigned int, QpMap>> & coarsen_map,
2373  int parent_side,
2374  int child,
2375  int child_side)
2376 {
2377  TIME_SECTION("findAdaptivityQpMaps", 5);
2378 
2379  ReplicatedMesh mesh(_communicator);
2380  mesh.skip_partitioning(true);
2381 
2382  unsigned int dim = template_elem->dim();
2383  mesh.set_mesh_dimension(dim);
2384 
2385  for (unsigned int i = 0; i < template_elem->n_nodes(); ++i)
2386  mesh.add_point(template_elem->point(i));
2387 
2388  Elem * elem = mesh.add_elem(Elem::build(template_elem->type()).release());
2389 
2390  for (unsigned int i = 0; i < template_elem->n_nodes(); ++i)
2391  elem->set_node(i) = mesh.node_ptr(i);
2392 
2393  std::unique_ptr<FEBase> fe(FEBase::build(dim, FEType()));
2394  fe->get_phi();
2395  const std::vector<Point> & q_points_volume = fe->get_xyz();
2396 
2397  std::unique_ptr<FEBase> fe_face(FEBase::build(dim, FEType()));
2398  fe_face->get_phi();
2399  const std::vector<Point> & q_points_face = fe_face->get_xyz();
2400 
2401  fe->attach_quadrature_rule(&qrule);
2402  fe_face->attach_quadrature_rule(&qrule_face);
2403 
2404  // The current q_points (locations in *physical* space)
2405  const std::vector<Point> * q_points;
2406 
2407  if (parent_side != -1)
2408  {
2409  fe_face->reinit(elem, parent_side);
2410  q_points = &q_points_face;
2411  }
2412  else
2413  {
2414  fe->reinit(elem);
2415  q_points = &q_points_volume;
2416  }
2417 
2418  std::vector<Point> parent_ref_points;
2419 
2420  FEInterface::inverse_map(elem->dim(), FEType(), elem, *q_points, parent_ref_points);
2421  MeshRefinement mesh_refinement(mesh);
2422  mesh_refinement.uniformly_refine(1);
2423 
2424  // A map from the child element index to the locations of all the child's quadrature points in
2425  // *reference* space. Note that we use a map here instead of a vector because the caller can
2426  // pass an explicit child index. We are not guaranteed to have a sequence from [0, n_children)
2427  std::map<unsigned int, std::vector<Point>> child_to_ref_points;
2428 
2429  unsigned int n_children = elem->n_children();
2430 
2431  refinement_map.resize(n_children);
2432 
2433  std::vector<unsigned int> children;
2434 
2435  if (child != -1) // Passed in a child explicitly
2436  children.push_back(child);
2437  else
2438  {
2439  children.resize(n_children);
2440  for (unsigned int child = 0; child < n_children; ++child)
2441  children[child] = child;
2442  }
2443 
2444  for (unsigned int i = 0; i < children.size(); ++i)
2445  {
2446  unsigned int child = children[i];
2447 
2448  if ((parent_side != -1 && !elem->is_child_on_side(child, parent_side)))
2449  continue;
2450 
2451  const Elem * child_elem = elem->child_ptr(child);
2452 
2453  if (child_side != -1)
2454  {
2455  fe_face->reinit(child_elem, child_side);
2456  q_points = &q_points_face;
2457  }
2458  else
2459  {
2460  fe->reinit(child_elem);
2461  q_points = &q_points_volume;
2462  }
2463 
2464  std::vector<Point> child_ref_points;
2465 
2466  FEInterface::inverse_map(elem->dim(), FEType(), elem, *q_points, child_ref_points);
2467  child_to_ref_points[child] = child_ref_points;
2468 
2469  std::vector<QpMap> & qp_map = refinement_map[child];
2470 
2471  // Find the closest parent_qp to each child_qp
2472  mapPoints(child_ref_points, parent_ref_points, qp_map);
2473  }
2474 
2475  coarsen_map.resize(parent_ref_points.size());
2476 
2477  // For each parent qp find the closest child qp
2478  for (unsigned int child = 0; child < n_children; child++)
2479  {
2480  if (parent_side != -1 && !elem->is_child_on_side(child, child_side))
2481  continue;
2482 
2483  std::vector<Point> & child_ref_points = child_to_ref_points[child];
2484 
2485  std::vector<QpMap> qp_map;
2486 
2487  // Find all of the closest points from parent_qp to _THIS_ child's qp
2488  mapPoints(parent_ref_points, child_ref_points, qp_map);
2489 
2490  // Check those to see if they are closer than what we currently have for each point
2491  for (unsigned int parent_qp = 0; parent_qp < parent_ref_points.size(); ++parent_qp)
2492  {
2493  std::pair<unsigned int, QpMap> & child_and_map = coarsen_map[parent_qp];
2494  unsigned int & closest_child = child_and_map.first;
2495  QpMap & closest_map = child_and_map.second;
2496 
2497  QpMap & current_map = qp_map[parent_qp];
2498 
2499  if (current_map._distance < closest_map._distance)
2500  {
2501  closest_child = child;
2502  closest_map = current_map;
2503  }
2504  }
2505  }
2506 }
2507 
2508 void
2510  const boundary_id_type new_id,
2511  bool delete_prev)
2512 {
2513  TIME_SECTION("changeBoundaryId", 6);
2514  changeBoundaryId(getMesh(), old_id, new_id, delete_prev);
2515 }
2516 
2517 void
2519  const boundary_id_type old_id,
2520  const boundary_id_type new_id,
2521  bool delete_prev)
2522 {
2523  // Get a reference to our BoundaryInfo object, we will use it several times below...
2524  BoundaryInfo & boundary_info = mesh.get_boundary_info();
2525 
2526  // Container to catch ids passed back from BoundaryInfo
2527  std::vector<boundary_id_type> old_ids;
2528 
2529  // Only level-0 elements store BCs. Loop over them.
2530  for (auto & elem : as_range(mesh.level_elements_begin(0), mesh.level_elements_end(0)))
2531  {
2532  unsigned int n_sides = elem->n_sides();
2533  for (unsigned int s = 0; s != n_sides; ++s)
2534  {
2535  boundary_info.boundary_ids(elem, s, old_ids);
2536  if (std::find(old_ids.begin(), old_ids.end(), old_id) != old_ids.end())
2537  {
2538  std::vector<boundary_id_type> new_ids(old_ids);
2539  std::replace(new_ids.begin(), new_ids.end(), old_id, new_id);
2540  if (delete_prev)
2541  {
2542  boundary_info.remove_side(elem, s);
2543  boundary_info.add_side(elem, s, new_ids);
2544  }
2545  else
2546  boundary_info.add_side(elem, s, new_ids);
2547  }
2548  }
2549  }
2550 
2551  // Remove any remaining references to the old ID from the
2552  // BoundaryInfo object. This prevents things like empty sidesets
2553  // from showing up when printing information, etc.
2554  if (delete_prev)
2555  boundary_info.remove_id(old_id);
2556 }
2557 
2558 const RealVectorValue &
2560 {
2561  mooseAssert(_boundary_to_normal_map.get() != nullptr, "Boundary To Normal Map not built!");
2562 
2563  // Note: Boundaries that are not in the map (existing boundaries) will default
2564  // construct a new RealVectorValue - (x,y,z)=(0, 0, 0)
2565  return (*_boundary_to_normal_map)[id];
2566 }
2567 
2568 MooseMesh &
2570 {
2571  mooseError("MooseMesh::clone() is no longer supported, use MooseMesh::safeClone() instead.");
2572 }
2573 
2574 void
2576 {
2577  switch (_parallel_type)
2578  {
2579  case ParallelType::DEFAULT:
2580  // The user did not specify 'parallel_type = XYZ' in the input file,
2581  // so we allow the --distributed-mesh command line arg to possibly turn
2582  // on DistributedMesh. If the command line arg is not present, we pick ReplicatedMesh.
2584  _use_distributed_mesh = true;
2585  break;
2589  _use_distributed_mesh = false;
2590  break;
2592  _use_distributed_mesh = true;
2593  break;
2594  }
2595 
2596  // If the user specifies 'nemesis = true' in the Mesh block, or they are using --use-split,
2597  // we must use DistributedMesh.
2598  if (_is_nemesis || _is_split)
2599  _use_distributed_mesh = true;
2600 }
2601 
2602 std::unique_ptr<MeshBase>
2604 {
2605  if (dim == libMesh::invalid_uint)
2606  dim = getParam<MooseEnum>("dim");
2607 
2608  std::unique_ptr<MeshBase> mesh;
2610  mesh = buildTypedMesh<DistributedMesh>(dim);
2611  else
2612  mesh = buildTypedMesh<ReplicatedMesh>(dim);
2613 
2614  return mesh;
2615 }
2616 
2617 void
2618 MooseMesh::setMeshBase(std::unique_ptr<MeshBase> mesh_base)
2619 {
2620  _mesh = std::move(mesh_base);
2621  _mesh->allow_remote_element_removal(_allow_remote_element_removal);
2622 }
2623 
2624 void
2626 {
2633  if (!_mesh)
2635 
2637  mooseError("You cannot use the mesh splitter capability with DistributedMesh!");
2638 
2639  TIME_SECTION("init", 2);
2640 
2642  {
2643  // Some partitioners are not idempotent. Some recovery data
2644  // files require partitioning to match mesh partitioning. This
2645  // means that, when recovering, we can't safely repartition.
2646  const bool skip_partitioning_later = getMesh().skip_partitioning();
2647  getMesh().skip_partitioning(true);
2648  const bool allow_renumbering_later = getMesh().allow_renumbering();
2649  getMesh().allow_renumbering(false);
2650 
2651  // For now, only read the recovery mesh on the Ultimate Master..
2652  // sub-apps need to just build their mesh like normal
2653  {
2654  TIME_SECTION("readRecoveredMesh", 2);
2656  }
2657 
2658  getMesh().allow_renumbering(allow_renumbering_later);
2659  getMesh().skip_partitioning(skip_partitioning_later);
2660  }
2661  else // Normally just build the mesh
2662  {
2663  // Don't allow partitioning during building
2664  if (_app.isSplitMesh())
2665  getMesh().skip_partitioning(true);
2666  buildMesh();
2667 
2668  // Re-enable partitioning so the splitter can partition!
2669  if (_app.isSplitMesh())
2670  getMesh().skip_partitioning(false);
2671 
2672  if (getParam<bool>("build_all_side_lowerd_mesh"))
2673  buildLowerDMesh();
2674  }
2675 }
2676 
2677 unsigned int
2679 {
2680  return getMesh().mesh_dimension();
2681 }
2682 
2683 unsigned int
2685 {
2686  const Real abs_zero = 1e-12;
2687 
2688  // See if the mesh is completely containd in the z and y planes to calculate effective spatial
2689  // dim
2690  for (unsigned int dim = LIBMESH_DIM; dim >= 1; --dim)
2691  if (dimensionWidth(dim - 1) >= abs_zero)
2692  return dim;
2693 
2694  // If we get here, we have a 1D mesh on the x-axis.
2695  return 1;
2696 }
2697 
2698 unsigned int
2699 MooseMesh::getBlocksMaxDimension(const std::vector<SubdomainName> & blocks) const
2700 {
2701  const auto & mesh = getMesh();
2702 
2703  // Take a shortcut if possible
2704  if (const auto & elem_dims = mesh.elem_dimensions(); mesh.is_prepared() && elem_dims.size() == 1)
2705  return *elem_dims.begin();
2706 
2707  unsigned short dim = 0;
2708  const auto subdomain_ids = getSubdomainIDs(blocks);
2709  const std::set<SubdomainID> subdomain_ids_set(subdomain_ids.begin(), subdomain_ids.end());
2710  for (const auto & elem : mesh.active_subdomain_set_elements_ptr_range(subdomain_ids_set))
2711  dim = std::max(dim, elem->dim());
2712 
2713  // Get the maximumal globally
2715  return dim;
2716 }
2717 
2718 std::vector<BoundaryID>
2719 MooseMesh::getBoundaryIDs(const Elem * const elem, const unsigned short int side) const
2720 {
2721  std::vector<BoundaryID> ids;
2722  getMesh().get_boundary_info().boundary_ids(elem, side, ids);
2723  return ids;
2724 }
2725 
2726 const std::set<BoundaryID> &
2728 {
2729  return getMesh().get_boundary_info().get_boundary_ids();
2730 }
2731 
2732 void
2734 {
2736  getMesh().get_boundary_info().build_node_list_from_side_list();
2737 }
2738 
2739 void
2740 MooseMesh::buildSideList(std::vector<dof_id_type> & el,
2741  std::vector<unsigned short int> & sl,
2742  std::vector<boundary_id_type> & il)
2743 {
2744 #ifdef LIBMESH_ENABLE_DEPRECATED
2745  mooseDeprecated("The version of MooseMesh::buildSideList() taking three arguments is "
2746  "deprecated, call the version that returns a vector of tuples instead.");
2747  getMesh().get_boundary_info().build_side_list(el, sl, il);
2748 #else
2749  libmesh_ignore(el);
2750  libmesh_ignore(sl);
2751  libmesh_ignore(il);
2752  mooseError("The version of MooseMesh::buildSideList() taking three "
2753  "arguments is not available in your version of libmesh, call the "
2754  "version that returns a vector of tuples instead.");
2755 #endif
2756 }
2757 
2758 std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
2760 {
2761  return getMesh().get_boundary_info().build_side_list();
2762 }
2763 
2764 std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
2766 {
2767  return getMesh().get_boundary_info().build_active_side_list();
2768 }
2769 
2770 unsigned int
2771 MooseMesh::sideWithBoundaryID(const Elem * const elem, const BoundaryID boundary_id) const
2772 {
2773  return getMesh().get_boundary_info().side_with_boundary_id(elem, boundary_id);
2774 }
2775 
2776 MeshBase::node_iterator
2778 {
2779  return getMesh().local_nodes_begin();
2780 }
2781 
2782 MeshBase::node_iterator
2784 {
2785  return getMesh().local_nodes_end();
2786 }
2787 
2788 MeshBase::const_node_iterator
2790 {
2791  return getMesh().local_nodes_begin();
2792 }
2793 
2794 MeshBase::const_node_iterator
2796 {
2797  return getMesh().local_nodes_end();
2798 }
2799 
2800 MeshBase::element_iterator
2802 {
2803  return getMesh().active_local_elements_begin();
2804 }
2805 
2806 const MeshBase::element_iterator
2808 {
2809  return getMesh().active_local_elements_end();
2810 }
2811 
2812 MeshBase::const_element_iterator
2814 {
2815  return getMesh().active_local_elements_begin();
2816 }
2817 
2818 const MeshBase::const_element_iterator
2820 {
2821  return getMesh().active_local_elements_end();
2822 }
2823 
2826 {
2827  return getMesh().n_nodes();
2828 }
2829 
2832 {
2833  return getMesh().n_elem();
2834 }
2835 
2838 {
2839  return getMesh().max_node_id();
2840 }
2841 
2844 {
2845  return getMesh().max_elem_id();
2846 }
2847 
2848 Elem *
2850 {
2851  mooseDeprecated("MooseMesh::elem() is deprecated, please use MooseMesh::elemPtr() instead");
2852  return elemPtr(i);
2853 }
2854 
2855 const Elem *
2857 {
2858  mooseDeprecated("MooseMesh::elem() is deprecated, please use MooseMesh::elemPtr() instead");
2859  return elemPtr(i);
2860 }
2861 
2862 Elem *
2864 {
2865  return getMesh().elem_ptr(i);
2866 }
2867 
2868 const Elem *
2870 {
2871  return getMesh().elem_ptr(i);
2872 }
2873 
2874 Elem *
2876 {
2877  return getMesh().query_elem_ptr(i);
2878 }
2879 
2880 const Elem *
2882 {
2883  return getMesh().query_elem_ptr(i);
2884 }
2885 
2886 bool
2888 {
2889  return _mesh->is_prepared() && _moose_mesh_prepared;
2890 }
2891 
2892 void
2894 {
2895  if (state)
2896  mooseError("We don't have any right to tell the libmesh mesh that it *is* prepared. Only a "
2897  "call to prepare_for_use should tell us that");
2898 
2899  // Some people may call this even before we have a MeshBase object. This isn't dangerous really
2900  // because when the MeshBase object is born, it knows it's in an unprepared state
2901  if (_mesh)
2902  _mesh->set_isnt_prepared();
2903 
2904  // If the libMesh mesh isn't preparead, then our MooseMesh wrapper is also no longer prepared
2905  _moose_mesh_prepared = false;
2906 
2911  _regular_orthogonal_mesh = false;
2912 }
2913 
2914 void
2916 {
2917  prepared(false);
2918 }
2919 
2920 const std::set<SubdomainID> &
2922 {
2923  return _mesh_subdomains;
2924 }
2925 
2926 const std::set<BoundaryID> &
2928 {
2929  return _mesh_boundary_ids;
2930 }
2931 
2932 const std::set<BoundaryID> &
2934 {
2935  return _mesh_sideset_ids;
2936 }
2937 
2938 const std::set<BoundaryID> &
2940 {
2941  return _mesh_nodeset_ids;
2942 }
2943 
2944 void
2945 MooseMesh::setMeshBoundaryIDs(std::set<BoundaryID> boundary_IDs)
2946 {
2947  _mesh_boundary_ids = boundary_IDs;
2948 }
2949 
2950 void
2952  std::unique_ptr<std::map<BoundaryID, RealVectorValue>> boundary_map)
2953 {
2954  _boundary_to_normal_map = std::move(boundary_map);
2955 }
2956 
2957 void
2958 MooseMesh::setBoundaryToNormalMap(std::map<BoundaryID, RealVectorValue> * boundary_map)
2959 {
2960  mooseDeprecated("setBoundaryToNormalMap(std::map<BoundaryID, RealVectorValue> * boundary_map) is "
2961  "deprecated, use the unique_ptr version instead");
2962  _boundary_to_normal_map.reset(boundary_map);
2963 }
2964 
2965 unsigned int
2967 {
2968  return _uniform_refine_level;
2969 }
2970 
2971 void
2972 MooseMesh::setUniformRefineLevel(unsigned int level, bool deletion)
2973 {
2974  _uniform_refine_level = level;
2976 }
2977 
2978 void
2980 {
2981  _ghosted_boundaries.insert(boundary_id);
2982 }
2983 
2984 void
2985 MooseMesh::setGhostedBoundaryInflation(const std::vector<Real> & inflation)
2986 {
2987  _ghosted_boundaries_inflation = inflation;
2988 }
2989 
2990 const std::set<unsigned int> &
2992 {
2993  return _ghosted_boundaries;
2994 }
2995 
2996 const std::vector<Real> &
2998 {
3000 }
3001 
3002 namespace // Anonymous namespace for helpers
3003 {
3004 // A class for templated methods that expect output iterator
3005 // arguments, which adds objects to the Mesh.
3006 // Although any mesh_inserter_iterator can add any object, we
3007 // template it around object type so that type inference and
3008 // iterator_traits will work.
3009 // This object specifically is used to insert extra ghost elems into the mesh
3010 template <typename T>
3011 struct extra_ghost_elem_inserter
3012 {
3013  using iterator_category = std::output_iterator_tag;
3014  using value_type = T;
3015 
3016  extra_ghost_elem_inserter(DistributedMesh & m) : mesh(m) {}
3017 
3018  void operator=(const Elem * e) { mesh.add_extra_ghost_elem(const_cast<Elem *>(e)); }
3019 
3020  void operator=(Node * n) { mesh.add_node(n); }
3021 
3022  void operator=(Point * p) { mesh.add_point(*p); }
3023 
3024  extra_ghost_elem_inserter & operator++() { return *this; }
3025 
3026  extra_ghost_elem_inserter operator++(int) { return extra_ghost_elem_inserter(*this); }
3027 
3028  // We don't return a reference-to-T here because we don't want to
3029  // construct one or have any of its methods called. We just want
3030  // to allow the returned object to be able to do mesh insertions
3031  // with operator=().
3032  extra_ghost_elem_inserter & operator*() { return *this; }
3033 
3034 private:
3035  DistributedMesh & mesh;
3036 };
3037 
3048 struct CompareElemsByLevel
3049 {
3050  bool operator()(const Elem * a, const Elem * b) const
3051  {
3052  libmesh_assert(a);
3053  libmesh_assert(b);
3054  const unsigned int al = a->level(), bl = b->level();
3055  const dof_id_type aid = a->id(), bid = b->id();
3056 
3057  return (al == bl) ? aid < bid : al < bl;
3058  }
3059 };
3060 
3061 } // anonymous namespace
3062 
3063 void
3065 {
3066  // No need to do this if using a serial mesh
3067  // We do not need to ghost boundary elements when _need_ghost_ghosted_boundaries
3068  // is not true. _need_ghost_ghosted_boundaries can be set by a mesh generator
3069  // where boundaries are already ghosted accordingly
3071  return;
3072 
3073  TIME_SECTION("GhostGhostedBoundaries", 3);
3074 
3075  parallel_object_only();
3076 
3077  DistributedMesh & mesh = dynamic_cast<DistributedMesh &>(getMesh());
3078 
3079  // We clear ghosted elements that were added by previous invocations of this
3080  // method but leave ghosted elements that were added by other code, e.g.
3081  // OversampleOutput, untouched
3082  mesh.clear_extra_ghost_elems(_ghost_elems_from_ghost_boundaries);
3084 
3085  std::set<const Elem *, CompareElemsByLevel> boundary_elems_to_ghost;
3086  std::set<Node *> connected_nodes_to_ghost;
3087 
3088  std::vector<const Elem *> family_tree;
3089 
3090  for (const auto & t : mesh.get_boundary_info().build_side_list())
3091  {
3092  auto elem_id = std::get<0>(t);
3093  auto bc_id = std::get<2>(t);
3094 
3095  if (_ghosted_boundaries.find(bc_id) != _ghosted_boundaries.end())
3096  {
3097  Elem * elem = mesh.elem_ptr(elem_id);
3098 
3099 #ifdef LIBMESH_ENABLE_AMR
3100  elem->family_tree(family_tree);
3101  Elem * parent = elem->parent();
3102  while (parent)
3103  {
3104  family_tree.push_back(parent);
3105  parent = parent->parent();
3106  }
3107 #else
3108  family_tree.clear();
3109  family_tree.push_back(elem);
3110 #endif
3111  for (const auto & felem : family_tree)
3112  {
3113  boundary_elems_to_ghost.insert(felem);
3114 
3115  // The entries of connected_nodes_to_ghost need to be
3116  // non-constant, so that they will work in things like
3117  // UpdateDisplacedMeshThread. The container returned by
3118  // family_tree contains const Elems even when the Elem
3119  // it is called on is non-const, so once that interface
3120  // gets fixed we can remove this const_cast.
3121  for (unsigned int n = 0; n < felem->n_nodes(); ++n)
3122  connected_nodes_to_ghost.insert(const_cast<Node *>(felem->node_ptr(n)));
3123  }
3124  }
3125  }
3126 
3127  // We really do want to store this by value instead of by reference
3128  const auto prior_ghost_elems = mesh.extra_ghost_elems();
3129 
3130  mesh.comm().allgather_packed_range(&mesh,
3131  connected_nodes_to_ghost.begin(),
3132  connected_nodes_to_ghost.end(),
3133  extra_ghost_elem_inserter<Node>(mesh));
3134 
3135  mesh.comm().allgather_packed_range(&mesh,
3136  boundary_elems_to_ghost.begin(),
3137  boundary_elems_to_ghost.end(),
3138  extra_ghost_elem_inserter<Elem>(mesh));
3139 
3140  const auto & current_ghost_elems = mesh.extra_ghost_elems();
3141 
3142  std::set_difference(current_ghost_elems.begin(),
3143  current_ghost_elems.end(),
3144  prior_ghost_elems.begin(),
3145  prior_ghost_elems.end(),
3146  std::inserter(_ghost_elems_from_ghost_boundaries,
3148 }
3149 
3150 unsigned int
3152 {
3153  return _patch_size;
3154 }
3155 
3156 void
3158 {
3159  _patch_update_strategy = patch_update_strategy;
3160 }
3161 
3162 const Moose::PatchUpdateType &
3164 {
3165  return _patch_update_strategy;
3166 }
3167 
3168 BoundingBox
3169 MooseMesh::getInflatedProcessorBoundingBox(Real inflation_multiplier) const
3170 {
3171  // Grab a bounding box to speed things up. Note that
3172  // local_bounding_box is *not* equivalent to processor_bounding_box
3173  // with processor_id() except in serial.
3174  BoundingBox bbox = MeshTools::create_local_bounding_box(getMesh());
3175 
3176  // Inflate the bbox just a bit to deal with roundoff
3177  // Adding 1% of the diagonal size in each direction on each end
3178  Real inflation_amount = inflation_multiplier * (bbox.max() - bbox.min()).norm();
3179  Point inflation(inflation_amount, inflation_amount, inflation_amount);
3180 
3181  bbox.first -= inflation; // min
3182  bbox.second += inflation; // max
3183 
3184  return bbox;
3185 }
3186 
3187 MooseMesh::operator libMesh::MeshBase &() { return getMesh(); }
3188 
3189 MooseMesh::operator const libMesh::MeshBase &() const { return getMesh(); }
3190 
3191 const MeshBase *
3193 {
3194  return _mesh.get();
3195 }
3196 
3197 MeshBase &
3199 {
3200  mooseAssert(_mesh, "Mesh hasn't been created");
3201  return *_mesh;
3202 }
3203 
3204 const MeshBase &
3206 {
3207  mooseAssert(_mesh, "Mesh hasn't been created");
3208  return *_mesh;
3209 }
3210 
3211 void
3212 MooseMesh::printInfo(std::ostream & os, const unsigned int verbosity /* = 0 */) const
3213 {
3214  os << '\n';
3215  getMesh().print_info(os, verbosity);
3216  os << std::flush;
3217 }
3218 
3219 const std::vector<dof_id_type> &
3221 {
3222  std::map<boundary_id_type, std::vector<dof_id_type>>::const_iterator it =
3223  _node_set_nodes.find(nodeset_id);
3224 
3225  if (it == _node_set_nodes.end())
3226  {
3227  // On a distributed mesh we might not know about a remote nodeset,
3228  // so we'll return an empty vector and hope the nodeset exists
3229  // elsewhere.
3230  if (!getMesh().is_serial())
3231  {
3232  static const std::vector<dof_id_type> empty_vec;
3233  return empty_vec;
3234  }
3235  // On a replicated mesh we should know about every nodeset and if
3236  // we're asked for one that doesn't exist then it must be a bug.
3237  else
3238  {
3239  mooseError("Unable to nodeset ID: ", nodeset_id, '.');
3240  }
3241  }
3242 
3243  return it->second;
3244 }
3245 
3246 const std::set<BoundaryID> &
3248 {
3249  const auto it = _sub_to_data.find(subdomain_id);
3250 
3251  if (it == _sub_to_data.end())
3252  mooseError("Unable to find subdomain ID: ", subdomain_id, '.');
3253 
3254  return it->second.boundary_ids;
3255 }
3256 
3257 std::set<BoundaryID>
3259 {
3260  const auto & bnd_ids = getSubdomainBoundaryIds(subdomain_id);
3261  std::set<BoundaryID> boundary_ids(bnd_ids.begin(), bnd_ids.end());
3262  std::unordered_map<SubdomainID, std::set<BoundaryID>>::const_iterator it =
3263  _neighbor_subdomain_boundary_ids.find(subdomain_id);
3264 
3265  boundary_ids.insert(it->second.begin(), it->second.end());
3266 
3267  return boundary_ids;
3268 }
3269 
3270 std::set<SubdomainID>
3272 {
3273  std::set<SubdomainID> subdomain_ids;
3274  for (const auto & [sub_id, data] : _sub_to_data)
3275  if (data.boundary_ids.find(bid) != data.boundary_ids.end())
3276  subdomain_ids.insert(sub_id);
3277 
3278  return subdomain_ids;
3279 }
3280 
3281 std::set<SubdomainID>
3283 {
3284  std::set<SubdomainID> subdomain_ids;
3285  for (const auto & it : _neighbor_subdomain_boundary_ids)
3286  if (it.second.find(bid) != it.second.end())
3287  subdomain_ids.insert(it.first);
3288 
3289  return subdomain_ids;
3290 }
3291 
3292 std::set<SubdomainID>
3294 {
3295  std::set<SubdomainID> subdomain_ids = getBoundaryConnectedBlocks(bid);
3296  for (const auto & it : _neighbor_subdomain_boundary_ids)
3297  if (it.second.find(bid) != it.second.end())
3298  subdomain_ids.insert(it.first);
3299 
3300  return subdomain_ids;
3301 }
3302 
3303 const std::set<SubdomainID> &
3305 {
3306  const auto it = _sub_to_data.find(subdomain_id);
3307 
3308  if (it == _sub_to_data.end())
3309  mooseError("Unable to find subdomain ID: ", subdomain_id, '.');
3310 
3311  return it->second.neighbor_subs;
3312 }
3313 
3314 bool
3316 {
3317  bool found_node = false;
3318  for (const auto & it : _bnd_node_ids)
3319  {
3320  if (it.second.find(node_id) != it.second.end())
3321  {
3322  found_node = true;
3323  break;
3324  }
3325  }
3326  return found_node;
3327 }
3328 
3329 bool
3331 {
3332  bool found_node = false;
3333  std::map<boundary_id_type, std::set<dof_id_type>>::const_iterator it = _bnd_node_ids.find(bnd_id);
3334  if (it != _bnd_node_ids.end())
3335  if (it->second.find(node_id) != it->second.end())
3336  found_node = true;
3337  return found_node;
3338 }
3339 
3340 bool
3342 {
3343  bool found_elem = false;
3344  for (const auto & it : _bnd_elem_ids)
3345  {
3346  if (it.second.find(elem_id) != it.second.end())
3347  {
3348  found_elem = true;
3349  break;
3350  }
3351  }
3352  return found_elem;
3353 }
3354 
3355 bool
3357 {
3358  bool found_elem = false;
3359  auto it = _bnd_elem_ids.find(bnd_id);
3360  if (it != _bnd_elem_ids.end())
3361  if (it->second.find(elem_id) != it->second.end())
3362  found_elem = true;
3363  return found_elem;
3364 }
3365 
3366 void
3367 MooseMesh::errorIfDistributedMesh(std::string name) const
3368 {
3370  mooseError("Cannot use ",
3371  name,
3372  " with DistributedMesh!\n",
3373  "Consider specifying parallel_type = 'replicated' in your input file\n",
3374  "to prevent it from being run with DistributedMesh.");
3375 }
3376 
3377 void
3378 MooseMesh::setPartitionerHelper(MeshBase * const mesh)
3379 {
3380  if (_use_distributed_mesh && (_partitioner_name != "default" && _partitioner_name != "parmetis"))
3381  {
3382  _partitioner_name = "parmetis";
3383  _partitioner_overridden = true;
3384  }
3385 
3387 }
3388 
3389 void
3390 MooseMesh::setPartitioner(MeshBase & mesh_base,
3391  MooseEnum & partitioner,
3392  bool use_distributed_mesh,
3393  const InputParameters & params,
3394  MooseObject & context_obj)
3395 {
3396  // Set the partitioner based on partitioner name
3397  switch (partitioner)
3398  {
3399  case -3: // default
3400  // We'll use the default partitioner, but notify the user of which one is being used...
3401  if (use_distributed_mesh)
3402  partitioner = "parmetis";
3403  else
3404  partitioner = "metis";
3405  break;
3406 
3407  // No need to explicitily create the metis or parmetis partitioners,
3408  // They are the default for serial and parallel mesh respectively
3409  case -2: // metis
3410  case -1: // parmetis
3411  break;
3412 
3413  case 0: // linear
3414  mesh_base.partitioner().reset(new LinearPartitioner);
3415  break;
3416  case 1: // centroid
3417  {
3418  if (!params.isParamValid("centroid_partitioner_direction"))
3419  context_obj.paramError(
3420  "centroid_partitioner_direction",
3421  "If using the centroid partitioner you _must_ specify centroid_partitioner_direction!");
3422 
3423  MooseEnum direction = params.get<MooseEnum>("centroid_partitioner_direction");
3424 
3425  if (direction == "x")
3426  mesh_base.partitioner().reset(new CentroidPartitioner(CentroidPartitioner::X));
3427  else if (direction == "y")
3428  mesh_base.partitioner().reset(new CentroidPartitioner(CentroidPartitioner::Y));
3429  else if (direction == "z")
3430  mesh_base.partitioner().reset(new CentroidPartitioner(CentroidPartitioner::Z));
3431  else if (direction == "radial")
3432  mesh_base.partitioner().reset(new CentroidPartitioner(CentroidPartitioner::RADIAL));
3433  break;
3434  }
3435  case 2: // hilbert_sfc
3436  mesh_base.partitioner().reset(new HilbertSFCPartitioner);
3437  break;
3438  case 3: // morton_sfc
3439  mesh_base.partitioner().reset(new MortonSFCPartitioner);
3440  break;
3441  }
3442 }
3443 
3444 void
3445 MooseMesh::setCustomPartitioner(Partitioner * partitioner)
3446 {
3447  _custom_partitioner = partitioner->clone();
3448 }
3449 
3450 bool
3452 {
3454 }
3455 
3456 bool
3458 {
3459  bool mesh_has_second_order_elements = false;
3460  for (auto it = activeLocalElementsBegin(), end = activeLocalElementsEnd(); it != end; ++it)
3461  if ((*it)->default_order() == SECOND)
3462  {
3463  mesh_has_second_order_elements = true;
3464  break;
3465  }
3466 
3467  // We checked our local elements, so take the max over all processors.
3468  comm().max(mesh_has_second_order_elements);
3469  return mesh_has_second_order_elements;
3470 }
3471 
3472 void
3474 {
3476 }
3477 
3478 std::unique_ptr<PointLocatorBase>
3480 {
3481  return getMesh().sub_point_locator();
3482 }
3483 
3484 void
3486 {
3487  mooseAssert(!Threads::in_threads,
3488  "This routine has not been implemented for threads. Please query this routine before "
3489  "a threaded region or contact a MOOSE developer to discuss.");
3490  _finite_volume_info_dirty = false;
3491 
3492  using Keytype = std::pair<const Elem *, unsigned short int>;
3493 
3494  // create a map from elem/side --> boundary ids
3495  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>> side_list =
3497  std::map<Keytype, std::set<boundary_id_type>> side_map;
3498  for (auto & [elem_id, side, bc_id] : side_list)
3499  {
3500  const Elem * elem = _mesh->elem_ptr(elem_id);
3501  Keytype key(elem, side);
3502  auto & bc_set = side_map[key];
3503  bc_set.insert(bc_id);
3504  }
3505 
3506  _face_info.clear();
3507  _all_face_info.clear();
3508  _elem_side_to_face_info.clear();
3509 
3510  _elem_to_elem_info.clear();
3511  _elem_info.clear();
3512 
3513  // by performing the element ID comparison check in the below loop, we are ensuring that we never
3514  // double count face contributions. If a face lies along a process boundary, the only process that
3515  // will contribute to both sides of the face residuals/Jacobians will be the process that owns the
3516  // element with the lower ID.
3517  auto begin = getMesh().active_elements_begin();
3518  auto end = getMesh().active_elements_end();
3519 
3520  // We prepare a map connecting the Elem* and the corresponding ElemInfo
3521  // for the active elements.
3522  for (const Elem * elem : as_range(begin, end))
3523  _elem_to_elem_info.emplace(elem->id(), elem);
3524 
3526 
3527  dof_id_type face_index = 0;
3528  for (const Elem * elem : as_range(begin, end))
3529  {
3530  for (unsigned int side = 0; side < elem->n_sides(); ++side)
3531  {
3532  // get the neighbor element
3533  const Elem * neighbor = elem->neighbor_ptr(side);
3534 
3535  // Check if the FaceInfo shall belong to the element. If yes,
3536  // create and initialize the FaceInfo. We need this to ensure that
3537  // we do not duplicate FaceInfo-s.
3538  if (Moose::FV::elemHasFaceInfo(*elem, neighbor))
3539  {
3540  mooseAssert(!neighbor || (neighbor->level() < elem->level() ? neighbor->active() : true),
3541  "If the neighbor is coarser than the element, we expect that the neighbor must "
3542  "be active.");
3543 
3544  // We construct the faceInfo using the elementinfo and side index
3545  _all_face_info.emplace_back(&_elem_to_elem_info[elem->id()], side, face_index++);
3546 
3547  auto & fi = _all_face_info.back();
3548 
3549  // get all the sidesets that this face is contained in and cache them
3550  // in the face info.
3551  std::set<boundary_id_type> & boundary_ids = fi.boundaryIDs();
3552  boundary_ids.clear();
3553 
3554  // We initialize the weights/other information in faceInfo. If the neighbor does not exist
3555  // or is remote (so when we are on some sort of mesh boundary), we initialize the ghost
3556  // cell and use it to compute the weights corresponding to the faceInfo.
3557  if (!neighbor || neighbor == remote_elem)
3558  fi.computeBoundaryCoefficients();
3559  else
3560  fi.computeInternalCoefficients(&_elem_to_elem_info[neighbor->id()]);
3561 
3562  auto lit = side_map.find(Keytype(&fi.elem(), fi.elemSideID()));
3563  if (lit != side_map.end())
3564  boundary_ids.insert(lit->second.begin(), lit->second.end());
3565 
3566  if (fi.neighborPtr())
3567  {
3568  auto rit = side_map.find(Keytype(fi.neighborPtr(), fi.neighborSideID()));
3569  if (rit != side_map.end())
3570  boundary_ids.insert(rit->second.begin(), rit->second.end());
3571  }
3572  }
3573  }
3574  }
3575 
3576  // Build the local face info and elem_side to face info maps. We need to do this after
3577  // _all_face_info is finished being constructed because emplace_back invalidates all iterators and
3578  // references if ever the new size exceeds capacity
3579  for (auto & fi : _all_face_info)
3580  {
3581  const Elem * const elem = &fi.elem();
3582  const auto side = fi.elemSideID();
3583 
3584 #ifndef NDEBUG
3585  auto pair_it =
3586 #endif
3587  _elem_side_to_face_info.emplace(std::make_pair(elem, side), &fi);
3588  mooseAssert(pair_it.second, "We should be adding unique FaceInfo objects.");
3589 
3590  // We will add the faces on processor boundaries to the list of face infos on each
3591  // associated processor.
3592  if (fi.elem().processor_id() == this->processor_id() ||
3593  (fi.neighborPtr() && (fi.neighborPtr()->processor_id() == this->processor_id())))
3594  _face_info.push_back(&fi);
3595  }
3596 
3597  for (auto & ei : _elem_to_elem_info)
3598  if (ei.second.elem()->processor_id() == this->processor_id())
3599  _elem_info.push_back(&ei.second);
3600 }
3601 
3602 const FaceInfo *
3603 MooseMesh::faceInfo(const Elem * elem, unsigned int side) const
3604 {
3605  auto it = _elem_side_to_face_info.find(std::make_pair(elem, side));
3606 
3607  if (it == _elem_side_to_face_info.end())
3608  return nullptr;
3609  else
3610  {
3611  mooseAssert(it->second,
3612  "For some reason, the FaceInfo object is NULL! Try calling "
3613  "`buildFiniteVolumeInfo()` before using this accessor!");
3614  return it->second;
3615  }
3616 }
3617 
3618 const ElemInfo &
3620 {
3621  return libmesh_map_find(_elem_to_elem_info, id);
3622 }
3623 
3624 void
3626 {
3628  mooseError("Trying to compute face- and elem-info coords when the information is dirty");
3629 
3630  for (auto & fi : _all_face_info)
3631  {
3632  // get elem & neighbor elements, and set subdomain ids
3633  const SubdomainID elem_subdomain_id = fi.elemSubdomainID();
3634  const SubdomainID neighbor_subdomain_id = fi.neighborSubdomainID();
3635 
3637  *this, elem_subdomain_id, fi.faceCentroid(), fi.faceCoord(), neighbor_subdomain_id);
3638  }
3639 
3640  for (auto & ei : _elem_to_elem_info)
3642  *this, ei.second.subdomain_id(), ei.second.centroid(), ei.second.coordFactor());
3643 }
3644 
3645 MooseEnum
3647 {
3648  MooseEnum partitioning("default=-3 metis=-2 parmetis=-1 linear=0 centroid hilbert_sfc morton_sfc",
3649  "default");
3650  return partitioning;
3651 }
3652 
3653 MooseEnum
3655 {
3657  "EDGE EDGE2 EDGE3 EDGE4 QUAD QUAD4 QUAD8 QUAD9 TRI3 TRI6 HEX HEX8 HEX20 HEX27 TET4 TET10 "
3658  "PRISM6 PRISM15 PRISM18 PYRAMID5 PYRAMID13 PYRAMID14");
3659  return elemTypes;
3660 }
3661 
3662 void
3663 MooseMesh::allowRemoteElementRemoval(const bool allow_remote_element_removal)
3664 {
3665  _allow_remote_element_removal = allow_remote_element_removal;
3666  if (_mesh)
3667  _mesh->allow_remote_element_removal(allow_remote_element_removal);
3668 
3669  if (!allow_remote_element_removal)
3670  // If we're not allowing remote element removal now, then we will need deletion later after
3671  // late geoemetric ghosting functors have been added (late geometric ghosting functor addition
3672  // happens when algebraic ghosting functors are added)
3673  _need_delete = true;
3674 }
3675 
3676 void
3678 {
3680  if (!_mesh)
3681  mooseError("Cannot delete remote elements because we have not yet attached a MeshBase");
3682 
3683  _mesh->allow_remote_element_removal(true);
3684 
3685  _mesh->delete_remote_elements();
3686 }
3687 
3688 void
3690 {
3691  mooseAssert(
3692  !Threads::in_threads,
3693  "Performing writes to faceInfo variable association maps. This must be done unthreaded!");
3694 
3695  std::vector<const MooseVariableFieldBase *> moose_vars;
3696 
3697  for (const auto i : make_range(_app.feProblem().numNonlinearSystems()))
3698  {
3699  const auto & nl_variables = _app.feProblem().getNonlinearSystemBase(i).getVariables(0);
3700  for (const auto & var : nl_variables)
3701  if (var->fieldType() == 0)
3702  moose_vars.push_back(var);
3703  }
3704 
3705  const auto & aux_variables = _app.feProblem().getAuxiliarySystem().getVariables(0);
3706  for (const auto & var : aux_variables)
3707  if (var->fieldType() == 0)
3708  moose_vars.push_back(var);
3709 
3710  for (FaceInfo & face : _all_face_info)
3711  {
3712  const SubdomainID elem_subdomain_id = face.elemSubdomainID();
3713  const SubdomainID neighbor_subdomain_id = face.neighborSubdomainID();
3714 
3715  // loop through vars
3716  for (unsigned int j = 0; j < moose_vars.size(); ++j)
3717  {
3718  // get the variable, its name, and its domain of definition
3719  const MooseVariableFieldBase * const var = moose_vars[j];
3720  const std::pair<unsigned int, unsigned int> var_sys =
3721  std::make_pair(var->number(), var->sys().number());
3722  std::set<SubdomainID> var_subdomains = var->blockIDs();
3723 
3733  bool var_defined_elem = var_subdomains.find(elem_subdomain_id) != var_subdomains.end();
3734  bool var_defined_neighbor =
3735  var_subdomains.find(neighbor_subdomain_id) != var_subdomains.end();
3736  if (var_defined_elem && var_defined_neighbor)
3737  face.faceType(var_sys) = FaceInfo::VarFaceNeighbors::BOTH;
3738  else if (!var_defined_elem && !var_defined_neighbor)
3739  face.faceType(var_sys) = FaceInfo::VarFaceNeighbors::NEITHER;
3740  else
3741  {
3742  // this is a boundary face for this variable, set elem or neighbor
3743  if (var_defined_elem)
3744  face.faceType(var_sys) = FaceInfo::VarFaceNeighbors::ELEM;
3745  else if (var_defined_neighbor)
3746  face.faceType(var_sys) = FaceInfo::VarFaceNeighbors::NEIGHBOR;
3747  else
3748  mooseError("Should never get here");
3749  }
3750  }
3751  }
3752 }
3753 
3754 void
3756 {
3757  mooseAssert(!Threads::in_threads,
3758  "Performing writes to elemInfo dof indices. This must be done unthreaded!");
3759 
3760  const unsigned int num_eqs = _app.feProblem().es().n_systems();
3761 
3762  for (auto & elem_info_pair : _elem_to_elem_info)
3763  {
3764  ElemInfo & elem_info = elem_info_pair.second;
3765  auto & dof_vector = elem_info.dofIndices();
3766 
3767  dof_vector.clear();
3768  dof_vector.resize(num_eqs);
3769 
3770  for (const auto i : make_range(_app.feProblem().numNonlinearSystems()))
3772  {
3773  auto & sys = _app.feProblem().getNonlinearSystemBase(i);
3774  dof_vector[sys.number()].resize(sys.nVariables(), libMesh::DofObject::invalid_id);
3775  const auto & variables = sys.getVariables(0);
3776  for (const auto & var : variables)
3777  {
3778  const auto & var_subdomains = var->blockIDs();
3779 
3780  // We will only cache for FV variables and if they live on the current subdomain
3781  if (var->isFV() && var_subdomains.find(elem_info.subdomain_id()) != var_subdomains.end())
3782  {
3783  std::vector<dof_id_type> indices;
3784  var->dofMap().dof_indices(elem_info.elem(), indices, var->number());
3785  mooseAssert(indices.size() == 1, "We expect to have only one dof per element!");
3786  dof_vector[sys.number()][var->number()] = indices[0];
3787  }
3788  }
3789  }
3790 
3792  {
3793  auto & sys = _app.feProblem().getAuxiliarySystem();
3794  dof_vector[sys.number()].resize(sys.nVariables(), libMesh::DofObject::invalid_id);
3795  const auto & aux_variables = sys.getVariables(0);
3796  for (const auto & var : aux_variables)
3797  {
3798  const auto & var_subdomains = var->blockIDs();
3799 
3800  // We will only cache for FV variables and if they live on the current subdomain
3801  if (var->isFV() && var_subdomains.find(elem_info.subdomain_id()) != var_subdomains.end())
3802  {
3803  std::vector<dof_id_type> indices;
3804  var->dofMap().dof_indices(elem_info.elem(), indices, var->number());
3805  mooseAssert(indices.size() == 1, "We expect to have only one dof per element!");
3806  dof_vector[sys.number()][var->number()] = indices[0];
3807  }
3808  }
3809  }
3810  }
3811 }
3812 
3813 void
3815 {
3820 }
3821 
3822 void
3823 MooseMesh::setCoordSystem(const std::vector<SubdomainName> & blocks,
3824  const MultiMooseEnum & coord_sys)
3825 {
3826  TIME_SECTION("setCoordSystem", 5, "Setting Coordinate System");
3827  if (!_provided_coord_blocks.empty() && (_provided_coord_blocks != blocks))
3828  {
3829  const std::string param_name = isParamValid("coord_block") ? "coord_block" : "block";
3830  mooseWarning("Supplied blocks in the 'setCoordSystem' method do not match the value of the "
3831  "'Mesh/",
3832  param_name,
3833  "' parameter. Did you provide different parameter values for 'Mesh/",
3834  param_name,
3835  "' and 'Problem/block'?. We will honor the parameter value from 'Mesh/",
3836  param_name,
3837  "'");
3838  mooseAssert(_coord_system_set,
3839  "If we are arriving here due to a bad specification in the Problem block, then we "
3840  "should have already set our coordinate system subdomains from the Mesh block");
3841  return;
3842  }
3843  if (_pars.isParamSetByUser("coord_type") && getParam<MultiMooseEnum>("coord_type") != coord_sys)
3844  mooseError("Supplied coordinate systems in the 'setCoordSystem' method do not match the value "
3845  "of the 'Mesh/coord_type' parameter. Did you provide different parameter values for "
3846  "'coord_type' to 'Mesh' and 'Problem'?");
3847 
3848  auto subdomains = meshSubdomains();
3849  // It's possible that a user has called this API before the mesh is prepared and consequently we
3850  // don't yet have the subdomains in meshSubdomains()
3851  for (const auto & sub_name : blocks)
3852  {
3853  const auto sub_id = getSubdomainID(sub_name);
3854  subdomains.insert(sub_id);
3855  }
3856 
3857  if (coord_sys.size() <= 1)
3858  {
3859  // We will specify the same coordinate system for all blocks
3860  const auto coord_type = coord_sys.size() == 0
3862  : Moose::stringToEnum<Moose::CoordinateSystemType>(coord_sys[0]);
3863  for (const auto sid : subdomains)
3864  _coord_sys[sid] = coord_type;
3865  }
3866  else
3867  {
3868  if (blocks.size() != coord_sys.size())
3869  mooseError("Number of blocks and coordinate systems does not match.");
3870 
3871  for (const auto i : index_range(blocks))
3872  {
3873  SubdomainID sid = getSubdomainID(blocks[i]);
3874  Moose::CoordinateSystemType coord_type =
3875  Moose::stringToEnum<Moose::CoordinateSystemType>(coord_sys[i]);
3876  _coord_sys[sid] = coord_type;
3877  }
3878 
3879  for (const auto & sid : subdomains)
3880  if (_coord_sys.find(sid) == _coord_sys.end())
3881  mooseError("Subdomain '" + Moose::stringify(sid) +
3882  "' does not have a coordinate system specified.");
3883  }
3884 
3885  _coord_system_set = true;
3886 
3888 }
3889 
3892 {
3893  auto it = _coord_sys.find(sid);
3894  if (it != _coord_sys.end())
3895  return (*it).second;
3896  else
3897  mooseError("Requested subdomain ", sid, " does not exist.");
3898 }
3899 
3902 {
3903  const auto unique_system = _coord_sys.find(*meshSubdomains().begin())->second;
3904  // Check that it is actually unique
3905  bool result = std::all_of(
3906  std::next(_coord_sys.begin()),
3907  _coord_sys.end(),
3908  [unique_system](
3909  typename std::unordered_map<SubdomainID, Moose::CoordinateSystemType>::const_reference
3910  item) { return (item.second == unique_system); });
3911  if (!result)
3912  mooseError("The unique coordinate system of the mesh was requested by the mesh contains "
3913  "multiple blocks with different coordinate systems");
3914 
3916  mooseError("General axisymmetric coordinate axes are being used, and it is currently "
3917  "conservatively assumed that in this case there is no unique coordinate system.");
3918 
3919  return unique_system;
3920 }
3921 
3922 const std::map<SubdomainID, Moose::CoordinateSystemType> &
3924 {
3925  return _coord_sys;
3926 }
3927 
3928 void
3930 {
3931  _rz_coord_axis = rz_coord_axis;
3932 
3934 }
3935 
3936 void
3938  const std::vector<SubdomainName> & blocks,
3939  const std::vector<std::pair<Point, RealVectorValue>> & axes)
3940 {
3941  // Set the axes for the given blocks
3942  mooseAssert(blocks.size() == axes.size(), "Blocks and axes vectors must be the same length.");
3943  for (const auto i : index_range(blocks))
3944  {
3945  const auto subdomain_id = getSubdomainID(blocks[i]);
3946  const auto it = _coord_sys.find(subdomain_id);
3947  if (it == _coord_sys.end())
3948  mooseError("The block '",
3949  blocks[i],
3950  "' has not set a coordinate system. Make sure to call setCoordSystem() before "
3951  "setGeneralAxisymmetricCoordAxes().");
3952  else
3953  {
3954  if (it->second == Moose::COORD_RZ)
3955  {
3956  const auto direction = axes[i].second;
3957  if (direction.is_zero())
3958  mooseError("Only nonzero vectors may be supplied for RZ directions.");
3959 
3960  _subdomain_id_to_rz_coord_axis[subdomain_id] =
3961  std::make_pair(axes[i].first, direction.unit());
3962  }
3963  else
3964  mooseError("The block '",
3965  blocks[i],
3966  "' was provided in setGeneralAxisymmetricCoordAxes(), but the coordinate system "
3967  "for this block is not 'RZ'.");
3968  }
3969  }
3970 
3971  // Make sure there are no RZ blocks that still do not have axes
3972  const auto all_subdomain_ids = meshSubdomains();
3973  for (const auto subdomain_id : all_subdomain_ids)
3974  if (getCoordSystem(subdomain_id) == Moose::COORD_RZ &&
3975  !_subdomain_id_to_rz_coord_axis.count(subdomain_id))
3976  mooseError("The block '",
3977  getSubdomainName(subdomain_id),
3978  "' was specified to use the 'RZ' coordinate system but was not given in "
3979  "setGeneralAxisymmetricCoordAxes().");
3980 
3982 }
3983 
3984 const std::pair<Point, RealVectorValue> &
3986 {
3987  auto it = _subdomain_id_to_rz_coord_axis.find(subdomain_id);
3988  if (it != _subdomain_id_to_rz_coord_axis.end())
3989  return (*it).second;
3990  else
3991  mooseError("Requested subdomain ", subdomain_id, " does not exist.");
3992 }
3993 
3994 bool
3996 {
3997  return _subdomain_id_to_rz_coord_axis.size() > 0;
3998 }
3999 
4000 void
4002 {
4003  if (!_coord_transform)
4004  _coord_transform = std::make_unique<MooseAppCoordTransform>(*this);
4005  else
4006  _coord_transform->setCoordinateSystem(*this);
4007 }
4008 
4009 unsigned int
4011 {
4013  mooseError("getAxisymmetricRadialCoord() should not be called if "
4014  "setGeneralAxisymmetricCoordAxes() has been called.");
4015 
4016  if (_rz_coord_axis == 0)
4017  return 1; // if the rotation axis is x (0), then the radial direction is y (1)
4018  else
4019  return 0; // otherwise the radial direction is assumed to be x, i.e., the rotation axis is y
4020 }
4021 
4022 void
4024 {
4025  for (const auto & elem : getMesh().element_ptr_range())
4026  {
4027  SubdomainID sid = elem->subdomain_id();
4028  if (_coord_sys[sid] == Moose::COORD_RZ && elem->dim() == 3)
4029  mooseError("An RZ coordinate system was requested for subdomain " + Moose::stringify(sid) +
4030  " which contains 3D elements.");
4031  if (_coord_sys[sid] == Moose::COORD_RSPHERICAL && elem->dim() > 1)
4032  mooseError("An RSPHERICAL coordinate system was requested for subdomain " +
4033  Moose::stringify(sid) + " which contains 2D or 3D elements.");
4034  }
4035 }
4036 
4037 void
4039 {
4040  _coord_sys = other_mesh._coord_sys;
4041  _rz_coord_axis = other_mesh._rz_coord_axis;
4043 }
4044 
4045 const MooseUnits &
4047 {
4048  mooseAssert(_coord_transform, "This must be non-null");
4049  return _coord_transform->lengthUnit();
4050 }
4051 
4052 void
4054 {
4055  std::map<SubdomainName, SubdomainID> subdomain;
4056  for (const auto & sbd_id : _mesh_subdomains)
4057  {
4058  std::string sub_name = getSubdomainName(sbd_id);
4059  if (!sub_name.empty() && subdomain.count(sub_name) > 0)
4060  mooseError("The subdomain name ",
4061  sub_name,
4062  " is used for both subdomain with ID=",
4063  subdomain[sub_name],
4064  " and ID=",
4065  sbd_id,
4066  ", Please rename one of them!");
4067  else
4068  subdomain[sub_name] = sbd_id;
4069  }
4070 }
4071 
4072 const std::vector<QpMap> &
4074  const Elem & elem,
4075  const std::map<std::pair<ElemType, unsigned int>, std::vector<QpMap>> & map) const
4076 {
4077  mooseAssert(elem.active() && elem.p_refinement_flag() == Elem::JUST_REFINED,
4078  "These are the conditions that should be met for requesting a refinement map");
4079  // We are actually seeking the map stored with the p_level - 1 key, e.g. the refinement map that
4080  // maps from the previous p_level to this element's p_level
4081  return libmesh_map_find(map,
4082  std::make_pair(elem.type(), cast_int<unsigned int>(elem.p_level() - 1)));
4083 }
4084 
4085 const std::vector<QpMap> &
4087  const Elem & elem,
4088  const std::map<std::pair<ElemType, unsigned int>, std::vector<QpMap>> & map) const
4089 {
4090  mooseAssert(elem.active() && elem.p_refinement_flag() == Elem::JUST_COARSENED,
4091  "These are the conditions that should be met for requesting a coarsening map");
4092  return libmesh_map_find(map, std::make_pair(elem.type(), elem.p_level()));
4093 }
4094 
4095 const std::vector<QpMap> &
4096 MooseMesh::getPRefinementMap(const Elem & elem) const
4097 {
4099 }
4100 
4101 const std::vector<QpMap> &
4102 MooseMesh::getPRefinementSideMap(const Elem & elem) const
4103 {
4105 }
4106 
4107 const std::vector<QpMap> &
4108 MooseMesh::getPCoarseningMap(const Elem & elem) const
4109 {
4111 }
4112 
4113 const std::vector<QpMap> &
4114 MooseMesh::getPCoarseningSideMap(const Elem & elem) const
4115 {
4117 }
ParallelType _parallel_type
Can be set to DISTRIBUTED, REPLICATED, or DEFAULT.
Definition: MooseMesh.h:1380
static InputParameters validParams()
Typical "Moose-style" constructor and copy constructor.
Definition: MooseMesh.C:78
virtual bnd_node_iterator bndNodesEnd()
Definition: MooseMesh.C:1335
virtual bnd_elem_iterator bndElemsEnd()
Definition: MooseMesh.C:1351
std::vector< std::vector< Real > > _bounds
The bounds in each dimension of the mesh for regular orthogonal meshes.
Definition: MooseMesh.h:1536
std::set< Node * > _semilocal_node_list
Used for generating the semilocal node range.
Definition: MooseMesh.h:1445
std::map< dof_id_type, Node * > _quadrature_nodes
Definition: MooseMesh.h:1503
LAGRANGE
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...
Definition: MooseMesh.C:4114
virtual Real getMaxInDimension(unsigned int component) const
Definition: MooseMesh.C:1964
static const std::string & checkpointSuffix()
The file suffix for the checkpoint mesh.
Definition: MooseApp.C:2396
bool _node_to_elem_map_built
Definition: MooseMesh.h:1462
std::vector< Node * > _extreme_nodes
A vector containing the nodes at the corners of a regular orthogonal mesh.
Definition: MooseMesh.h:1590
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition: SystemBase.h:732
ElemType
Node * addQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp, BoundaryID bid, const Point &point)
Adds a fictitious "QuadratureNode".
Definition: MooseMesh.C:1392
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > buildSideList()
As above, but uses the non-deprecated std::tuple interface.
Definition: MooseMesh.C:2759
const std::set< BoundaryID > & meshNodesetIds() const
Returns a read-only reference to the set of nodesets currently present in the Mesh.
Definition: MooseMesh.C:2939
void buildElemIDInfo()
Build extra data for faster access to the information of extra element integers.
Definition: MooseMesh.C:861
std::vector< FaceInfo > _all_face_info
FaceInfo object storing information for face based loops.
Definition: MooseMesh.h:1560
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
std::vector< const FaceInfo * > _face_info
Holds only those FaceInfo objects that have processor_id equal to this process&#39;s id, e.g.
Definition: MooseMesh.h:1564
bool allowRemoteElementRemoval() const
Whether we are allow remote element removal.
Definition: MooseMesh.h:1072
virtual Real getMinInDimension(unsigned int component) const
Returns the min or max of the requested dimension respectively.
Definition: MooseMesh.C:1955
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...
Definition: FVUtils.C:20
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1040
virtual void onMeshChanged()
Declares a callback function that is executed at the conclusion of meshChanged(). ...
Definition: MooseMesh.C:710
bool prepared() const
Setter/getter for whether the mesh is prepared.
Definition: MooseMesh.C:2887
void needsPrepareForUse()
If this method is called, we will call libMesh&#39;s prepare_for_use method when we call Moose&#39;s prepare ...
Definition: MooseMesh.C:2915
const std::set< BoundaryID > & getBoundaryIDs() const
Returns a const reference to a set of all user-specified boundary IDs.
Definition: MooseMesh.C:2727
bool _is_nemesis
True if a Nemesis Mesh was read in.
Definition: MooseMesh.h:1426
std::vector< SubdomainName > _provided_coord_blocks
Set for holding user-provided coordinate system type block names.
Definition: MooseMesh.h:1820
virtual MooseMesh & clone() const
Clone method.
Definition: MooseMesh.C:2569
bool isCustomPartitionerRequested() const
Setter and getter for _custom_partitioner_requested.
Definition: MooseMesh.C:3451
bool _need_ghost_ghosted_boundaries
A parallel mesh generator such as DistributedRectilinearMeshGenerator already make everything ready...
Definition: MooseMesh.h:1783
A class for creating restricted objects.
Definition: Restartable.h:28
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
Definition: MooseApp.h:823
unsigned int _uniform_refine_level
The level of uniform refinement requested (set to zero if AMR is disabled)
Definition: MooseMesh.h:1414
std::vector< dof_id_type > _min_ids
Minimum integer ID for each extra element integer.
Definition: MooseMesh.h:1790
Helper class for sorting Boundary Nodes so that we always get the same order of application for bound...
Definition: MooseMesh.C:803
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.
Definition: MooseMesh.C:1133
auto norm() const -> decltype(std::norm(Real()))
const MooseUnits & lengthUnit() const
Definition: MooseMesh.C:4046
void checkDuplicateSubdomainNames()
Loop through all subdomain IDs and check if there is name duplication used for the subdomains with sa...
Definition: MooseMesh.C:4053
const unsigned int invalid_uint
const std::set< BoundaryID > & getSubdomainBoundaryIds(const SubdomainID subdomain_id) const
Get the list of boundary ids associated with the given subdomain id.
Definition: MooseMesh.C:3247
void mooseDeprecated(Args &&... args) const
RealVectorValue _half_range
A convenience vector used to hold values in each dimension representing half of the range...
Definition: MooseMesh.h:1587
Keeps track of stuff related to assembling.
Definition: Assembly.h:93
void setCoordData(const MooseMesh &other_mesh)
Set the coordinate system data to that of other_mesh.
Definition: MooseMesh.C:4038
static InputParameters validParams()
Describes the parameters this object can take to setup transformations.
virtual ~MooseMesh()
Definition: MooseMesh.C:325
void freeBndElems()
Definition: MooseMesh.C:351
std::map< std::pair< ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_refinement_map
Definition: MooseMesh.h:1707
virtual std::size_t numNonlinearSystems() const override
bool _finite_volume_info_dirty
Definition: MooseMesh.h:1571
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2863
The definition of the bnd_elem_iterator struct.
Definition: MooseMesh.h:1982
bool isBoundaryNode(dof_id_type node_id) const
Returns true if the requested node is in the list of boundary nodes, false otherwise.
Definition: MooseMesh.C:3315
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1292
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToActiveSemilocalElemMap()
If not already created, creates a map from every node to all active semilocal elements to which they ...
Definition: MooseMesh.C:1008
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > buildActiveSideList() const
Calls BoundaryInfo::build_active_side_list.
Definition: MooseMesh.C:2765
static void setPartitioner(MeshBase &mesh_base, MooseEnum &partitioner, bool use_distributed_mesh, const InputParameters &params, MooseObject &context_obj)
Method for setting the partitioner on the passed in mesh_base object.
Definition: MooseMesh.C:3390
void buildLowerDMesh()
Build lower-d mesh for all sides.
Definition: MooseMesh.C:505
const std::set< BoundaryID > & meshSidesetIds() const
Returns a read-only reference to the set of sidesets currently present in the Mesh.
Definition: MooseMesh.C:2933
unsigned int number() const
Get variable number coming from libMesh.
std::unordered_map< const Elem *, unsigned short int > _lower_d_elem_to_higher_d_elem_side
Definition: MooseMesh.h:1758
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
void cacheFVElementalDoFs() const
Cache the DoF indices for FV variables on each element.
Definition: MooseMesh.C:3755
static constexpr Real TOLERANCE
void cacheFaceInfoVariableOwnership() const
Cache if variables live on the elements connected by the FaceInfo objects.
Definition: MooseMesh.C:3689
bool _custom_partitioner_requested
Definition: MooseMesh.h:1398
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.
Definition: MooseMesh.C:1119
Moose::CoordinateSystemType getUniqueCoordSystem() const
Get the coordinate system from the mesh, it must be the same in all subdomains otherwise this will er...
Definition: MooseMesh.C:3901
std::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.
Definition: MooseMesh.h:1461
MooseMesh()=delete
bool isSemiLocal(Node *const node) const
Returns true if the node is semi-local.
Definition: MooseMesh.C:794
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...
Definition: MooseMesh.C:1483
RealVectorValue minPeriodicVector(unsigned int nonlinear_var_num, Point p, Point q) const
This function returns the minimum vector between two points on the mesh taking into account periodici...
Definition: MooseMesh.C:2005
StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > ConstBndElemRange
Definition: MooseMesh.h:2027
const std::vector< std::pair< unsigned int, QpMap > > & getCoarseningMap(const Elem &elem, int input_side)
Get the coarsening map for a given element type.
Definition: MooseMesh.C:2326
FIRST
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.
Definition: MooseMesh.h:1501
const Elem * elem() const
Definition: ElemInfo.h:34
void determineUseDistributedMesh()
Determine whether to use a distributed mesh.
Definition: MooseMesh.C:2575
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.
Definition: MooseMesh.C:2262
const boundary_id_type side_id
const std::string & getBoundaryName(BoundaryID boundary_id)
Return the name of the boundary given the id.
Definition: MooseMesh.C:1566
void cacheChangedLists()
Cache information about what elements were refined and coarsened in the previous step.
Definition: MooseMesh.C:715
bool isTranslatedPeriodic(unsigned int nonlinear_var_num, unsigned int component) const
Returns whether this generated mesh is periodic in the given dimension for the given variable...
Definition: MooseMesh.C:1994
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 ...
Definition: Assembly.C:39
const Point & getPoint(const PointObject &item) const
get a Point reference from the PointData object at index idx in the list
The definition of the bnd_node_iterator struct.
Definition: MooseMesh.h:1939
const SubdomainID BOUNDARY_SIDE_LOWERD_ID
Definition: MooseTypes.C:21
std::vector< const ElemInfo * > _elem_info
Holds only those ElemInfo objects that have processor_id equal to this process&#39;s id, e.g.
Definition: MooseMesh.h:1556
void buildHRefinementAndCoarseningMaps(Assembly *assembly)
Definition: MooseMesh.C:2054
MeshBase & mesh
bool usingGeneralAxisymmetricCoordAxes() const
Returns true if general axisymmetric coordinate axes are being used.
Definition: MooseMesh.C:3995
const std::set< SubdomainID > & getBlockConnectedBlocks(const SubdomainID subdomain_id) const
Get the list of subdomains neighboring a given subdomain.
Definition: MooseMesh.C:3304
virtual const Node * queryNodePtr(const dof_id_type i) const
Definition: MooseMesh.C:662
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.
Definition: MooseMesh.h:1757
Helper object for holding qp mapping info.
Definition: MooseMesh.h:69
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
bool _has_lower_d
Whether there are any lower-dimensional blocks that are manifolds of higher-dimensional block faces...
Definition: MooseMesh.h:1762
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::vector< Real > & getGhostedBoundaryInflation() const
Return a writable reference to the _ghosted_boundaries_inflation vector.
Definition: MooseMesh.C:2997
std::unique_ptr< ConstElemPointerRange > _refined_elements
The elements that were just refined.
Definition: MooseMesh.h:1432
std::vector< std::vector< bool > > _id_identical_flag
Flags to indicate whether or not any two extra element integers are the same.
Definition: MooseMesh.h:1792
virtual dof_id_type maxElemId() const
Definition: MooseMesh.C:2843
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:148
const Parallel::Communicator & comm() const
virtual bnd_elem_iterator bndElemsBegin()
Return iterators to the beginning/end of the boundary elements list.
Definition: MooseMesh.C:1343
void setUniformRefineLevel(unsigned int, bool deletion=true)
Set uniform refinement level.
Definition: MooseMesh.C:2972
const std::vector< QpMap > & getPCoarseningMapHelper(const Elem &elem, const std::map< std::pair< ElemType, unsigned int >, std::vector< QpMap >> &) const
Definition: MooseMesh.C:4086
MooseEnum _partitioner_name
The partitioner used on this mesh.
Definition: MooseMesh.h:1393
std::map< dof_id_type, std::set< SubdomainID > > _block_node_list
list of nodes that belongs to a specified block (domain)
Definition: MooseMesh.h:1509
bool _node_to_active_semilocal_elem_map_built
Definition: MooseMesh.h:1466
std::map< boundary_id_type, std::set< dof_id_type > > _bnd_node_ids
Map of sets of node IDs in each boundary.
Definition: MooseMesh.h:1493
virtual void init()
Initialize the Mesh object.
Definition: MooseMesh.C:2625
ConstElemPointerRange * refinedElementRange() const
Return a range that is suitable for threaded execution over elements that were just refined...
Definition: MooseMesh.C:733
unsigned int getHigherDSide(const Elem *elem) const
Returns the local side ID of the interior parent aligned with the lower dimensional element...
Definition: MooseMesh.C:1494
std::unordered_map< std::pair< const Elem *, unsigned int >, FaceInfo * > _elem_side_to_face_info
Map from elem-side pair to FaceInfo.
Definition: MooseMesh.h:1568
void detectPairedSidesets()
This routine detects paired sidesets of a regular orthogonal mesh (.i.e.
Definition: MooseMesh.C:1773
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition: MooseMesh.C:1280
This class provides an interface for common operations on field variables of both FE and FV types wit...
const Parallel::Communicator & _communicator
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
void setMeshBoundaryIDs(std::set< BoundaryID > boundary_IDs)
Sets the set of BoundaryIDs Is called by AddAllSideSetsByNormals.
Definition: MooseMesh.C:2945
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] ...
Definition: MooseMesh.h:1512
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.
bool _linear_finite_volume_dofs_cached
Definition: MooseMesh.h:1576
void cacheInfo()
Definition: MooseMesh.C:1209
std::basic_ostream< charT, traits > * os
Definition: InfixIterator.h:33
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.
Definition: MooseMesh.C:2509
std::map< std::pair< ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_coarsening_side_map
Definition: MooseMesh.h:1734
std::set< Elem * > _ghost_elems_from_ghost_boundaries
Set of elements ghosted by ghostGhostedBoundaries.
Definition: MooseMesh.h:1777
SECOND
std::map< std::pair< int, 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:
Definition: MooseMesh.h:1730
virtual void buildMesh()=0
Must be overridden by child classes.
void setPartitionerHelper(MeshBase *mesh=nullptr)
Definition: MooseMesh.C:3378
void deleteRemoteElements()
Delete remote elements.
Definition: MooseMesh.C:3677
bool isSplitMesh() const
Whether or not this is a split mesh operation.
Definition: MooseApp.C:1179
unsigned int _to
The qp to map to.
Definition: MooseMesh.h:78
bool in_threads
BoundaryID _bnd_id
boundary id for the node
Definition: BndNode.h:26
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:1077
Node * _node
pointer to the node
Definition: BndNode.h:24
Real distance(const Point &p)
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:636
bool _allow_recovery
Whether or not this Mesh is allowed to read a recovery file.
Definition: MooseMesh.h:1765
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
bool operator()(const BndNode *const &lhs, const BndNode *const &rhs)
Definition: MooseMesh.C:808
void buildNodeListFromSideList()
Calls BoundaryInfo::build_node_list_from_side_list().
Definition: MooseMesh.C:2733
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
FEProblemBase & feProblem() const
Definition: MooseApp.C:1326
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition: MooseMesh.C:1537
void setPatchUpdateStrategy(Moose::PatchUpdateType patch_update_strategy)
Set the patch size update strategy.
Definition: MooseMesh.C:3157
void buildFiniteVolumeInfo() const
Builds the face and elem info vectors that store meta-data needed for looping over and doing calculat...
Definition: MooseMesh.C:3485
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.
Definition: MooseMesh.h:1753
const std::pair< Point, RealVectorValue > & getGeneralAxisymmetricCoordAxis(SubdomainID subdomain_id) const
Gets the general axisymmetric coordinate axis for a block.
Definition: MooseMesh.C:3985
void reinit(const Elem *elem)
Reinitialize objects (JxW, q_points, ...) for an elements.
Definition: Assembly.C:1811
SubdomainID getSubdomainID(const SubdomainName &subdomain_name, const MeshBase &mesh)
Gets the subdomain ID associated with the given SubdomainName.
StoredRange< MeshBase::const_element_iterator, const Elem *> ConstElemRange
std::unique_ptr< NodeRange > _active_node_range
Definition: MooseMesh.h:1454
auto max(const L &left, const R &right)
const std::set< BoundaryID > & meshBoundaryIds() const
Returns a read-only reference to the set of boundary IDs currently present in the Mesh...
Definition: MooseMesh.C:2927
virtual Elem * queryElemPtr(const dof_id_type i)
Definition: MooseMesh.C:2875
elem_info_iterator ownedElemInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1310
void setIsCustomPartitionerRequested(bool cpr)
Definition: MooseMesh.C:3473
virtual EquationSystems & es() override
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
std::unique_ptr< StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > > _bnd_elem_range
Definition: MooseMesh.h:1458
virtual bnd_node_iterator bndNodesBegin()
Return iterators to the beginning/end of the boundary nodes list.
Definition: MooseMesh.C:1327
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".
Definition: MooseMesh.C:2337
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
StoredRange< std::vector< const Elem * >::iterator, const Elem * > ConstElemPointerRange
Definition: MooseTypes.h:206
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
Gets the boundary ID associated with the given BoundaryName.
QBase *const & writeableQRuleFace()
Returns the reference to the current quadrature being used on a current face.
Definition: Assembly.h:292
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
Definition: MooseMesh.C:3367
const MeshBase * getMeshPtr() const
Definition: MooseMesh.C:3192
bool getDistributedMeshOnCommandLine() const
Returns true if the user specified –distributed-mesh (or –parallel-mesh, for backwards compatibilit...
Definition: MooseApp.h:464
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:35
const std::vector< const FaceInfo * > & faceInfo() const
Accessor for local FaceInfo objects.
Definition: MooseMesh.h:2108
std::map< 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, child_side).
Definition: MooseMesh.h:1713
void updateCoordTransform()
Update the coordinate transformation object based on our coordinate system data.
Definition: MooseMesh.C:4001
std::map< SubdomainID, Moose::CoordinateSystemType > _coord_sys
Type of coordinate system per subdomain.
Definition: MooseMesh.h:1804
static const int GRAIN_SIZE
Definition: MooseMesh.C:63
bool _use_distributed_mesh
False by default.
Definition: MooseMesh.h:1385
void libmesh_ignore(const Args &...)
CONSTANT
std::unique_ptr< std::map< BoundaryID, RealVectorValue > > _boundary_to_normal_map
The boundary to normal map - valid only when AddAllSideSetsByNormals is active.
Definition: MooseMesh.h:1486
const dof_id_type n_nodes
bool _built_from_other_mesh
Whether or not this mesh was built from another mesh.
Definition: MooseMesh.h:1376
bool _allow_remote_element_removal
Whether to allow removal of remote elements.
Definition: MooseMesh.h:1774
SemiLocalNodeRange * getActiveSemiLocalNodeRange() const
Definition: MooseMesh.C:1068
int8_t boundary_id_type
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.
Definition: MooseMesh.C:1144
void setSubdomainName(SubdomainID subdomain_id, const SubdomainName &name)
This method sets the name for subdomain_id to name.
Definition: MooseMesh.C:1525
void clearQuadratureNodes()
Clear out any existing quadrature nodes.
Definition: MooseMesh.C:1462
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3198
void min(const T &r, T &o, Request &req) const
const std::map< SubdomainID, Moose::CoordinateSystemType > & getCoordSystem() const
Get the map from subdomain ID to coordinate system type, e.g.
Definition: MooseMesh.C:3923
std::vector< BndNode * > _bnd_nodes
array of boundary nodes
Definition: MooseMesh.h:1489
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
Definition: MooseMesh.C:2678
unsigned int _from
The qp to map from.
Definition: MooseMesh.h:75
std::pair< const Node *, BoundaryID > PeriodicNodeInfo
Helper type for building periodic node maps.
Definition: MooseMesh.h:1052
QBase *const & writeableQRule()
Returns the reference to the current quadrature being used.
Definition: Assembly.h:216
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 ...
Definition: MooseMesh.C:2603
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition: MooseMesh.C:4010
const std::set< unsigned int > & getGhostedBoundaries() const
Return a writable reference to the set of ghosted boundary IDs.
Definition: MooseMesh.C:2991
bool _construct_node_list_from_side_list
Whether or not to allow generation of nodesets from sidesets.
Definition: MooseMesh.h:1768
boundary_id_type BoundaryID
void buildCoarseningMap(const Elem &elem, QBase &qrule, QBase &qrule_face, int input_side)
Build the coarsening map for a given element type.
Definition: MooseMesh.C:2298
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
unsigned int sideWithBoundaryID(const Elem *const elem, const BoundaryID boundary_id) const
Calls BoundaryInfo::side_with_boundary_id().
Definition: MooseMesh.C:2771
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.
Definition: MooseMesh.C:3220
virtual const Node * nodePtr(const dof_id_type i) const
Definition: MooseMesh.C:650
std::vector< dof_id_type > _max_ids
Maximum integer ID for each extra element integer.
Definition: MooseMesh.h:1788
const std::vector< QpMap > & getPRefinementMapHelper(const Elem &elem, const std::map< std::pair< ElemType, unsigned int >, std::vector< QpMap >> &) const
Definition: MooseMesh.C:4073
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
void family_tree(T elem, std::vector< T > &family, bool reset=true)
libmesh_assert(ctx)
void update()
Calls buildNodeListFromSideList(), buildNodeList(), and buildBndElemList().
Definition: MooseMesh.C:483
static const dof_id_type invalid_id
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:50
const std::pair< BoundaryID, BoundaryID > * getPairedBoundaryMapping(unsigned int component)
This function attempts to return the paired boundary ids for the given component. ...
Definition: MooseMesh.C:2036
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
std::set< BoundaryID > _mesh_nodeset_ids
Definition: MooseMesh.h:1482
StoredRange< MeshBase::const_node_iterator, const Node *> ConstNodeRange
std::unique_ptr< MooseAppCoordTransform > _coord_transform
A coordinate transformation object that describes how to transform this problem&#39;s coordinate system i...
Definition: MooseMesh.h:1814
std::set< SubdomainID > getBoundaryConnectedBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary.
Definition: MooseMesh.C:3271
void checkCoordinateSystems()
Performs a sanity check for every element in the mesh.
Definition: MooseMesh.C:4023
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.
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
std::map< std::pair< ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_coarsening_map
Definition: MooseMesh.h:1732
const bool _is_split
Whether or not we are using a (pre-)split mesh (automatically DistributedMesh)
Definition: MooseMesh.h:1542
void setCoordSystem(const std::vector< SubdomainName > &blocks, const MultiMooseEnum &coord_sys)
Set the coordinate system for the provided blocks to coord_sys.
Definition: MooseMesh.C:3823
std::unique_ptr< ConstElemPointerRange > _coarsened_elements
The elements that were just coarsened.
Definition: MooseMesh.h:1435
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.
Definition: MooseMesh.C:931
subdomain_id_type SubdomainID
std::set< BoundaryID > _mesh_boundary_ids
A set of boundary IDs currently present in the mesh.
Definition: MooseMesh.h:1480
const Node * addUniqueNode(const Point &p, Real tol=1e-6)
Add a new node to the mesh.
Definition: MooseMesh.C:1358
std::vector< BndNode > _extra_bnd_nodes
Definition: MooseMesh.h:1506
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1125
bool _moose_mesh_prepared
True if prepare has been called on the mesh.
Definition: MooseMesh.h:1429
auto norm(const T &a) -> decltype(std::abs(a))
The definition of the face_info_iterator struct.
Definition: MooseMesh.h:1851
unsigned int uniformRefineLevel() const
Returns the level of uniform refinement requested (zero if AMR is disabled).
Definition: MooseMesh.C:2966
std::vector< BndElement * > _bnd_elems
array of boundary elems
Definition: MooseMesh.h:1496
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:62
bool _coord_system_set
Whether the coordinate system has been set.
Definition: MooseMesh.h:1817
std::vector< SubdomainName > getSubdomainNames(const std::vector< SubdomainID > &subdomain_ids) const
Get the associated subdomainNames for the subdomain ids that are passed in.
Definition: MooseMesh.C:1543
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...
Definition: MooseMesh.C:4096
AuxiliarySystem & getAuxiliarySystem()
Real minPeriodicDistance(unsigned int nonlinear_var_num, Point p, Point q) const
This function returns the distance between two points on the mesh taking into account periodicity for...
Definition: MooseMesh.C:2030
bool hasSecondOrderElements()
check if the mesh has SECOND order elements
Definition: MooseMesh.C:3457
unsigned int getPatchSize() const
Getter for the patch_size parameter.
Definition: MooseMesh.C:3151
void buildRefinementAndCoarseningMaps(Assembly *assembly)
Create the refinement and coarsening maps necessary for projection of stateful material properties wh...
Definition: MooseMesh.C:2209
void findAdaptivityQpMaps(const Elem *template_elem, QBase &qrule, 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&#39;s are closest to each other between a parent and it...
Definition: MooseMesh.C:2368
bool _parallel_type_overridden
Definition: MooseMesh.h:1387
Interface for objects interacting with the PerfGraph.
MeshBase::element_iterator activeLocalElementsBegin()
Calls active_local_nodes_begin/end() on the underlying libMesh mesh object.
Definition: MooseMesh.C:2801
std::vector< Node * > _node_map
Vector of all the Nodes in the mesh for determining when to add a new point.
Definition: MooseMesh.h:1530
std::map< dof_id_type, std::map< unsigned int, std::map< dof_id_type, Node * > > > _elem_to_side_to_qp_to_quadrature_nodes
Definition: MooseMesh.h:1505
std::unique_ptr< StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > > _bnd_node_range
Definition: MooseMesh.h:1456
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...
Definition: MooseMesh.C:4102
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...
Definition: MooseMesh.h:1552
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
Definition: MooseMesh.C:1444
void printInfo(std::ostream &os=libMesh::out, const unsigned int verbosity=0) const
Calls print_info() on the underlying Mesh.
Definition: MooseMesh.C:3212
virtual dof_id_type nNodes() const
Calls n_nodes/elem() on the underlying libMesh mesh object.
Definition: MooseMesh.C:2825
MONOMIAL
std::pair< T, U > ResultItem
Definition: KDTree.h:24
static MooseEnum partitioning()
returns MooseMesh partitioning options so other classes can use it
Definition: MooseMesh.C:3646
std::map< std::pair< ElemType, unsigned int >, std::vector< QpMap > > _elem_type_to_p_refinement_side_map
Definition: MooseMesh.h:1709
const std::vector< std::vector< dof_id_type > > & dofIndices() const
Definition: ElemInfo.h:39
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
const std::vector< const Elem * > & coarsenedElementChildren(const Elem *elem) const
Get the newly removed children element ids for an element that was just coarsened.
Definition: MooseMesh.C:745
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
Definition: MooseMesh.C:902
void setBoundaryName(BoundaryID boundary_id, BoundaryName name)
This method sets the boundary name of the boundary based on the id parameter.
Definition: MooseMesh.C:1554
bool isParamSetByUser(const std::string &nm) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
Moose::PatchUpdateType _patch_update_strategy
The patch update strategy.
Definition: MooseMesh.h:1527
infix_ostream_iterator< T, charT, traits > & operator=(T const &item)
Definition: InfixIterator.h:46
Physical unit management class with runtime unit string parsing, unit checking, unit conversion...
Definition: Units.h:32
void addPeriodicVariable(unsigned int var_num, BoundaryID primary, BoundaryID secondary)
For "regular orthogonal" meshes, determine if variable var_num is periodic with respect to the primar...
Definition: MooseMesh.C:1973
StoredRange< std::set< Node * >::iterator, Node * > SemiLocalNodeRange
Definition: MooseMesh.h:55
void setCurrentSubdomainID(SubdomainID i)
set the current subdomain ID
Definition: Assembly.h:377
std::set< BoundaryID > _mesh_sideset_ids
Definition: MooseMesh.h:1481
void setGeneralAxisymmetricCoordAxes(const std::vector< SubdomainName > &blocks, const std::vector< std::pair< Point, RealVectorValue >> &axes)
Sets the general coordinate axes for axisymmetric blocks.
Definition: MooseMesh.C:3937
void setBoundaryToNormalMap(std::unique_ptr< std::map< BoundaryID, RealVectorValue >> boundary_map)
Sets the mapping between BoundaryID and normal vector Is called by AddAllSideSetsByNormals.
Definition: MooseMesh.C:2951
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool _partitioner_overridden
Definition: MooseMesh.h:1394
bool detectOrthogonalDimRanges(Real tol=1e-6)
This routine determines whether the Mesh is a regular orthogonal mesh (i.e.
Definition: MooseMesh.C:1699
void updateActiveSemiLocalNodeRange(std::set< dof_id_type > &ghosted_elems)
Clears the "semi-local" node list and rebuilds it.
Definition: MooseMesh.C:753
std::map< const Elem *, std::vector< const Elem * > > _coarsened_element_children
Map of Parent elements to children elements for elements that were just coarsened.
CoordinateSystemType
Definition: MooseTypes.h:722
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...
Definition: MooseMesh.C:941
unsigned int nFVVariables() const
Get the number of finite volume variables in this system.
Definition: SystemBase.C:859
unsigned int getBlocksMaxDimension(const std::vector< SubdomainName > &blocks) const
Returns the maximum element dimension on the given blocks.
Definition: MooseMesh.C:2699
std::unique_ptr< libMesh::MeshBase > _mesh
Pointer to underlying libMesh mesh object.
Definition: MooseMesh.h:1390
void max(const T &r, T &o, Request &req) const
NodeRange * getActiveNodeRange()
Definition: MooseMesh.C:1054
void buildPeriodicNodeSets(std::map< BoundaryID, std::set< dof_id_type >> &periodic_node_sets, unsigned int var_number, PeriodicBoundaries *pbs) const
This routine builds a datastructure of node ids organized by periodic boundary ids.
Definition: MooseMesh.C:1672
infix_ostream_iterator< T, charT, traits > & operator*()
Definition: InfixIterator.h:56
void buildRefinementMap(const Elem &elem, QBase &qrule, QBase &qrule_face, int parent_side, int child, int child_side)
Build the refinement map for a given element type.
Definition: MooseMesh.C:2219
void setGhostedBoundaryInflation(const std::vector< Real > &inflation)
This sets the inflation amount for the bounding box for each partition for use in ghosting boundaries...
Definition: MooseMesh.C:2985
const SubdomainID INTERNAL_SIDE_LOWERD_ID
Definition: MooseTypes.C:20
void freeBndNodes()
Definition: MooseMesh.C:333
The definition of the elem_info_iterator struct.
Definition: MooseMesh.h:1895
Real dimensionWidth(unsigned int component) const
Returns the width of the requested dimension.
Definition: MooseMesh.C:1949
PatchUpdateType
Type of patch update strategy for modeling node-face constraints or contact.
Definition: MooseTypes.h:865
bool _skip_deletion_repartition_after_refine
Whether or not skip remote deletion and repartition after uniform refinements.
Definition: MooseMesh.h:1420
std::set< SubdomainID > getBoundaryConnectedSecondaryBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary of its secondary side.
Definition: MooseMesh.C:3282
bool _need_delete
Whether we need to delete remote elements after init&#39;ing the EquationSystems.
Definition: MooseMesh.h:1771
void setAxisymmetricCoordAxis(const MooseEnum &rz_coord_axis)
For axisymmetric simulations, set the symmetry coordinate axis.
Definition: MooseMesh.C:3929
std::set< BoundaryID > getSubdomainInterfaceBoundaryIds(const SubdomainID subdomain_id) const
Get the list of boundaries that contact the given subdomain.
Definition: MooseMesh.C:3258
std::vector< const Elem * > _refined_elements
The elements that were just refined.
std::unique_ptr< ConstElemRange > _active_local_elem_range
A range for use with threading.
Definition: MooseMesh.h:1451
IntRange< T > make_range(T beg, T end)
virtual const Node & node(const dof_id_type i) const
Various accessors (pointers/references) for Node "i".
Definition: MooseMesh.C:622
infix_ostream_iterator< T, charT, traits > & operator++()
Definition: InfixIterator.h:57
BoundingBox getInflatedProcessorBoundingBox(Real inflation_multiplier=0.01) const
Get a (slightly inflated) processor bounding box.
Definition: MooseMesh.C:3169
std::map< unsigned int, std::vector< bool > > _periodic_dim
A map of vectors indicating which dimensions are periodic in a regular orthogonal mesh for the specif...
Definition: MooseMesh.h:1582
void setMeshBase(std::unique_ptr< MeshBase > mesh_base)
Method to set the mesh_base object.
Definition: MooseMesh.C:2618
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void buildBndElemList()
Definition: MooseMesh.C:957
std::set< SubdomainID > getInterfaceConnectedBlocks(const BoundaryID bid) const
Get the list of subdomains contacting the given boundary.
Definition: MooseMesh.C:3293
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
std::vector< Real > _ghosted_boundaries_inflation
Definition: MooseMesh.h:1515
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.
Definition: MooseMesh.h:1786
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
unsigned int _patch_size
The number of nodes to consider in the NearestNode neighborhood.
Definition: MooseMesh.h:1518
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_name) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1519
elem_info_iterator ownedElemInfoEnd()
Definition: MooseMesh.C:1318
void addGhostedBoundary(BoundaryID boundary_id)
This will add the boundary ids to be ghosted to this processor.
Definition: MooseMesh.C:2979
virtual dof_id_type maxNodeId() const
Calls max_node/elem_id() on the underlying libMesh mesh object.
Definition: MooseMesh.C:2837
virtual Elem * elem(const dof_id_type i)
Various accessors (pointers/references) for Elem "i".
Definition: MooseMesh.C:2849
StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > * getBoundaryElementRange()
Definition: MooseMesh.C:1105
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
void paramWarning(const std::string &param, Args... args) const
Emits a warning prefixed with the file and line number of the given param (from the input file) along...
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1301
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::unordered_map< SubdomainID, std::pair< Point, RealVectorValue > > _subdomain_id_to_rz_coord_axis
Map of subdomain ID to general axisymmetric axis.
Definition: MooseMesh.h:1810
Class used for caching additional information for elements such as the volume and centroid...
Definition: ElemInfo.h:25
MeshBase::node_iterator localNodesEnd()
Definition: MooseMesh.C:2783
const RealVectorValue & getNormalByBoundaryID(BoundaryID id) const
Returns the normal vector associated with a given BoundaryID.
Definition: MooseMesh.C:2559
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
std::set< SubdomainID > _mesh_subdomains
A set of subdomain IDs currently present in the mesh.
Definition: MooseMesh.h:1472
ConstElemPointerRange * coarsenedElementRange() const
Return a range that is suitable for threaded execution over elements that were just coarsened...
Definition: MooseMesh.C:739
static InputParameters validParams()
Definition: MooseObject.C:24
const Moose::PatchUpdateType & getPatchUpdateStrategy() const
Get the current patch update strategy.
Definition: MooseMesh.C:3163
bool doingPRefinement() const
Query whether we have p-refinement.
Definition: MooseMesh.h:1330
std::vector< std::pair< BoundaryID, BoundaryID > > _paired_boundary
A vector holding the paired boundaries for a regular orthogonal mesh.
Definition: MooseMesh.h:1539
void ghostGhostedBoundaries()
Actually do the ghosting of boundaries that need to be ghosted to this processor. ...
Definition: MooseMesh.C:3064
std::set< unsigned int > _ghosted_boundaries
Definition: MooseMesh.h:1514
MeshBase::node_iterator localNodesBegin()
Calls local_nodes_begin/end() on the underlying libMesh mesh object.
Definition: MooseMesh.C:2777
unsigned int _rz_coord_axis
Storage for RZ axis selection.
Definition: MooseMesh.h:1807
void computeFiniteVolumeCoords() const
Compute the face coordinate value for all FaceInfo and ElemInfo objects.
Definition: MooseMesh.C:3625
void buildNodeList()
Calls BoundaryInfo::build_node_list()/build_side_list() and makes separate copies of Nodes/Elems in t...
Definition: MooseMesh.C:827
std::unordered_map< SubdomainID, SubdomainData > _sub_to_data
Holds a map from subdomain ids to associated data.
Definition: MooseMesh.h:1750
bool isBoundaryElem(dof_id_type elem_id) const
Returns true if the requested element is in the list of boundary elements, false otherwise.
Definition: MooseMesh.C:3341
std::map< const Elem *, std::vector< const Elem * > > _coarsened_element_children
Map of Parent elements to child elements for elements that were just coarsened.
Definition: MooseMesh.h:1442
processor_id_type processor_id() const
StoredRange< MeshBase::node_iterator, Node *> NodeRange
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 ...
Definition: MooseMesh.C:4108
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1167
SystemBase & sys()
Get the system this variable is part of.
auto min(const L &left, const R &right)
SearchParams SearchParameters
std::vector< const Elem * > _coarsened_elements
The elements that were just coarsened.
virtual std::unique_ptr< PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default)...
Definition: MooseMesh.C:3479
std::string getRestartRecoverFileBase() const
The file_base for the recovery file.
Definition: MooseApp.h:498
uint8_t unique_id_type
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.
Definition: MooseMesh.C:1127
const MeshBase::element_iterator activeLocalElementsEnd()
Definition: MooseMesh.C:2807
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1091
void ErrorVector unsigned int
auto index_range(const T &sizable)
std::map< std::pair< int, 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:
Definition: MooseMesh.h:1705
bool _regular_orthogonal_mesh
Boolean indicating whether this mesh was detected to be regular and orthogonal.
Definition: MooseMesh.h:1533
void buildPeriodicNodeMap(std::multimap< dof_id_type, dof_id_type > &periodic_node_map, unsigned int var_number, PeriodicBoundaries *pbs) const
This routine builds a multimap of boundary ids to matching boundary ids across all periodic boundarie...
Definition: MooseMesh.C:1587
std::map< dof_id_type, std::vector< dof_id_type > > _node_to_active_semilocal_elem_map
A map of all of the current nodes to the active elements that they are connected to.
Definition: MooseMesh.h:1465
bool prepare(const MeshBase *mesh_to_clone)
Calls prepare_for_use() if the underlying MeshBase object isn&#39;t prepared, then communicates various b...
Definition: MooseMesh.C:364
const ElemInfo & elemInfo(const dof_id_type id) const
Accessor for the elemInfo object for a given element ID.
Definition: MooseMesh.C:3619
Real _distance
The distance between them.
Definition: MooseMesh.h:81
void setCustomPartitioner(Partitioner *partitioner)
Setter for custom partitioner.
Definition: MooseMesh.C:3445
SubdomainID subdomain_id() const
We return the subdomain ID of the corresponding libmesh element.
Definition: ElemInfo.h:43
static MooseEnum elemTypes()
returns MooseMesh element type options
Definition: MooseMesh.C:3654
std::unique_ptr< Partitioner > _custom_partitioner
The custom partitioner.
Definition: MooseMesh.h:1397
void meshChanged()
Declares that the MooseMesh has changed, invalidates cached data and rebuilds caches.
Definition: MooseMesh.C:684
void buildPRefinementAndCoarseningMaps(Assembly *assembly)
Definition: MooseMesh.C:2111
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
Definition: MooseMesh.C:1474
uint8_t dof_id_type
virtual dof_id_type nElem() const
Definition: MooseMesh.C:2831
const std::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...
Definition: MooseMesh.C:980
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, by which we mean that elements on both sides of the boundary are in those blocks.
Definition: MooseMesh.C:1175
std::unique_ptr< SemiLocalNodeRange > _active_semilocal_node_range
Definition: MooseMesh.h:1453
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2921
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
Definition: MooseMesh.C:1513
std::unique_ptr< ConstNodeRange > _local_node_range
Definition: MooseMesh.h:1455
void setupFiniteVolumeMeshData() const
Sets up the additional data needed for finite volume computations.
Definition: MooseMesh.C:3814
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
void set_union(T &data, const unsigned int root_id) const
const RemoteElem * remote_elem
virtual unsigned int effectiveSpatialDimension() const
Returns the effective spatial dimension determined by the coordinates actually used by the mesh...
Definition: MooseMesh.C:2684