LCOV - code coverage report
Current view: top level - include/mesh - MooseMesh.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 104 108 96.3 %
Date: 2026-05-29 20:35:17 Functions: 58 59 98.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       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             : #pragma once
      11             : 
      12             : #ifdef MOOSE_KOKKOS_ENABLED
      13             : #include "KokkosMesh.h"
      14             : #endif
      15             : 
      16             : #include "MooseObject.h"
      17             : #include "BndNode.h"
      18             : #include "BndElement.h"
      19             : #include "Restartable.h"
      20             : #include "MooseEnum.h"
      21             : #include "PerfGraphInterface.h"
      22             : #include "MooseHashing.h"
      23             : #include "MooseApp.h"
      24             : #include "FaceInfo.h"
      25             : #include "ElemInfo.h"
      26             : 
      27             : #include <memory> //std::unique_ptr
      28             : #include <unordered_map>
      29             : #include <unordered_set>
      30             : 
      31             : // libMesh
      32             : #include "libmesh/elem_range.h"
      33             : #include "libmesh/mesh_base.h"
      34             : #include "libmesh/replicated_mesh.h"
      35             : #include "libmesh/distributed_mesh.h"
      36             : #include "libmesh/node_range.h"
      37             : #include "libmesh/nanoflann.hpp"
      38             : #include "libmesh/vector_value.h"
      39             : #include "libmesh/point.h"
      40             : #include "libmesh/partitioner.h"
      41             : 
      42             : class Assembly;
      43             : class RelationshipManager;
      44             : class MooseVariableBase;
      45             : class MooseAppCoordTransform;
      46             : class MooseUnits;
      47             : 
      48             : // libMesh forward declarations
      49             : namespace libMesh
      50             : {
      51             : class ExodusII_IO;
      52             : class QBase;
      53             : class PeriodicBoundaries;
      54             : class Partitioner;
      55             : class GhostingFunctor;
      56             : class BoundingBox;
      57             : }
      58             : // Useful typedefs
      59             : typedef libMesh::StoredRange<std::set<Node *>::iterator, Node *> SemiLocalNodeRange;
      60             : 
      61             : // List of supported geometrical elements
      62             : const std::string LIST_GEOM_ELEM = "EDGE EDGE2 EDGE3 EDGE4 "
      63             :                                    "QUAD QUAD4 QUAD8 QUAD9 "
      64             :                                    "TRI TRI3 TRI6 TRI7 "
      65             :                                    "HEX HEX8 HEX20 HEX27 "
      66             :                                    "TET TET4 TET10 TET14 "
      67             :                                    "PRISM PRISM6 PRISM15 PRISM18 "
      68             :                                    "PYRAMID PYRAMID5 PYRAMID13 PYRAMID14 "
      69             :                                    "C0POLYGON C0POLYHEDRON";
      70             : 
      71             : /**
      72             :  * Helper object for holding qp mapping info.
      73             :  */
      74             : class QpMap
      75             : {
      76             : public:
      77       59216 :   QpMap() : _distance(std::numeric_limits<Real>::max()) {}
      78             : 
      79             :   /// The qp to map from
      80             :   unsigned int _from;
      81             : 
      82             :   /// The qp to map to
      83             :   unsigned int _to;
      84             : 
      85             :   /// The distance between them
      86             :   Real _distance;
      87             : };
      88             : 
      89             : /**
      90             :  * MooseMesh wraps a libMesh::Mesh object and enhances its capabilities
      91             :  * by caching additional data and storing more state.
      92             :  */
      93             : class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterface
      94             : {
      95             : public:
      96             :   /**
      97             :    * Typical "Moose-style" constructor and copy constructor.
      98             :    */
      99             :   static InputParameters validParams();
     100             : 
     101             :   /**
     102             :    * Default value for the automatically detected paired boundaries for
     103             :    * each unit dimension, in which the value for each unit dimension is
     104             :    * false (not detected).
     105             :    */
     106             :   static const std::array<bool, 3> periodic_dim_default;
     107             : 
     108             :   MooseMesh(const InputParameters & parameters);
     109             :   MooseMesh(const MooseMesh & other_mesh);
     110             :   MooseMesh() = delete;
     111             :   MooseMesh & operator=(const MooseMesh & other_mesh) = delete;
     112             : 
     113             :   virtual ~MooseMesh();
     114             : 
     115             :   // The type of libMesh::MeshBase that will be used
     116             :   enum class ParallelType
     117             :   {
     118             :     DEFAULT,
     119             :     REPLICATED,
     120             :     DISTRIBUTED
     121             :   };
     122             : 
     123             :   /**
     124             :    * Clone method.  Allocates memory you are responsible to clean up.
     125             :    */
     126             :   virtual MooseMesh & clone() const;
     127             : 
     128             :   /**
     129             :    * A safer version of the clone() method that hands back an
     130             :    * allocated object wrapped in a smart pointer. This makes it much
     131             :    * less likely that the caller will leak the memory in question.
     132             :    */
     133             :   virtual std::unique_ptr<MooseMesh> safeClone() const = 0;
     134             : 
     135             :   /**
     136             :    * Determine whether to use a distributed mesh. Should be called during construction
     137             :    */
     138             :   void determineUseDistributedMesh();
     139             : 
     140             :   /**
     141             :    * Method to construct a libMesh::MeshBase object that is normally set and used by the MooseMesh
     142             :    * object during the "init()" phase. If the parameter \p dim is not
     143             :    * provided, then its value will be taken from the input file mesh block.
     144             :    */
     145             :   std::unique_ptr<MeshBase> buildMeshBaseObject(unsigned int dim = libMesh::invalid_uint);
     146             : 
     147             :   /**
     148             :    * Shortcut method to construct a unique pointer to a libMesh mesh instance. The created
     149             :    * derived-from-MeshBase object will have its \p allow_remote_element_removal flag set to whatever
     150             :    * our value is. We will also attach any geometric \p RelationshipManagers that have been
     151             :    * requested by our simulation objects to the \p MeshBase object. If the parameter \p dim is not
     152             :    * provided, then its value will be taken from the input file mesh block.
     153             :    */
     154             :   template <typename T>
     155             :   std::unique_ptr<T> buildTypedMesh(unsigned int dim = libMesh::invalid_uint);
     156             : 
     157             :   /**
     158             :    * Method to set the mesh_base object. If this method is NOT called prior to calling init(), a
     159             :    * MeshBase object will be automatically constructed and set.
     160             :    */
     161             :   void setMeshBase(std::unique_ptr<MeshBase> mesh_base);
     162             : 
     163             :   /// returns MooseMesh partitioning options so other classes can use it
     164             :   static MooseEnum partitioning();
     165             : 
     166             :   /// returns MooseMesh element type options
     167             :   static MooseEnum elemTypes();
     168             : 
     169             :   /**
     170             :    * Initialize the Mesh object.  Most of the time this will turn around
     171             :    * and call build_mesh so the child class can build the Mesh object.
     172             :    *
     173             :    * However, during Recovery this will read the CPA file...
     174             :    */
     175             :   virtual void init();
     176             : 
     177             :   /**
     178             :    * Must be overridden by child classes.
     179             :    *
     180             :    * This is where the Mesh object is actually created and filled in.
     181             :    */
     182             :   virtual void buildMesh() = 0;
     183             : 
     184             :   /**
     185             :    * Returns MeshBase::mesh_dimension(), (not
     186             :    * MeshBase::spatial_dimension()!) of the underlying libMesh mesh
     187             :    * object.
     188             :    */
     189             :   virtual unsigned int dimension() const;
     190             : 
     191             :   /**
     192             :    * Returns MeshBase::spatial_dimension
     193             :    */
     194       53336 :   virtual unsigned int spatialDimension() const { return _mesh->spatial_dimension(); }
     195             : 
     196             :   /**
     197             :    * Returns the effective spatial dimension determined by the coordinates actually used by the
     198             :    * mesh. This means that a 1D mesh that has non-zero z or y coordinates is actually a 2D or 3D
     199             :    * mesh, respectively. Likewise a 2D mesh that has non-zero z coordinates is actually 3D mesh.
     200             :    */
     201             :   virtual unsigned int effectiveSpatialDimension() const;
     202             : 
     203             :   /**
     204             :    * Returns the maximum element dimension on the given blocks
     205             :    */
     206             :   unsigned int getBlocksMaxDimension(const std::vector<SubdomainName> & blocks) const;
     207             : 
     208             :   /**
     209             :    * Returns a vector of boundary IDs for the requested element on the
     210             :    * requested side.
     211             :    */
     212             :   std::vector<BoundaryID> getBoundaryIDs(const Elem * const elem,
     213             :                                          const unsigned short int side) const;
     214             : 
     215             :   /**
     216             :    * Returns a vector of vector of boundary IDs for the requested element on each of its sides
     217             :    */
     218             :   std::vector<std::vector<BoundaryID>> getBoundaryIDs(const Elem * const elem) const;
     219             : 
     220             :   /**
     221             :    * Returns a const pointer to a lower dimensional element that
     222             :    * corresponds to a side of a higher dimensional element. This
     223             :    * relationship is established through an internal_parent; if there is
     224             :    * no lowerDElem, nullptr is returned.
     225             :    */
     226             :   const Elem * getLowerDElem(const Elem *, unsigned short int) const;
     227             : 
     228             :   /**
     229             :    * Returns the local side ID of the interior parent aligned with the lower dimensional element.
     230             :    */
     231             :   unsigned int getHigherDSide(const Elem * elem) const;
     232             : 
     233             :   /**
     234             :    * Returns a const reference to a set of all user-specified
     235             :    * boundary IDs.  On a distributed mesh this will *only* include
     236             :    * boundary IDs which exist on local or ghosted elements; a copy and
     237             :    * a call to _communicator.set_union() will be necessary to get the
     238             :    * global ID set.
     239             :    */
     240             :   const std::set<BoundaryID> & getBoundaryIDs() const;
     241             : 
     242             :   /**
     243             :    * Calls BoundaryInfo::build_node_list()/build_side_list() and *makes separate copies* of
     244             :    * Nodes/Elems in those lists.
     245             :    *
     246             :    * Allocates memory which is cleaned up in the freeBndNodes()/freeBndElems() functions.
     247             :    */
     248             :   void buildNodeList();
     249             :   void buildBndElemList();
     250             : 
     251             :   /**
     252             :    * If not already created, creates a map from every node to all
     253             :    * elements to which they are connected.
     254             :    */
     255             :   const std::map<dof_id_type, std::vector<dof_id_type>> & nodeToElemMap();
     256             : 
     257             :   /**
     258             :    * If not already created, creates a map from every node to all
     259             :    * _active_ _semilocal_ elements to which they are connected.
     260             :    * Semilocal elements include local elements and elements that share at least
     261             :    * one node with a local element.
     262             :    * \note Extra ghosted elements are not included in this map!
     263             :    */
     264             :   const std::map<dof_id_type, std::vector<dof_id_type>> & nodeToActiveSemilocalElemMap();
     265             : 
     266             :   /**
     267             :    * These structs are required so that the bndNodes{Begin,End} and
     268             :    * bndElems{Begin,End} functions work...
     269             :    */
     270             :   struct bnd_node_iterator;
     271             :   struct const_bnd_node_iterator;
     272             : 
     273             :   struct bnd_elem_iterator;
     274             :   struct const_bnd_elem_iterator;
     275             : 
     276             :   /**
     277             :    * Return iterators to the beginning/end of the boundary nodes list.
     278             :    */
     279             :   virtual bnd_node_iterator bndNodesBegin();
     280             :   virtual bnd_node_iterator bndNodesEnd();
     281             : 
     282             :   /**
     283             :    * Return iterators to the beginning/end of the boundary elements list.
     284             :    */
     285             :   virtual bnd_elem_iterator bndElemsBegin();
     286             :   virtual bnd_elem_iterator bndElemsEnd();
     287             : 
     288             :   /**
     289             :    * Calls BoundaryInfo::build_node_list_from_side_list().
     290             :    */
     291             :   void buildNodeListFromSideList();
     292             : 
     293             :   /**
     294             :    * Calls BoundaryInfo::build_side_list(), returns a std::vector of
     295             :    * (elem-id, side-id, bc-id) tuples.
     296             :    */
     297             :   std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>> buildSideList();
     298             : 
     299             :   /**
     300             :    * Calls BoundaryInfo::build_active_side_list
     301             :    * @return A container of active (element, side, id) tuples.
     302             :    */
     303             :   std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
     304             :   buildActiveSideList() const;
     305             : 
     306             :   /**
     307             :    * Calls BoundaryInfo::side_with_boundary_id().
     308             :    */
     309             :   unsigned int sideWithBoundaryID(const Elem * const elem, const BoundaryID boundary_id) const;
     310             : 
     311             :   /**
     312             :    * Calls local_nodes_begin/end() on the underlying libMesh mesh object.
     313             :    */
     314             :   MeshBase::node_iterator localNodesBegin();
     315             :   MeshBase::node_iterator localNodesEnd();
     316             :   MeshBase::const_node_iterator localNodesBegin() const;
     317             :   MeshBase::const_node_iterator localNodesEnd() const;
     318             : 
     319             :   /**
     320             :    * Calls active_local_nodes_begin/end() on the underlying libMesh mesh object.
     321             :    */
     322             :   MeshBase::element_iterator activeLocalElementsBegin();
     323             :   const MeshBase::element_iterator activeLocalElementsEnd();
     324             :   MeshBase::const_element_iterator activeLocalElementsBegin() const;
     325             :   const MeshBase::const_element_iterator activeLocalElementsEnd() const;
     326             : 
     327             :   /**
     328             :    * Calls n_nodes/elem() on the underlying libMesh mesh object.
     329             :    */
     330             :   virtual dof_id_type nNodes() const;
     331             :   virtual dof_id_type nElem() const;
     332             : 
     333       27255 :   virtual dof_id_type nLocalNodes() const { return _mesh->n_local_nodes(); }
     334       53661 :   virtual dof_id_type nActiveElem() const { return _mesh->n_active_elem(); }
     335       38576 :   virtual dof_id_type nActiveLocalElem() const { return _mesh->n_active_local_elem(); }
     336             :   // NOTE: Expensive operation (iterates through all elements to gather subdomains)
     337       53370 :   virtual SubdomainID nSubdomains() const { return _mesh->n_subdomains(); }
     338       27081 :   virtual unsigned int nPartitions() const { return _mesh->n_partitions(); }
     339       27081 :   virtual bool skipPartitioning() const { return _mesh->skip_partitioning(); }
     340             :   virtual bool skipNoncriticalPartitioning() const;
     341             : 
     342             :   /**
     343             :    * Calls max_node/elem_id() on the underlying libMesh mesh object.
     344             :    * This may be larger than n_nodes/elem() in cases where the id
     345             :    * numbering is not contiguous.
     346             :    */
     347             :   virtual dof_id_type maxNodeId() const;
     348             :   virtual dof_id_type maxElemId() const;
     349             : 
     350             :   /**
     351             :    * Various accessors (pointers/references) for Node "i".
     352             :    *
     353             :    * If the requested node is a remote node on a distributed mesh,
     354             :    * only the query accessors are valid to call, and they return NULL.
     355             :    */
     356             :   virtual const Node & node(const dof_id_type i) const;
     357             :   virtual Node & node(const dof_id_type i);
     358             :   virtual const Node & nodeRef(const dof_id_type i) const;
     359             :   virtual Node & nodeRef(const dof_id_type i);
     360             :   virtual const Node * nodePtr(const dof_id_type i) const;
     361             :   virtual Node * nodePtr(const dof_id_type i);
     362             :   virtual const Node * queryNodePtr(const dof_id_type i) const;
     363             :   virtual Node * queryNodePtr(const dof_id_type i);
     364             : 
     365             :   /**
     366             :    * Various accessors (pointers/references) for Elem "i".
     367             :    *
     368             :    * If the requested elem is a remote element on a distributed mesh,
     369             :    * only the query accessors are valid to call, and they return NULL.
     370             :    */
     371             :   virtual Elem * elem(const dof_id_type i);
     372             :   virtual const Elem * elem(const dof_id_type i) const;
     373             :   virtual Elem * elemPtr(const dof_id_type i);
     374             :   virtual const Elem * elemPtr(const dof_id_type i) const;
     375             :   virtual Elem * queryElemPtr(const dof_id_type i);
     376             :   virtual const Elem * queryElemPtr(const dof_id_type i) const;
     377             : 
     378             :   /**
     379             :    * Setter/getter for whether the mesh is prepared
     380             :    */
     381             :   bool prepared() const;
     382             :   virtual void prepared(bool state);
     383             : 
     384             :   /**
     385             :    * If this method is called, we will call libMesh's prepare_for_use method when we
     386             :    * call Moose's prepare method. This should only be set when the mesh structure is changed
     387             :    * by MeshGenerators (i.e. Element deletion).
     388             :    */
     389             :   void needsPrepareForUse();
     390             : 
     391             :   /**
     392             :    * Declares that the MooseMesh has changed, invalidates cached data
     393             :    * and rebuilds caches.  Sets a flag so that clients of the
     394             :    * MooseMesh also know when it has changed.
     395             :    */
     396             :   void meshChanged();
     397             : 
     398             :   /**
     399             :    * Declares a callback function that is executed at the conclusion
     400             :    * of meshChanged(). Ther user can implement actions required after
     401             :    * changing the mesh here.
     402             :    **/
     403             :   virtual void onMeshChanged();
     404             : 
     405             :   /**
     406             :    * Cache information about what elements were refined and coarsened in the previous step.
     407             :    */
     408             :   void cacheChangedLists();
     409             : 
     410             :   /**
     411             :    * Return a range that is suitable for threaded execution over elements that were just refined.
     412             :    *
     413             :    * @return The _Parent_ elements that are now set to be INACTIVE.  Their _children_ are the new
     414             :    * elements.
     415             :    */
     416             :   ConstElemPointerRange * refinedElementRange() const;
     417             : 
     418             :   /**
     419             :    * Return a range that is suitable for threaded execution over elements that were just coarsened.
     420             :    * Note that these are the _Parent_ elements that are now set to be INACTIVE.  Their _children_
     421             :    * are the elements that were just removed.  Use coarsenedElementChildren() to get the element
     422             :    * IDs for the children that were just removed for a particular parent element.
     423             :    */
     424             :   ConstElemPointerRange * coarsenedElementRange() const;
     425             : 
     426             :   /**
     427             :    * Get the newly removed children element ids for an element that was just coarsened.
     428             :    *
     429             :    * @param elem Pointer to the parent element that was coarsened to.
     430             :    * @return The child element ids in Elem::child() order.
     431             :    */
     432             :   const std::vector<const Elem *> & coarsenedElementChildren(const Elem * elem) const;
     433             : 
     434             :   /**
     435             :    * Clears the "semi-local" node list and rebuilds it.  Semi-local nodes
     436             :    * consist of all nodes that belong to local and ghost elements.
     437             :    */
     438             :   void updateActiveSemiLocalNodeRange(std::set<dof_id_type> & ghosted_elems);
     439             : 
     440             :   /**
     441             :    * Returns true if the node is semi-local
     442             :    * @param node Node pointer
     443             :    * @return true is the node is semi-local, false otherwise
     444             :    */
     445             :   bool isSemiLocal(Node * const node) const;
     446             : 
     447             :   ///@{
     448             :   /**
     449             :    * Return pointers to range objects for various types of ranges
     450             :    * (local nodes, boundary elems, etc.).
     451             :    */
     452             :   libMesh::ConstElemRange * getActiveLocalElementRange();
     453             :   libMesh::NodeRange * getActiveNodeRange();
     454             :   SemiLocalNodeRange * getActiveSemiLocalNodeRange() const;
     455             :   libMesh::ConstNodeRange * getLocalNodeRange();
     456             :   libMesh::StoredRange<MooseMesh::const_bnd_node_iterator, const BndNode *> *
     457             :   getBoundaryNodeRange();
     458             :   libMesh::StoredRange<MooseMesh::const_bnd_elem_iterator, const BndElement *> *
     459             :   getBoundaryElementRange();
     460             :   ///@}
     461             : 
     462             :   /**
     463             :    * Returns a map of boundaries to ids of elements on the boundary.
     464             :    */
     465             :   const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
     466             :   getBoundariesToElems() const;
     467             : 
     468             :   /**
     469             :    * Returns a map of boundaries to ids of elements on the boundary.
     470             :    */
     471             :   const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
     472             :   getBoundariesToActiveSemiLocalElemIds() const;
     473             : 
     474             :   /**
     475             :    * Return all ids of elements which have a side which is part of a sideset.
     476             :    * Note that boundaries are sided.
     477             :    * @param bid the id of the sideset of interest
     478             :    */
     479             :   std::unordered_set<dof_id_type> getBoundaryActiveSemiLocalElemIds(BoundaryID bid) const;
     480             : 
     481             :   /**
     482             :    * Return all ids of neighbors of elements which have a side which is part of a sideset.
     483             :    * Note that boundaries are sided, this is on the neighbor side. For the sideset side, use
     484             :    * getBoundariesActiveLocalElemIds.
     485             :    * Note that while the element is local and active, the neighbor is not guaranteed to be local,
     486             :    * it could be ghosted.
     487             :    * Note that if the neighbor is not ghosted, is a remote_elem, then it will not be included
     488             :    * @param bid the id of the sideset of interest
     489             :    */
     490             :   std::unordered_set<dof_id_type> getBoundaryActiveNeighborElemIds(BoundaryID bid) const;
     491             : 
     492             :   /**
     493             :    * Returns whether a boundary (given by its id) is not crossing through a group of blocks,
     494             :    * by which we mean that elements on both sides of the boundary are in those blocks
     495             :    * @param bid the id of the boundary of interest
     496             :    * @param blk_group the group of blocks potentially traversed
     497             :    * @return whether the boundary does not cross between the subdomains in the group
     498             :    */
     499             :   bool isBoundaryFullyExternalToSubdomains(BoundaryID bid,
     500             :                                            const std::set<SubdomainID> & blk_group) const;
     501             : 
     502             :   /**
     503             :    * Returns a read-only reference to the set of subdomains currently
     504             :    * present in the Mesh.
     505             :    */
     506             :   const std::set<SubdomainID> & meshSubdomains() const;
     507             : 
     508             :   /**
     509             :    * Returns a read-only reference to the set of boundary IDs currently
     510             :    * present in the Mesh.
     511             :    */
     512             :   const std::set<BoundaryID> & meshBoundaryIds() const;
     513             : 
     514             :   /**
     515             :    * Returns a read-only reference to the set of sidesets currently
     516             :    * present in the Mesh.
     517             :    */
     518             :   const std::set<BoundaryID> & meshSidesetIds() const;
     519             : 
     520             :   /**
     521             :    * Returns a read-only reference to the set of nodesets currently
     522             :    * present in the Mesh.
     523             :    */
     524             :   const std::set<BoundaryID> & meshNodesetIds() const;
     525             : 
     526             :   /**
     527             :    * Sets the mapping between BoundaryID and normal vector
     528             :    * Is called by AddAllSideSetsByNormals
     529             :    */
     530             :   void setBoundaryToNormalMap(std::unique_ptr<std::map<BoundaryID, RealVectorValue>> boundary_map);
     531             : 
     532             :   // DEPRECATED METHOD
     533             :   void setBoundaryToNormalMap(std::map<BoundaryID, RealVectorValue> * boundary_map);
     534             : 
     535             :   /**
     536             :    * Sets the set of BoundaryIDs
     537             :    * Is called by AddAllSideSetsByNormals
     538             :    */
     539             :   void setMeshBoundaryIDs(std::set<BoundaryID> boundary_IDs);
     540             : 
     541             :   /**
     542             :    * Returns the normal vector associated with a given BoundaryID.
     543             :    * It's only valid to call this when AddAllSideSetsByNormals is active.
     544             :    */
     545             :   const RealVectorValue & getNormalByBoundaryID(BoundaryID id) const;
     546             : 
     547             :   /**
     548             :    * Calls prepare_for_use() if the underlying MeshBase object isn't prepared, then communicates
     549             :    * various boundary information on parallel meshes. Also calls update() internally. Instead of
     550             :    * calling \p prepare_for_use on the currently held \p MeshBase object, a \p mesh_to_clone can be
     551             :    * provided. If it is provided (e.g. this method is given a non-null argument), then \p _mesh will
     552             :    * be assigned a clone of the \p mesh_to_clone. The provided \p mesh_to_clone must already be
     553             :    * prepared
     554             :    * @param mesh_to_clone If nonnull, we will clone this mesh instead of preparing our current one
     555             :    * @return Whether the libMesh mesh was prepared. This should really only be relevant in MOOSE
     556             :    * framework contexts where we need to make a decision about what to do with the displaced mesh.
     557             :    * If the reference mesh base object has \p prepare_for_use called (e.g. this method returns \p
     558             :    * true when called for the reference mesh), then we must pass the reference mesh base object into
     559             :    * this method when we call this for the displaced mesh. This is because the displaced mesh \emph
     560             :    * must be an exact clone of the reference mesh. We have seen that \p prepare_for_use called on
     561             :    * two previously identical meshes can result in two different meshes even with Metis partitioning
     562             :    */
     563             :   bool prepare(const MeshBase * mesh_to_clone);
     564             : 
     565             :   /**
     566             :    * Calls buildNodeListFromSideList(), buildNodeList(), and buildBndElemList().
     567             :    */
     568             :   void update();
     569             : 
     570             :   /**
     571             :    * Returns the level of uniform refinement requested (zero if AMR is disabled).
     572             :    */
     573             :   unsigned int uniformRefineLevel() const;
     574             : 
     575             :   /**
     576             :    * Set uniform refinement level
     577             :    */
     578             :   void setUniformRefineLevel(unsigned int, bool deletion = true);
     579             : 
     580             :   /**
     581             :    * Return a flag indicating whether or not we should skip remote deletion
     582             :    * and repartition after uniform refinements. If the flag is true, uniform
     583             :    * refinements will run more efficiently, but at the same time, there might
     584             :    * be extra ghosting elements. The number of layers of additional ghosting
     585             :    * elements depends on the number of uniform refinement levels.  This flag
     586             :    * should be used only when you have a "fine enough" coarse mesh and want
     587             :    * to refine the mesh by a few levels. Otherwise, it might introduce an
     588             :    * unbalanced workload and too large ghosting domain.
     589             :    */
     590             :   bool skipDeletionRepartitionAfterRefine() const;
     591             : 
     592             :   /**
     593             :    * Whether or not skip uniform refinements when using a pre-split mesh
     594             :    */
     595         255 :   bool skipRefineWhenUseSplit() const { return _skip_refine_when_use_split; }
     596             : 
     597             :   /**
     598             :    * This will add the boundary ids to be ghosted to this processor
     599             :    */
     600             :   void addGhostedBoundary(BoundaryID boundary_id);
     601             : 
     602             :   /**
     603             :    * This sets the inflation amount for the bounding box for each partition for use in
     604             :    * ghosting boundaries
     605             :    */
     606             :   void setGhostedBoundaryInflation(const std::vector<Real> & inflation);
     607             : 
     608             :   /**
     609             :    * Return a writable reference to the set of ghosted boundary IDs.
     610             :    */
     611             :   const std::set<unsigned int> & getGhostedBoundaries() const;
     612             : 
     613             :   /**
     614             :    * Return a writable reference to the _ghosted_boundaries_inflation vector.
     615             :    */
     616             :   const std::vector<Real> & getGhostedBoundaryInflation() const;
     617             : 
     618             :   /**
     619             :    * Actually do the ghosting of boundaries that need to be ghosted to this processor.
     620             :    */
     621             :   void ghostGhostedBoundaries();
     622             : 
     623             :   /**
     624             :    * Whether or not we want to ghost ghosted boundaries
     625             :    */
     626         779 :   void needGhostGhostedBoundaries(bool needghost) { _need_ghost_ghosted_boundaries = needghost; }
     627             : 
     628             :   /**
     629             :    * Getter for the patch_size parameter.
     630             :    */
     631             :   unsigned int getPatchSize() const;
     632             : 
     633             :   /**
     634             :    * Getter for the ghosting_patch_size parameter.
     635             :    */
     636        8658 :   unsigned int getGhostingPatchSize() const { return _ghosting_patch_size; }
     637             : 
     638             :   /**
     639             :    * Getter for the maximum leaf size parameter.
     640             :    */
     641       64048 :   unsigned int getMaxLeafSize() const { return _max_leaf_size; }
     642             : 
     643             :   /**
     644             :    * Set the patch size update strategy
     645             :    */
     646             :   void setPatchUpdateStrategy(Moose::PatchUpdateType patch_update_strategy);
     647             : 
     648             :   /**
     649             :    * Get the current patch update strategy.
     650             :    */
     651             :   const Moose::PatchUpdateType & getPatchUpdateStrategy() const;
     652             : 
     653             :   /**
     654             :    * Get a (slightly inflated) processor bounding box.
     655             :    *
     656             :    * @param inflation_multiplier This amount will be multiplied by the length of the diagonal of the
     657             :    * bounding box to find the amount to inflate the bounding box by in all directions.
     658             :    */
     659             :   libMesh::BoundingBox getInflatedProcessorBoundingBox(Real inflation_multiplier = 0.01) const;
     660             : 
     661             :   /**
     662             :    * Implicit conversion operator from MooseMesh -> libMesh::MeshBase.
     663             :    */
     664             :   operator libMesh::MeshBase &();
     665             :   operator const libMesh::MeshBase &() const;
     666             : 
     667             :   /**
     668             :    * Accessor for the underlying libMesh Mesh object.
     669             :    */
     670             :   MeshBase & getMesh();
     671             :   MeshBase & getMesh(const std::string & name);
     672             :   const MeshBase & getMesh() const;
     673             :   const MeshBase & getMesh(const std::string & name) const;
     674             :   const MeshBase * getMeshPtr() const;
     675             : 
     676             :   /**
     677             :    * Accessor for Kokkos mesh object.
     678             :    */
     679             : #ifdef MOOSE_KOKKOS_ENABLED
     680       82717 :   Moose::Kokkos::Mesh * getKokkosMesh() { return _kokkos_mesh.get(); }
     681        5102 :   const Moose::Kokkos::Mesh * getKokkosMesh() const { return _kokkos_mesh.get(); }
     682             : #endif
     683             : 
     684             :   /**
     685             :    * Calls print_info() on the underlying Mesh.
     686             :    */
     687             :   void printInfo(std::ostream & os = libMesh::out, const unsigned int verbosity = 0) const;
     688             : 
     689             :   /**
     690             :    * Return list of blocks to which the given node belongs.
     691             :    */
     692             :   const std::set<SubdomainID> & getNodeBlockIds(const Node & node) const;
     693             : 
     694             :   /**
     695             :    * Return a writable reference to a vector of node IDs that belong
     696             :    * to nodeset_id.
     697             :    */
     698             :   const std::vector<dof_id_type> & getNodeList(boundary_id_type nodeset_id) const;
     699             : 
     700             :   /**
     701             :    * Add a new node to the mesh.  If there is already a node located at the point passed
     702             :    * then the node will not be added.  In either case a reference to the node at that location
     703             :    * will be returned
     704             :    */
     705             :   const Node * addUniqueNode(const Point & p, Real tol = 1e-6);
     706             : 
     707             :   /**
     708             :    * Adds a fictitious "QuadratureNode".  This doesn't actually add it to the libMesh mesh...
     709             :    * we just keep track of these here in MooseMesh.
     710             :    *
     711             :    * QuadratureNodes are fictitious "Nodes" that are located at quadrature points.  This is useful
     712             :    * for using the geometric search system to do searches based on quadrature point locations....
     713             :    *
     714             :    * @param elem The element
     715             :    * @param side The side number on which we want to add a quadrature node
     716             :    * @param qp The number of the quadrature point
     717             :    * @param bid The boundary ID for the point to be added with
     718             :    * @param point The physical location of the point
     719             :    */
     720             :   Node * addQuadratureNode(const Elem * elem,
     721             :                            const unsigned short int side,
     722             :                            const unsigned int qp,
     723             :                            BoundaryID bid,
     724             :                            const Point & point);
     725             : 
     726             :   /**
     727             :    * Get a specified quadrature node.
     728             :    *
     729             :    * @param elem The element the quadrature point is on
     730             :    * @param side The side the quadrature point is on
     731             :    * @param qp The quadrature point number associated with the point
     732             :    */
     733             :   Node * getQuadratureNode(const Elem * elem, const unsigned short int side, const unsigned int qp);
     734             : 
     735             :   /**
     736             :    * Clear out any existing quadrature nodes.
     737             :    * Most likely called before re-adding them.
     738             :    */
     739             :   void clearQuadratureNodes();
     740             : 
     741             :   /**
     742             :    * Get the associated BoundaryID for the boundary name.
     743             :    *
     744             :    * @param boundary_name The name of the boundary.
     745             :    * @return the boundary id from the passed boundary name.
     746             :    */
     747             :   BoundaryID getBoundaryID(const BoundaryName & boundary_name) const;
     748             : 
     749             :   /**
     750             :    * Get the associated BoundaryID for the boundary names that are passed in.
     751             :    *
     752             :    * @param boundary_name The names of the boundaries.
     753             :    * @return the boundary ids from the passed boundary names.
     754             :    */
     755             :   std::vector<BoundaryID> getBoundaryIDs(const std::vector<BoundaryName> & boundary_name,
     756             :                                          bool generate_unknown = false) const;
     757             : 
     758             :   /**
     759             :    * Get the associated subdomain ID for the subdomain name.
     760             :    *
     761             :    * @param subdomain_name The name of the subdomain
     762             :    * @return The subdomain id from the passed subdomain name.
     763             :    */
     764             :   SubdomainID getSubdomainID(const SubdomainName & subdomain_name) const;
     765             : 
     766             :   /**
     767             :    * Get the associated subdomainIDs for the subdomain names that are passed in.
     768             :    *
     769             :    * @param subdomain_names The names of the subdomains
     770             :    * @return The subdomain ids from the passed subdomain names.
     771             :    */
     772             :   std::vector<SubdomainID>
     773             :   getSubdomainIDs(const std::vector<SubdomainName> & subdomain_names) const;
     774             :   std::set<SubdomainID> getSubdomainIDs(const std::set<SubdomainName> & subdomain_names) const;
     775             : 
     776             :   /**
     777             :    * This method sets the name for \p subdomain_id to \p name
     778             :    */
     779             :   void setSubdomainName(SubdomainID subdomain_id, const SubdomainName & name);
     780             : 
     781             :   /**
     782             :    * This method sets the name for \p subdomain_id on the provided \p mesh to \p name
     783             :    */
     784             :   static void
     785             :   setSubdomainName(MeshBase & mesh, SubdomainID subdomain_id, const SubdomainName & name);
     786             : 
     787             :   /**
     788             :    * Return the name of a block given an id.
     789             :    */
     790             :   const std::string & getSubdomainName(SubdomainID subdomain_id) const;
     791             : 
     792             :   /**
     793             :    * Get the associated subdomainNames for the subdomain ids that are passed in.
     794             :    *
     795             :    * @param subdomain_ids The ids of the subdomains
     796             :    * @return The subdomain names from the passed subdomain ids.
     797             :    */
     798             :   std::vector<SubdomainName>
     799             :   getSubdomainNames(const std::vector<SubdomainID> & subdomain_ids) const;
     800             : 
     801             :   /**
     802             :    * This method sets the boundary name of the boundary based on the id parameter
     803             :    */
     804             :   void setBoundaryName(BoundaryID boundary_id, BoundaryName name);
     805             : 
     806             :   /**
     807             :    * Return the name of the boundary given the id.
     808             :    */
     809             :   const std::string & getBoundaryName(const BoundaryID boundary_id) const;
     810             : 
     811             :   /**
     812             :    * Return the name of the boundary given the id, if it exists. Otherwise, return
     813             :    * the id as a string.
     814             :    */
     815             :   std::string getBoundaryString(const BoundaryID boundary_id) const;
     816             : 
     817             :   /**
     818             :    * This routine builds a multimap of boundary ids to matching boundary ids across all periodic
     819             :    * boundaries
     820             :    * in the system.
     821             :    */
     822             :   void buildPeriodicNodeMap(std::multimap<dof_id_type, dof_id_type> & periodic_node_map,
     823             :                             unsigned int var_number,
     824             :                             libMesh::PeriodicBoundaries * pbs) const;
     825             : 
     826             :   /**
     827             :    * This routine builds a datastructure of node ids organized by periodic boundary ids
     828             :    */
     829             :   void buildPeriodicNodeSets(std::map<BoundaryID, std::set<dof_id_type>> & periodic_node_sets,
     830             :                              unsigned int var_number,
     831             :                              libMesh::PeriodicBoundaries * pbs) const;
     832             : 
     833             :   /**
     834             :    * Returns the width of the requested dimension
     835             :    */
     836             :   Real dimensionWidth(unsigned int component) const;
     837             : 
     838             :   ///@{
     839             :   /**
     840             :    * Returns the min or max of the requested dimension respectively
     841             :    */
     842             :   virtual Real getMinInDimension(unsigned int component) const;
     843             :   virtual Real getMaxInDimension(unsigned int component) const;
     844             :   ///@}
     845             : 
     846             :   /**
     847             :    * This routine determines whether the Mesh is a regular orthogonal mesh (i.e. square in 2D, cubic
     848             :    * in 3D). If it is, then we can use a number of convenience functions when periodic boundary
     849             :    * conditions are applied.  This routine populates the _range vector which is necessary for these
     850             :    * convenience functions.
     851             :    *
     852             :    * Note:  This routine can potentially identify meshes with concave faces that still "fit" in the
     853             :    * convex hull of the corresponding regular orthogonal mesh.  This case is highly unlikely in
     854             :    * practice and if a user does this, well.... release the kicker!
     855             :    */
     856             :   bool detectOrthogonalDimRanges(Real tol = 1e-6);
     857             : 
     858             :   /**
     859             :    * For "regular orthogonal" meshes, determine if variable var_num is periodic with respect to the
     860             :    * primary and secondary BoundaryIDs, record this fact in the _periodic_dim data structure.
     861             :    */
     862             :   void addPeriodicVariable(const unsigned int sys_num,
     863             :                            const unsigned int var_num,
     864             :                            const BoundaryID primary,
     865             :                            const BoundaryID secondary);
     866             : 
     867             :   /**
     868             :    * Query the translated periodic dimension flags for the given variable on the given system.
     869             :    *
     870             :    * Query here means that it will not error if a variable isn't found to be periodic, instead
     871             :    * the default value is returned (false for each dimension)
     872             :    *
     873             :    * @param sys_num - The number of the system the variable is on
     874             :    * @param var_num - The variable number
     875             :    */
     876             :   const std::array<bool, 3> & queryPeriodicDimensions(const unsigned int sys_num,
     877             :                                                       const unsigned int var_num) const;
     878             :   /**
     879             :    * Query the translated periodic dimension flags for the given variable.\
     880             :    *
     881             :    * Query here means that it will not error if a variable isn't found to be periodic, instead
     882             :    * the default value is returned (false for each dimension)
     883             :    *
     884             :    * @param var - The variable
     885             :    */
     886             :   const std::array<bool, 3> & queryPeriodicDimensions(const MooseVariableBase & var) const;
     887             : 
     888             :   /**
     889             :    * Returns whether this generated mesh is periodic in the given dimension for the given variable
     890             :    * on the given system.
     891             :    * @param sys_num - The number of the system the variable is on
     892             :    * @param var_num - The variable number
     893             :    * @param component - An integer representing the desired component (dimension)
     894             :    */
     895             :   bool isTranslatedPeriodic(const unsigned int sys_num,
     896             :                             const unsigned int var_num,
     897             :                             const unsigned int component) const;
     898             : 
     899             :   /**
     900             :    * Returns whether this generated mesh is periodic in the given dimension for the given variable.
     901             :    * @param var - The variable
     902             :    * @param component - An integer representing the desired component (dimension)
     903             :    */
     904             :   bool isTranslatedPeriodic(const MooseVariableBase & var, const unsigned int component) const;
     905             : 
     906             :   /**
     907             :    * Returns whether this generated mesh is periodic in the given dimension for the given variable.
     908             :    *
     909             :    * Deprecated method; assumes the system number is 0. Use the method that
     910             :    * additionally takes the system number or the MooseVariableBase instead.
     911             :    *
     912             :    * @param var_num - The variable number
     913             :    * @param component - An integer representing the desired component (dimension)
     914             :    */
     915             :   bool isTranslatedPeriodic(const unsigned int var_num, const unsigned int component) const;
     916             : 
     917             :   /**
     918             :    * Returns the minimum vector between two points on the mesh taking into account
     919             :    * periodicity for the given variable on the given system.
     920             :    * @param sys_num - The number of the system the variable is on
     921             :    * @param var_num - The variable number
     922             :    * @param p, q - The points between which to compute a minimum vector
     923             :    * @return RealVectorValue - The vector pointing from p to q
     924             :    */
     925             :   RealVectorValue
     926             :   minPeriodicVector(const unsigned int sys_num, const unsigned int var_num, Point p, Point q) const;
     927             : 
     928             :   /**
     929             :    * Returns the minimum vector between two points on the mesh taking into account
     930             :    * periodicity for the given variable.
     931             :    * @param var - The variable
     932             :    * @param p, q - The points between which to compute a minimum vector
     933             :    * @return RealVectorValue - The vector pointing from p to q
     934             :    */
     935             :   RealVectorValue
     936             :   minPeriodicVector(const MooseVariableBase & var, const Point & p, const Point & q) const;
     937             : 
     938             :   /**
     939             :    * Returns the minimum vector between two points on the mesh taking into account
     940             :    * periodicity for the given variable on the given system.
     941             :    *
     942             :    * Deprecated method; assumes the system number is 0. Use the method that
     943             :    * additionally takes the system number or the MooseVariableBase instead.
     944             :    *
     945             :    * @param var_num - The variable number
     946             :    * @param p, q - The points between which to compute a minimum vector
     947             :    * @return RealVectorValue - The vector pointing from p to q
     948             :    */
     949             :   RealVectorValue
     950             :   minPeriodicVector(const unsigned int var_num, const Point & p, const Point & q) const;
     951             : 
     952             :   /**
     953             :    * Returns the distance between two points on the mesh taking into account
     954             :    * periodicity for the given variable on the given system.
     955             :    * @param sys_num - The number of the system the variable is on
     956             :    * @param var_num - The variable number
     957             :    * @param p, q - The points for which to compute a minimum distance
     958             :    * @return Real - The L2 distance between p and q
     959             :    */
     960             :   Real minPeriodicDistance(const unsigned int sys_num,
     961             :                            const unsigned int var_num,
     962             :                            const Point & p,
     963             :                            const Point & q) const;
     964             : 
     965             :   /**
     966             :    * Returns the distance between two points on the mesh taking into account
     967             :    * periodicity for the given variable.
     968             :    * @param var - The variable
     969             :    * @param p, q - The points for which to compute a minimum distance
     970             :    * @return Real - The L2 distance between p and q
     971             :    */
     972             :   Real minPeriodicDistance(const MooseVariableBase & var, const Point & p, const Point & q) const;
     973             : 
     974             :   /**
     975             :    * Returns the distance between two points on the mesh taking into account
     976             :    * periodicity for the given variable.
     977             :    *
     978             :    * Deprecated method; assumes the system number is 0. Use the method that
     979             :    * additionally takes the system number or the MooseVariableBase instead.
     980             :    *
     981             :    * @param var_num - The variable number
     982             :    * @param p, q - The points for which to compute a minimum distance
     983             :    * @return Real - The L2 distance between p and q
     984             :    */
     985             :   Real minPeriodicDistance(const unsigned int var_num, const Point & p, const Point & q) const;
     986             : 
     987             :   /**
     988             :    * This routine detects paired sidesets of a regular orthogonal mesh (.i.e. parallel sidesets
     989             :    * "across" from one and other).
     990             :    *
     991             :    * The _paired_boundary datastructure is populated with this information.
     992             :    */
     993             :   void detectPairedSidesets();
     994             : 
     995             :   /**
     996             :    * Whether or not detectedPairedSidesets() has been called.
     997             :    */
     998        3045 :   bool hasDetectedPairedSidesets() const { return _paired_boundary.has_value(); }
     999             : 
    1000             :   /**
    1001             :    * This function attempts to return the paired boundary ids for the given component.  For example,
    1002             :    * in a generated 2D mesh, passing 0 for the "x" component will return (3, 1).
    1003             :    *
    1004             :    * Must have called detectPairedSidesets() prior to using.
    1005             :    *
    1006             :    * @param component - An integer representing the desired component (dimension)
    1007             :    * @return std::pair pointer - The matching boundary pairs for the passed component
    1008             :    */
    1009             :   const std::pair<BoundaryID, BoundaryID> * getPairedBoundaryMapping(unsigned int component) const;
    1010             : 
    1011             :   /**
    1012             :    * Create the refinement and coarsening maps necessary for projection of stateful material
    1013             :    * properties when using adaptivity.
    1014             :    *
    1015             :    * @param assembly Pointer to the Assembly object for this Mesh.
    1016             :    */
    1017             :   void buildRefinementAndCoarseningMaps(Assembly * assembly);
    1018             : 
    1019             :   /**
    1020             :    * Get the refinement map for a given element type.  This will tell you what quadrature points
    1021             :    * to copy from and to for stateful material properties on newly created elements from Adaptivity.
    1022             :    *
    1023             :    * @param elem The element that represents the element type you need the refinement map for.
    1024             :    * @param parent_side The side of the parent to map (-1 if not mapping parent sides)
    1025             :    * @param child The child number (-1 if not mapping child internal sides)
    1026             :    * @param child_side The side number of the child (-1 if not mapping sides)
    1027             :    */
    1028             :   const std::vector<std::vector<QpMap>> &
    1029             :   getRefinementMap(const Elem & elem, int parent_side, int child, int child_side);
    1030             : 
    1031             :   /**
    1032             :    * Get the coarsening map for a given element type.  This will tell you what quadrature points
    1033             :    * to copy from and to for stateful material properties on newly created elements from Adaptivity.
    1034             :    *
    1035             :    * @param elem The element that represents the element type you need the coarsening map for.
    1036             :    * @param input_side The side to map
    1037             :    */
    1038             :   const std::vector<std::pair<unsigned int, QpMap>> & getCoarseningMap(const Elem & elem,
    1039             :                                                                        int input_side);
    1040             : 
    1041             :   /**
    1042             :    * Change all the boundary IDs for a given side from old_id to new_id.  If delete_prev is true,
    1043             :    * also actually remove the side with old_id from the BoundaryInfo object.
    1044             :    */
    1045             :   void
    1046             :   changeBoundaryId(const boundary_id_type old_id, const boundary_id_type new_id, bool delete_prev);
    1047             : 
    1048             :   /**
    1049             :    * Change all the boundary IDs for a given side from old_id to new_id for the given \p mesh.  If
    1050             :    * delete_prev is true, also actually remove the side with old_id from the BoundaryInfo object.
    1051             :    */
    1052             :   static void changeBoundaryId(MeshBase & mesh,
    1053             :                                const boundary_id_type old_id,
    1054             :                                const boundary_id_type new_id,
    1055             :                                bool delete_prev);
    1056             : 
    1057             :   /**
    1058             :    * Get the list of boundary ids associated with the given subdomain id.
    1059             :    *
    1060             :    * @param subdomain_id The subdomain ID you want to get the boundary ids for.
    1061             :    * @return All boundary IDs connected to elements in the give
    1062             :    */
    1063             :   const std::set<BoundaryID> & getSubdomainBoundaryIds(const SubdomainID subdomain_id) const;
    1064             : 
    1065             :   /**
    1066             :    * Get the list of boundaries that contact the given subdomain.
    1067             :    *
    1068             :    * @param subdomain_id The subdomain ID you want to get the boundary ids for.
    1069             :    * @return All boundary IDs connected to elements in the given subdomain
    1070             :    */
    1071             :   std::set<BoundaryID> getSubdomainInterfaceBoundaryIds(const SubdomainID subdomain_id) const;
    1072             : 
    1073             :   /**
    1074             :    * Get the list of subdomains associated with the given boundary.
    1075             :    *
    1076             :    * @param bid The boundary ID you want to get the subdomain IDs for.
    1077             :    * @return All subdomain IDs associated with given boundary ID
    1078             :    */
    1079             :   std::set<SubdomainID> getBoundaryConnectedBlocks(const BoundaryID bid) const;
    1080             : 
    1081             :   /**
    1082             :    * Get the list of subdomains associated with the given boundary of its secondary side.
    1083             :    *
    1084             :    * @param bid The boundary ID you want to get the subdomain IDs for.
    1085             :    * @return All subdomain IDs associated with given boundary ID
    1086             :    */
    1087             :   std::set<SubdomainID> getBoundaryConnectedSecondaryBlocks(const BoundaryID bid) const;
    1088             : 
    1089             :   /**
    1090             :    * Get the list of subdomains contacting the given boundary.
    1091             :    *
    1092             :    * @param bid The boundary ID you want to get the subdomain IDs for.
    1093             :    * @return All subdomain IDs contacting given boundary ID
    1094             :    */
    1095             :   std::set<SubdomainID> getInterfaceConnectedBlocks(const BoundaryID bid) const;
    1096             : 
    1097             :   /**
    1098             :    * Get the list of subdomains neighboring a given subdomain.
    1099             :    *
    1100             :    * @param subdomain_id The boundary ID you want to get the subdomain IDs for.
    1101             :    * @return All subdomain IDs neighboring a given subdomain
    1102             :    */
    1103             :   const std::set<SubdomainID> & getBlockConnectedBlocks(const SubdomainID subdomain_id) const;
    1104             : 
    1105             :   /**
    1106             :    * Returns true if the requested node is in the list of boundary nodes, false otherwise.
    1107             :    */
    1108             :   bool isBoundaryNode(dof_id_type node_id) const;
    1109             : 
    1110             :   /**
    1111             :    * Returns true if the requested node is in the list of boundary nodes for the specified boundary,
    1112             :    * false otherwise.
    1113             :    */
    1114             :   bool isBoundaryNode(dof_id_type node_id, BoundaryID bnd_id) const;
    1115             : 
    1116             :   /**
    1117             :    * Returns true if the requested element is in the list of boundary elements, false otherwise.
    1118             :    */
    1119             :   bool isBoundaryElem(dof_id_type elem_id) const;
    1120             : 
    1121             :   /**
    1122             :    * Returns true if the requested element is in the list of boundary elements for the specified
    1123             :    * boundary, false otherwise.
    1124             :    */
    1125             :   bool isBoundaryElem(dof_id_type elem_id, BoundaryID bnd_id) const;
    1126             : 
    1127             :   /**
    1128             :    * Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.  Clients
    1129             :    * of MooseMesh can use this function to throw an error if they know they don't work with
    1130             :    * DistributedMesh.
    1131             :    *
    1132             :    * See, for example, the NodalVariableValue class.
    1133             :    */
    1134             :   void errorIfDistributedMesh(std::string name) const;
    1135             : 
    1136             :   /**
    1137             :    * Returns the final Mesh distribution type.
    1138             :    */
    1139       64358 :   virtual bool isDistributedMesh() const { return _use_distributed_mesh; }
    1140             : 
    1141             :   /**
    1142             :    * Tell the user if the distribution was overriden for any reason
    1143             :    */
    1144       53336 :   bool isParallelTypeForced() const { return _parallel_type_overridden; }
    1145             : 
    1146             :   /**
    1147             :    *  Allow to change parallel type
    1148             :    */
    1149             :   void setParallelType(ParallelType parallel_type);
    1150             : 
    1151             :   /**
    1152             :    * @return The parallel type
    1153             :    */
    1154        1114 :   ParallelType getParallelType() const { return _parallel_type; }
    1155             : 
    1156             :   /*
    1157             :    * Set/Get the partitioner name
    1158             :    */
    1159       27081 :   const MooseEnum & partitionerName() const { return _partitioner_name; }
    1160             : 
    1161             :   /**
    1162             :    * Tell the user if the partitioner was overriden for any reason
    1163             :    */
    1164       27081 :   bool isPartitionerForced() const { return _partitioner_overridden; }
    1165             : 
    1166             :   /**
    1167             :    * Set whether or not this mesh is allowed to read a recovery file.
    1168             :    */
    1169          10 :   void allowRecovery(bool allow) { _allow_recovery = allow; }
    1170             : 
    1171             :   /**
    1172             :    * Method for setting the partitioner on the passed in mesh_base object.
    1173             :    */
    1174             :   static void setPartitioner(MeshBase & mesh_base,
    1175             :                              MooseEnum & partitioner,
    1176             :                              bool use_distributed_mesh,
    1177             :                              const InputParameters & params,
    1178             :                              MooseObject & context_obj);
    1179             : 
    1180             :   /**
    1181             :    * Setter for custom partitioner
    1182             :    */
    1183             :   void setCustomPartitioner(libMesh::Partitioner * partitioner);
    1184             : 
    1185             :   ///@{
    1186             :   /**
    1187             :    * Setter and getter for _custom_partitioner_requested
    1188             :    */
    1189             :   bool isCustomPartitionerRequested() const;
    1190             :   void setIsCustomPartitionerRequested(bool cpr);
    1191             :   ///@}
    1192             : 
    1193             :   /// Getter to query if the mesh was detected to be regular and orthogonal
    1194        1594 :   bool isRegularOrthogonal() { return _regular_orthogonal_mesh; }
    1195             : 
    1196             :   /// check if the mesh has SECOND order elements
    1197             :   bool hasSecondOrderElements();
    1198             : 
    1199             :   /**
    1200             :    * Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default), or
    1201             :    * to allow derived meshes to return a custom point locator.
    1202             :    */
    1203             :   virtual std::unique_ptr<libMesh::PointLocatorBase> getPointLocator() const;
    1204             : 
    1205             :   /**
    1206             :    * Returns the name of the mesh file read to produce this mesh if any or an empty string
    1207             :    * otherwise.
    1208             :    */
    1209         462 :   virtual std::string getFileName() const { return ""; }
    1210             : 
    1211             :   /// Helper type for building periodic node maps
    1212             :   using PeriodicNodeInfo = std::pair<const Node *, BoundaryID>;
    1213             : 
    1214             :   /**
    1215             :    * Set whether we need to delete remote elements
    1216             :    */
    1217          24 :   void needsRemoteElemDeletion(bool need_delete) { _need_delete = need_delete; }
    1218             : 
    1219             :   /**
    1220             :    * Whether we need to delete remote elements
    1221             :    */
    1222       63937 :   bool needsRemoteElemDeletion() const { return _need_delete; }
    1223             : 
    1224             :   /**
    1225             :    * Set whether to allow remote element removal
    1226             :    */
    1227             :   void allowRemoteElementRemoval(bool allow_removal);
    1228             : 
    1229             :   /**
    1230             :    * Whether we are allow remote element removal
    1231             :    */
    1232       27621 :   bool allowRemoteElementRemoval() const { return _allow_remote_element_removal; }
    1233             : 
    1234             :   /**
    1235             :    * Delete remote elements
    1236             :    */
    1237             :   void deleteRemoteElements();
    1238             : 
    1239             :   /**
    1240             :    * Whether mesh base object was constructed or not
    1241             :    */
    1242       87876 :   bool hasMeshBase() const { return _mesh.get() != nullptr; }
    1243             : 
    1244             :   /**
    1245             :    * Whether mesh has an extra element integer with a given name
    1246             :    */
    1247             :   bool hasElementID(const std::string & id_name) const;
    1248             : 
    1249             :   /**
    1250             :    * Return the accessing integer for an extra element integer with its name
    1251             :    */
    1252             :   unsigned int getElementIDIndex(const std::string & id_name) const;
    1253             : 
    1254             :   /**
    1255             :    * Return the maximum element ID for an extra element integer with its accessing index
    1256             :    */
    1257             :   dof_id_type maxElementID(unsigned int elem_id_index) const { return _max_ids[elem_id_index]; }
    1258             : 
    1259             :   /**
    1260             :    * Return the minimum element ID for an extra element integer with its accessing index
    1261             :    */
    1262             :   dof_id_type minElementID(unsigned int elem_id_index) const { return _min_ids[elem_id_index]; }
    1263             : 
    1264             :   /**
    1265             :    * Whether or not two extra element integers are identical
    1266             :    */
    1267             :   bool areElemIDsIdentical(const std::string & id_name1, const std::string & id_name2) const;
    1268             : 
    1269             :   /**
    1270             :    * Return all the unique element IDs for an extra element integer with its index
    1271             :    */
    1272             :   std::set<dof_id_type> getAllElemIDs(unsigned int elem_id_index) const;
    1273             : 
    1274             :   /**
    1275             :    * Return all the unique element IDs for an extra element integer with its index on a set of
    1276             :    * subdomains
    1277             :    */
    1278             :   std::set<dof_id_type> getElemIDsOnBlocks(unsigned int elem_id_index,
    1279             :                                            const std::set<SubdomainID> & blks) const;
    1280             : 
    1281             :   /**
    1282             :    * Get the maximum number of sides per element
    1283             :    */
    1284        9077 :   unsigned int getMaxSidesPerElem() const { return _max_sides_per_elem; }
    1285             : 
    1286             :   /**
    1287             :    * Get the maximum number of nodes per element
    1288             :    */
    1289        2265 :   unsigned int getMaxNodesPerElem() const { return _max_nodes_per_elem; }
    1290             : 
    1291             :   /**
    1292             :    * Get the maximum number of nodes per side
    1293             :    */
    1294             :   unsigned int getMaxNodesPerSide() const { return _max_nodes_per_side; }
    1295             : 
    1296             :   std::unordered_map<dof_id_type, std::set<dof_id_type>>
    1297             :   getElemIDMapping(const std::string & from_id_name, const std::string & to_id_name) const;
    1298             : 
    1299             :   ///@{ accessors for the FaceInfo objects
    1300             :   unsigned int nFace() const { return _face_info.size(); }
    1301             : 
    1302             :   /// Accessor for local \p FaceInfo objects.
    1303             :   const std::vector<const FaceInfo *> & faceInfo() const;
    1304             : 
    1305             :   /// Need to declare these iterators here to make sure the iterators below work
    1306             :   struct face_info_iterator;
    1307             :   struct const_face_info_iterator;
    1308             : 
    1309             :   /// Iterators to owned faceInfo objects. These faceInfo-s are required for the
    1310             :   /// face loops and to filter out the faceInfo-s that are not owned by this processor
    1311             :   /// in case we have a distributed mesh and we included FaceInfo objects that
    1312             :   /// are on processor boundaries
    1313             :   face_info_iterator ownedFaceInfoBegin();
    1314             :   face_info_iterator ownedFaceInfoEnd();
    1315             : 
    1316             :   /// Need to declare these iterators here to make sure the iterators below work
    1317             :   struct elem_info_iterator;
    1318             :   struct const_elem_info_iterator;
    1319             : 
    1320             :   /// Iterators to owned faceInfo objects. These faceInfo-s are required for the
    1321             :   /// face loops and to filter out the faceInfo-s that are not owned by this processor
    1322             :   /// in case we have a distributed mesh and we included FaceInfo objects that
    1323             :   /// are on processor boundaries
    1324             :   elem_info_iterator ownedElemInfoBegin();
    1325             :   elem_info_iterator ownedElemInfoEnd();
    1326             : 
    1327             :   /// Accessor for the local FaceInfo object on the side of one element. Returns null if ghosted.
    1328             :   const FaceInfo * faceInfo(const Elem * elem, unsigned int side) const;
    1329             : 
    1330             :   /// Accessor for the elemInfo object for a given element ID
    1331             :   const ElemInfo & elemInfo(const dof_id_type id) const;
    1332             : 
    1333             :   /// Accessor for the element info objects owned by this process
    1334          15 :   const std::vector<const ElemInfo *> & elemInfoVector() const { return _elem_info; }
    1335             : 
    1336             :   /// Accessor for all \p FaceInfo objects.
    1337             :   const std::vector<FaceInfo> & allFaceInfo() const;
    1338             :   ///@}
    1339             : 
    1340             :   /**
    1341             :    * Cache if variables live on the elements connected by the FaceInfo objects
    1342             :    */
    1343             :   void cacheFaceInfoVariableOwnership() const;
    1344             : 
    1345             :   /**
    1346             :    * Cache the DoF indices for FV variables on each element. These indices are used to speed up the
    1347             :    * setup loops of finite volume systems.
    1348             :    */
    1349             :   void cacheFVElementalDoFs() const;
    1350             : 
    1351             :   /**
    1352             :    * Compute the face coordinate value for all \p FaceInfo and \p ElemInfo objects. 'Coordinate'
    1353             :    * here means a coordinate value associated with the coordinate system. For Cartesian coordinate
    1354             :    * systems, 'coordinate' is simply '1'; in RZ, '2*pi*r', and in spherical, '4*pi*r^2'
    1355             :    */
    1356             :   void computeFiniteVolumeCoords() const;
    1357             : 
    1358             :   /**
    1359             :    * Set whether this mesh is a displaced mesh
    1360             :    */
    1361        2032 :   void isDisplaced(bool is_displaced) { _is_displaced = is_displaced; }
    1362             : 
    1363             :   /**
    1364             :    * whether this mesh is a displaced mesh
    1365             :    */
    1366             :   bool isDisplaced() const { return _is_displaced; }
    1367             : 
    1368             :   /**
    1369             :    * @return A map from nodeset ids to the vector of node ids in the nodeset
    1370             :    */
    1371             :   const std::map<boundary_id_type, std::vector<dof_id_type>> & nodeSetNodes() const;
    1372             : 
    1373             :   /**
    1374             :    * Get the coordinate system type, e.g. xyz, rz, or r-spherical, for the provided subdomain id \p
    1375             :    * sid
    1376             :    */
    1377             :   Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const;
    1378             : 
    1379             :   /**
    1380             :    * Get the coordinate system from the mesh, it must be the same in all subdomains otherwise this
    1381             :    * will error
    1382             :    */
    1383             :   Moose::CoordinateSystemType getUniqueCoordSystem() const;
    1384             : 
    1385             :   /**
    1386             :    * Get the map from subdomain ID to coordinate system type, e.g. xyz, rz, or r-spherical
    1387             :    */
    1388             :   const std::map<SubdomainID, Moose::CoordinateSystemType> & getCoordSystem() const;
    1389             : 
    1390             :   /**
    1391             :    * Set the coordinate system for the provided blocks to \p coord_sys
    1392             :    */
    1393             :   void setCoordSystem(const std::vector<SubdomainName> & blocks, const MultiMooseEnum & coord_sys);
    1394             : 
    1395             :   /**
    1396             :    * For axisymmetric simulations, set the symmetry coordinate axis. For r in the x-direction, z in
    1397             :    * the y-direction the coordinate axis would be y
    1398             :    */
    1399             :   void setAxisymmetricCoordAxis(const MooseEnum & rz_coord_axis);
    1400             : 
    1401             :   /**
    1402             :    * Sets the general coordinate axes for axisymmetric blocks.
    1403             :    *
    1404             :    * This method must be used if any of the following are true:
    1405             :    * - There are multiple axisymmetric coordinate systems
    1406             :    * - Any axisymmetric coordinate system axis/direction is not the +X or +Y axis
    1407             :    * - Any axisymmetric coordinate system does not start at (0,0,0)
    1408             :    *
    1409             :    * @param[in] blocks  Subdomain names
    1410             :    * @param[in] axes  Pair of values defining the axisymmetric coordinate axis
    1411             :    *                  for each subdomain. The first value is the point on the axis
    1412             :    *                  corresponding to the origin. The second value is the direction
    1413             :    *                  vector of the axis (normalization not necessary).
    1414             :    */
    1415             :   void setGeneralAxisymmetricCoordAxes(const std::vector<SubdomainName> & blocks,
    1416             :                                        const std::vector<std::pair<Point, RealVectorValue>> & axes);
    1417             : 
    1418             :   /**
    1419             :    * Gets the general axisymmetric coordinate axis for a block.
    1420             :    *
    1421             :    * @param[in] subdomain_id  Subdomain ID for which to get axisymmetric coordinate axis
    1422             :    */
    1423             :   const std::pair<Point, RealVectorValue> &
    1424             :   getGeneralAxisymmetricCoordAxis(SubdomainID subdomain_id) const;
    1425             : 
    1426             :   /**
    1427             :    * Returns true if general axisymmetric coordinate axes are being used
    1428             :    */
    1429             :   bool usingGeneralAxisymmetricCoordAxes() const;
    1430             : 
    1431             :   /**
    1432             :    * Returns the desired radial direction for RZ coordinate transformation
    1433             :    * @return The coordinate direction for the radial direction
    1434             :    */
    1435             :   unsigned int getAxisymmetricRadialCoord() const;
    1436             : 
    1437             :   /**
    1438             :    * Performs a sanity check for every element in the mesh. If an element dimension is 3 and the
    1439             :    * corresponding coordinate system is RZ, then this will error. If an element dimension is greater
    1440             :    * than 1 and the corresponding system is RPSHERICAL then this will error
    1441             :    */
    1442             :   void checkCoordinateSystems();
    1443             : 
    1444             :   /**
    1445             :    * Set the coordinate system data to that of \p other_mesh
    1446             :    */
    1447             :   void setCoordData(const MooseMesh & other_mesh);
    1448             : 
    1449             :   /**
    1450             :    * Mark the finite volume information as dirty
    1451             :    */
    1452        4132 :   void markFiniteVolumeInfoDirty() { _finite_volume_info_dirty = true; }
    1453             : 
    1454             :   /**
    1455             :    * @return whether the finite volume information is dirty
    1456             :    */
    1457        1238 :   bool isFiniteVolumeInfoDirty() const { return _finite_volume_info_dirty; }
    1458             : 
    1459             :   /**
    1460             :    * @return the coordinate transformation object that describes how to transform this problem's
    1461             :    * coordinate system into the canonical/reference coordinate system
    1462             :    */
    1463             :   MooseAppCoordTransform & coordTransform();
    1464             : 
    1465             :   /**
    1466             :    * @return the length unit of this mesh provided through the coordinate transformation object
    1467             :    */
    1468             :   const MooseUnits & lengthUnit() const;
    1469             : 
    1470             :   /**
    1471             :    * This function attempts to return the map from a high-order element side to its corresponding
    1472             :    * lower-d element
    1473             :    */
    1474             :   const std::unordered_map<std::pair<const Elem *, unsigned short int>, const Elem *> &
    1475             :   getLowerDElemMap() const;
    1476             : 
    1477             :   /**
    1478             :    * @return Whether or not this mesh comes from a split mesh
    1479             :    */
    1480      180445 :   bool isSplit() const { return _is_split; }
    1481             : 
    1482             :   /**
    1483             :    * Builds the face and elem info vectors that store meta-data needed for looping over and doing
    1484             :    * calculations based on mesh faces and elements in a finite volume setting. This should only
    1485             :    * be called when finite volume variables are used in the problem or when the face and elem info
    1486             :    * objects are necessary for functor-based evaluations.
    1487             :    */
    1488             :   void buildFiniteVolumeInfo() const;
    1489             : 
    1490             :   /**
    1491             :    * Sets up the additional data needed for finite volume computations.
    1492             :    * This involves building FaceInfo and ElemInfo objects, caching variable associations
    1493             :    * and elemental DoF indices for FV variables.
    1494             :    */
    1495             :   void setupFiniteVolumeMeshData() const;
    1496             : 
    1497             :   /**
    1498             :    * Indicate whether the kind of adaptivity we're doing includes p-refinement
    1499             :    */
    1500         228 :   void doingPRefinement(bool doing_p_refinement) { _doing_p_refinement = doing_p_refinement; }
    1501             : 
    1502             :   /**
    1503             :    * Query whether the kind of adaptivity we're doing includes p-refinement
    1504             :    */
    1505      127856 :   [[nodiscard]] bool doingPRefinement() const { return _doing_p_refinement; }
    1506             : 
    1507             :   /**
    1508             :    * Returns the maximum p-refinement level of all elements
    1509             :    */
    1510       53703 :   unsigned int maxPLevel() const { return _max_p_level; }
    1511             : 
    1512             :   /**
    1513             :    * Returns the maximum h-refinement level of all elements
    1514             :    */
    1515       58519 :   unsigned int maxHLevel() const { return _max_h_level; }
    1516             : 
    1517             :   /**
    1518             :    * Get the map describing for each volumetric quadrature point (qp) on the refined level which qp
    1519             :    * on the previous coarser level the fine qp is closest to
    1520             :    */
    1521             :   const std::vector<QpMap> & getPRefinementMap(const Elem & elem) const;
    1522             :   /**
    1523             :    * Get the map describing for each side quadrature point (qp) on the refined level which qp
    1524             :    * on the previous coarser level the fine qp is closest to
    1525             :    */
    1526             :   const std::vector<QpMap> & getPRefinementSideMap(const Elem & elem) const;
    1527             :   /**
    1528             :    * Get the map describing for each volumetric quadrature point (qp) on the coarse level which qp
    1529             :    * on the previous finer level the coarse qp is closest to
    1530             :    */
    1531             :   const std::vector<QpMap> & getPCoarseningMap(const Elem & elem) const;
    1532             :   /**
    1533             :    * Get the map describing for each side quadrature point (qp) on the coarse level which qp
    1534             :    * on the previous finer level the coarse qp is closest to
    1535             :    */
    1536             :   const std::vector<QpMap> & getPCoarseningSideMap(const Elem & elem) const;
    1537             : 
    1538             :   void buildPRefinementAndCoarseningMaps(Assembly * assembly);
    1539             : 
    1540             :   /**
    1541             :    * @return Whether there are any lower-dimensional blocks
    1542             :    */
    1543       33964 :   bool hasLowerD() const { return getMesh().elem_dimensions().size() > 1; }
    1544             : 
    1545             :   /**
    1546             :    * @return The set of lower-dimensional blocks for interior sides
    1547             :    */
    1548   379786465 :   const std::set<SubdomainID> & interiorLowerDBlocks() const { return _lower_d_interior_blocks; }
    1549             :   /**
    1550             :    * @return The set of lower-dimensional blocks for boundary sides
    1551             :    */
    1552   378903265 :   const std::set<SubdomainID> & boundaryLowerDBlocks() const { return _lower_d_boundary_blocks; }
    1553             : 
    1554             :   /// Return construct node list from side list boolean
    1555         130 :   bool getConstructNodeListFromSideList() { return _construct_node_list_from_side_list; }
    1556             : 
    1557             :   /// Return displace node list by side list boolean
    1558             :   bool getDisplaceNodeListBySideList() { return _displace_node_list_by_side_list; }
    1559             : 
    1560             : protected:
    1561             :   /// Deprecated (DO NOT USE)
    1562             :   std::vector<std::unique_ptr<libMesh::GhostingFunctor>> _ghosting_functors;
    1563             : 
    1564             :   /// The list of active geometric relationship managers (bound to the underlying MeshBase object).
    1565             :   std::vector<std::shared_ptr<RelationshipManager>> _relationship_managers;
    1566             : 
    1567             :   /// Whether or not this mesh was built from another mesh
    1568             :   bool _built_from_other_mesh = false;
    1569             : 
    1570             :   /// Can be set to DISTRIBUTED, REPLICATED, or DEFAULT.  Determines whether
    1571             :   /// the underlying libMesh mesh is a ReplicatedMesh or DistributedMesh.
    1572             :   ParallelType _parallel_type;
    1573             : 
    1574             :   /// False by default.  Final value is determined by several factors
    1575             :   /// including the 'distribution' setting in the input file, and whether
    1576             :   /// or not the Mesh file is a Nemesis file.
    1577             :   bool _use_distributed_mesh;
    1578             :   bool _distribution_overridden;
    1579             :   bool _parallel_type_overridden;
    1580             : 
    1581             :   /// Pointer to underlying libMesh mesh object
    1582             :   std::unique_ptr<libMesh::MeshBase> _mesh;
    1583             : 
    1584             :   /// Pointer to Kokkos mesh object
    1585             : #ifdef MOOSE_KOKKOS_ENABLED
    1586             :   std::unique_ptr<Moose::Kokkos::Mesh> _kokkos_mesh;
    1587             : #endif
    1588             : 
    1589             :   /// The partitioner used on this mesh
    1590             :   MooseEnum _partitioner_name;
    1591             :   bool _partitioner_overridden;
    1592             : 
    1593             :   /// The custom partitioner
    1594             :   std::unique_ptr<libMesh::Partitioner> _custom_partitioner;
    1595             :   bool _custom_partitioner_requested;
    1596             : 
    1597             :   /// Convenience enums
    1598             :   enum
    1599             :   {
    1600             :     X = 0,
    1601             :     Y,
    1602             :     Z
    1603             :   };
    1604             :   enum
    1605             :   {
    1606             :     MIN = 0,
    1607             :     MAX
    1608             :   };
    1609             : 
    1610             :   /// The level of uniform refinement requested (set to zero if AMR is disabled)
    1611             :   unsigned int _uniform_refine_level;
    1612             : 
    1613             :   /// Whether or not to skip uniform refinements when using a pre-split mesh
    1614             :   bool _skip_refine_when_use_split;
    1615             : 
    1616             :   /// Whether or not skip remote deletion and repartition after uniform refinements
    1617             :   bool _skip_deletion_repartition_after_refine;
    1618             : 
    1619             :   /// true if mesh is changed (i.e. after adaptivity step)
    1620             :   bool _is_changed;
    1621             : 
    1622             :   /// True if a Nemesis Mesh was read in
    1623             :   bool _is_nemesis;
    1624             : 
    1625             :   /// True if prepare has been called on the mesh
    1626             :   bool _moose_mesh_prepared = false;
    1627             : 
    1628             :   /// The elements that were just refined.
    1629             :   std::unique_ptr<ConstElemPointerRange> _refined_elements;
    1630             : 
    1631             :   /// The elements that were just coarsened.
    1632             :   std::unique_ptr<ConstElemPointerRange> _coarsened_elements;
    1633             : 
    1634             :   /**
    1635             :    * Map of Parent elements to child elements for elements that were just coarsened.
    1636             :    *
    1637             :    * NOTE: the child element pointers ARE PROBABLY INVALID.  Only use them for indexing!
    1638             :    */
    1639             :   std::map<const Elem *, std::vector<const Elem *>> _coarsened_element_children;
    1640             : 
    1641             :   /// Used for generating the semilocal node range
    1642             :   std::set<Node *> _semilocal_node_list;
    1643             : 
    1644             :   /**
    1645             :    * A range for use with threading.  We do this so that it doesn't have
    1646             :    * to get rebuilt all the time (which takes time).
    1647             :    */
    1648             :   std::unique_ptr<libMesh::ConstElemRange> _active_local_elem_range;
    1649             : 
    1650             :   std::unique_ptr<SemiLocalNodeRange> _active_semilocal_node_range;
    1651             :   std::unique_ptr<libMesh::NodeRange> _active_node_range;
    1652             :   std::unique_ptr<libMesh::ConstNodeRange> _local_node_range;
    1653             :   std::unique_ptr<libMesh::StoredRange<MooseMesh::const_bnd_node_iterator, const BndNode *>>
    1654             :       _bnd_node_range;
    1655             :   std::unique_ptr<libMesh::StoredRange<MooseMesh::const_bnd_elem_iterator, const BndElement *>>
    1656             :       _bnd_elem_range;
    1657             : 
    1658             :   /// A map of all of the current nodes to the elements that they are connected to.
    1659             :   std::map<dof_id_type, std::vector<dof_id_type>> _node_to_elem_map;
    1660             :   bool _node_to_elem_map_built;
    1661             : 
    1662             :   /// A map of all of the current nodes to the active elements that they are connected to.
    1663             :   std::map<dof_id_type, std::vector<dof_id_type>> _node_to_active_semilocal_elem_map;
    1664             :   bool _node_to_active_semilocal_elem_map_built;
    1665             : 
    1666             :   /**
    1667             :    * A set of subdomain IDs currently present in the mesh. For parallel meshes, includes
    1668             :    * subdomains defined on other processors as well.
    1669             :    */
    1670             :   std::set<SubdomainID> _mesh_subdomains;
    1671             : 
    1672             :   ///@{
    1673             :   /**
    1674             :    * A set of boundary IDs currently present in the mesh. In serial, this is equivalent to the
    1675             :    * values returned by _mesh.get_boundary_info().get_boundary_ids(). In parallel, it will contain
    1676             :    * off-processor boundary IDs as well.
    1677             :    */
    1678             :   std::set<BoundaryID> _mesh_boundary_ids;
    1679             :   std::set<BoundaryID> _mesh_sideset_ids;
    1680             :   std::set<BoundaryID> _mesh_nodeset_ids;
    1681             :   ///@}
    1682             : 
    1683             :   /// The boundary to normal map - valid only when AddAllSideSetsByNormals is active
    1684             :   std::unique_ptr<std::map<BoundaryID, RealVectorValue>> _boundary_to_normal_map;
    1685             : 
    1686             :   /// array of boundary nodes
    1687             :   std::vector<BndNode *> _bnd_nodes;
    1688             :   typedef std::vector<BndNode *>::iterator bnd_node_iterator_imp;
    1689             :   typedef std::vector<BndNode *>::const_iterator const_bnd_node_iterator_imp;
    1690             :   /// Map of sets of node IDs in each boundary
    1691             :   std::map<boundary_id_type, std::set<dof_id_type>> _bnd_node_ids;
    1692             : 
    1693             :   /// array of boundary elems
    1694             :   std::vector<BndElement *> _bnd_elems;
    1695             :   typedef std::vector<BndElement *>::iterator bnd_elem_iterator_imp;
    1696             :   typedef std::vector<BndElement *>::const_iterator const_bnd_elem_iterator_imp;
    1697             : 
    1698             :   /// Map of set of elem IDs connected to each boundary
    1699             :   std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> _bnd_elem_ids;
    1700             : 
    1701             :   std::map<dof_id_type, Node *> _quadrature_nodes;
    1702             :   std::map<dof_id_type, std::map<unsigned int, std::map<dof_id_type, Node *>>>
    1703             :       _elem_to_side_to_qp_to_quadrature_nodes;
    1704             :   std::vector<BndNode> _extra_bnd_nodes;
    1705             : 
    1706             :   /// list of nodes that belongs to a specified block (domain)
    1707             :   std::map<dof_id_type, std::set<SubdomainID>> _block_node_list;
    1708             : 
    1709             :   /// list of nodes that belongs to a specified nodeset: indexing [nodeset_id] -> [array of node ids]
    1710             :   std::map<boundary_id_type, std::vector<dof_id_type>> _node_set_nodes;
    1711             : 
    1712             :   std::set<unsigned int> _ghosted_boundaries;
    1713             :   std::vector<Real> _ghosted_boundaries_inflation;
    1714             : 
    1715             :   /// The number of nodes to consider in the NearestNode neighborhood.
    1716             :   unsigned int _patch_size;
    1717             : 
    1718             :   /// The number of nearest neighbors to consider for ghosting purposes when iteration patch update strategy is used.
    1719             :   unsigned int _ghosting_patch_size;
    1720             : 
    1721             :   // The maximum number of points in each leaf of the KDTree used in the nearest neighbor search.
    1722             :   unsigned int _max_leaf_size;
    1723             : 
    1724             :   /// The patch update strategy
    1725             :   Moose::PatchUpdateType _patch_update_strategy;
    1726             : 
    1727             :   /// Vector of all the Nodes in the mesh for determining when to add a new point
    1728             :   std::vector<Node *> _node_map;
    1729             : 
    1730             :   /// Boolean indicating whether this mesh was detected to be regular and orthogonal
    1731             :   bool _regular_orthogonal_mesh;
    1732             : 
    1733             :   /// The bounds in each dimension of the mesh for regular orthogonal meshes
    1734             :   std::vector<std::vector<Real>> _bounds;
    1735             : 
    1736             :   /// A vector holding the paired boundaries for a regular orthogonal mesh
    1737             :   std::optional<std::vector<std::pair<BoundaryID, BoundaryID>>> _paired_boundary;
    1738             : 
    1739             :   /// Whether or not we are using a (pre-)split mesh (automatically DistributedMesh)
    1740             :   const bool _is_split;
    1741             : 
    1742             :   void cacheInfo();
    1743             :   void freeBndNodes();
    1744             :   void freeBndElems();
    1745             :   void setPartitionerHelper(MeshBase * mesh = nullptr);
    1746             : 
    1747             : private:
    1748             :   /// Map connecting elems with their corresponding ElemInfo, we use the element ID as
    1749             :   /// the key
    1750             :   mutable std::unordered_map<dof_id_type, ElemInfo> _elem_to_elem_info;
    1751             : 
    1752             :   /// Holds only those \p ElemInfo objects that have \p processor_id equal to this process's id,
    1753             :   /// e.g. the local \p ElemInfo objects
    1754             :   mutable std::vector<const ElemInfo *> _elem_info;
    1755             : 
    1756             :   /// FaceInfo object storing information for face based loops. This container holds all the \p
    1757             :   /// FaceInfo objects accessible from this process
    1758             :   mutable std::vector<FaceInfo> _all_face_info;
    1759             : 
    1760             :   /// Holds only those \p FaceInfo objects that have \p processor_id equal to this process's id,
    1761             :   /// e.g. the local \p FaceInfo objects
    1762             :   mutable std::vector<const FaceInfo *> _face_info;
    1763             : 
    1764             :   /// Map from elem-side pair to FaceInfo
    1765             :   mutable std::unordered_map<std::pair<const Elem *, unsigned int>, FaceInfo *>
    1766             :       _elem_side_to_face_info;
    1767             : 
    1768             :   // true if the _face_info member needs to be rebuilt/updated.
    1769             :   mutable bool _finite_volume_info_dirty = true;
    1770             : 
    1771             :   // True if we have cached elemental dofs ids for the linear finite volume variables.
    1772             :   // This happens in the first system which has a linear finite volume variable, considering
    1773             :   // that currently we only support one variable per linear system.
    1774             :   mutable bool _linear_finite_volume_dofs_cached = false;
    1775             : 
    1776             :   /**
    1777             :    * A map from (system number, vector number) to which dimensions are periodic in a regular
    1778             :    * orthogonal mesh.
    1779             :    *
    1780             :    * This data structure is populated by addPeriodicVariable.
    1781             :    */
    1782             :   std::map<std::pair<unsigned int, unsigned int>, std::array<bool, 3>> _periodic_dim;
    1783             : 
    1784             :   /**
    1785             :    * A convenience vector used to hold values in each dimension representing half of the range.
    1786             :    */
    1787             :   RealVectorValue _half_range;
    1788             : 
    1789             :   /// A vector containing the nodes at the corners of a regular orthogonal mesh
    1790             :   std::vector<Node *> _extreme_nodes;
    1791             : 
    1792             :   /**
    1793             :    * Build the refinement map for a given element type.  This will tell you what quadrature points
    1794             :    * to copy from and to for stateful material properties on newly created elements from Adaptivity.
    1795             :    *
    1796             :    * @param elem The element that represents the element type you need the refinement map for.
    1797             :    * @param qrule The quadrature rule in use.
    1798             :    * @param qrule_face The current face quadrature rule
    1799             :    * @param parent_side The side of the parent to map (-1 if not mapping parent sides)
    1800             :    * @param child The child number (-1 if not mapping child internal sides)
    1801             :    * @param child_side The side number of the child (-1 if not mapping sides)
    1802             :    */
    1803             :   void buildRefinementMap(const Elem & elem,
    1804             :                           libMesh::QBase & qrule,
    1805             :                           libMesh::QBase & qrule_face,
    1806             :                           int parent_side,
    1807             :                           int child,
    1808             :                           int child_side);
    1809             : 
    1810             :   /**
    1811             :    * Build the coarsening map for a given element type.  This will tell you what quadrature points
    1812             :    * to copy from and to for stateful material properties on newly created elements from Adaptivity.
    1813             :    *
    1814             :    * @param elem The element that represents the element type you need the coarsening map for.
    1815             :    * @param qrule The quadrature rule in use.
    1816             :    * @param qrule_face The current face quadrature rule
    1817             :    * @param input_side The side to map
    1818             :    */
    1819             :   void buildCoarseningMap(const Elem & elem,
    1820             :                           libMesh::QBase & qrule,
    1821             :                           libMesh::QBase & qrule_face,
    1822             :                           int input_side);
    1823             : 
    1824             :   /**
    1825             :    * Find the closest points that map "from" to "to" and fill up "qp_map".
    1826             :    * Essentially, for each point in "from" find the closest point in "to".
    1827             :    *
    1828             :    * @param from The reference positions in the parent of the the points we're mapping _from_
    1829             :    * @param to The reference positions in the parent of the the points we're mapping _to_
    1830             :    * @param qp_map This will be filled with QpMap objects holding the mappings.
    1831             :    */
    1832             :   void mapPoints(const std::vector<Point> & from,
    1833             :                  const std::vector<Point> & to,
    1834             :                  std::vector<QpMap> & qp_map);
    1835             : 
    1836             :   /**
    1837             :    * Given an elem type, get maps that tell us what qp's are closest to each other between a parent
    1838             :    * and it's children.
    1839             :    * This is mainly used for mapping stateful material properties during adaptivity.
    1840             :    *
    1841             :    * There are 3 cases here:
    1842             :    *
    1843             :    * 1. Volume to volume (parent_side = -1, child = -1, child_side = -1)
    1844             :    * 2. Parent side to child side (parent_side = 0+, child = -1, child_side = 0+)
    1845             :    * 3. Child side to parent volume (parent_side = -1, child = 0+, child_side = 0+)
    1846             :    *
    1847             :    * Case 3 only happens under refinement (need to invent data at internal child sides).
    1848             :    *
    1849             :    * @param template_elem An element of the type that we need to find the maps for
    1850             :    * @param qrule The quadrature rule that we need to find the maps for
    1851             :    * @param qrule_face The face quadrature rule that we need to find the maps for
    1852             :    * @param refinement_map The map to use when an element gets split
    1853             :    * @param coarsen_map The map to use when an element is coarsened.
    1854             :    * @param parent_side - the id of the parent's side
    1855             :    * @param child - the id of the child element
    1856             :    * @param child_side - The id of the child's side
    1857             :    */
    1858             :   void findAdaptivityQpMaps(const Elem * template_elem,
    1859             :                             libMesh::QBase & qrule,
    1860             :                             libMesh::QBase & qrule_face,
    1861             :                             std::vector<std::vector<QpMap>> & refinement_map,
    1862             :                             std::vector<std::pair<unsigned int, QpMap>> & coarsen_map,
    1863             :                             int parent_side,
    1864             :                             int child,
    1865             :                             int child_side);
    1866             : 
    1867             :   void buildHRefinementAndCoarseningMaps(Assembly * assembly);
    1868             : 
    1869             :   const std::vector<QpMap> & getPRefinementMapHelper(
    1870             :       const Elem & elem,
    1871             :       const std::map<std::pair<libMesh::ElemType, unsigned int>, std::vector<QpMap>> &) const;
    1872             :   const std::vector<QpMap> & getPCoarseningMapHelper(
    1873             :       const Elem & elem,
    1874             :       const std::map<std::pair<libMesh::ElemType, unsigned int>, std::vector<QpMap>> &) const;
    1875             : 
    1876             :   /**
    1877             :    * Update the coordinate transformation object based on our coordinate system data. The coordinate
    1878             :    * transformation will be created if it hasn't been already
    1879             :    */
    1880             :   void updateCoordTransform();
    1881             : 
    1882             :   /**
    1883             :    * Loop through all subdomain IDs and check if there is name duplication used for the subdomains
    1884             :    * with same ID. Throw out an error if any name duplication is found.
    1885             :    */
    1886             :   void checkDuplicateSubdomainNames();
    1887             : 
    1888             :   /// Holds mappings for volume to volume and parent side to child side
    1889             :   /// Map key:
    1890             :   /// - first member corresponds to element side. It's -1 for volume quadrature points
    1891             :   /// - second member correponds to the element type
    1892             :   /// Map value:
    1893             :   /// - Outermost index is the child element index
    1894             :   /// - Once we have indexed by the child element index, we have a std::vector of QpMaps. This
    1895             :   ///   vector is sized by the number of reference points in the child element. Then for each
    1896             :   ///   reference point in the child element we have a QpMap whose \p _from index corresponds to
    1897             :   ///   the child element reference point, a \p _to index which corresponds to the reference point
    1898             :   ///   on the parent element that the child element reference point is closest to, and a
    1899             :   ///   \p _distance member which is the distance between the mapped child and parent reference
    1900             :   ///   quadrature points
    1901             :   std::map<std::pair<int, libMesh::ElemType>, std::vector<std::vector<QpMap>>>
    1902             :       _elem_type_to_refinement_map;
    1903             : 
    1904             :   std::map<std::pair<libMesh::ElemType, unsigned int>, std::vector<QpMap>>
    1905             :       _elem_type_to_p_refinement_map;
    1906             :   std::map<std::pair<libMesh::ElemType, unsigned int>, std::vector<QpMap>>
    1907             :       _elem_type_to_p_refinement_side_map;
    1908             : 
    1909             :   /// Holds mappings for "internal" child sides to parent volume.  The second key is (child, child_side).
    1910             :   std::map<libMesh::ElemType, std::map<std::pair<int, int>, std::vector<std::vector<QpMap>>>>
    1911             :       _elem_type_to_child_side_refinement_map;
    1912             : 
    1913             :   /// Holds mappings for volume to volume and parent side to child side
    1914             :   /// Map key:
    1915             :   /// - first member corresponds to element side. It's -1 for volume quadrature points
    1916             :   /// - second member correponds to the element type
    1917             :   /// Map value:
    1918             :   /// - Vector is sized based on the number of quadrature points in the parent (e.g. coarser)
    1919             :   ///   element.
    1920             :   /// - For each parent quadrature point we store a pair
    1921             :   ///   - The first member of the pair identifies which child holds the closest refined-level
    1922             :   ///     quadrature point
    1923             :   ///   - The second member of the pair is the QpMap. The \p _from data member will correspond to
    1924             :   ///     the parent quadrature point index. The \p _to data member will correspond to which child
    1925             :   ///     element quadrature point is closest to the parent quadrature point. And \p _distance is
    1926             :   ///     the distance between the two
    1927             :   std::map<std::pair<int, libMesh::ElemType>, std::vector<std::pair<unsigned int, QpMap>>>
    1928             :       _elem_type_to_coarsening_map;
    1929             : 
    1930             :   std::map<std::pair<libMesh::ElemType, unsigned int>, std::vector<QpMap>>
    1931             :       _elem_type_to_p_coarsening_map;
    1932             :   std::map<std::pair<libMesh::ElemType, unsigned int>, std::vector<QpMap>>
    1933             :       _elem_type_to_p_coarsening_side_map;
    1934             : 
    1935             :   struct SubdomainData
    1936             :   {
    1937             :     /// Neighboring subdomain ids
    1938             :     std::set<SubdomainID> neighbor_subs;
    1939             : 
    1940             :     /// The boundary ids that are attached. This set will include any sideset boundary ID that
    1941             :     /// is a side of any part of the subdomain
    1942             :     std::set<BoundaryID> boundary_ids;
    1943             :   };
    1944             : 
    1945             :   /// Holds a map from subdomain ids to associated data
    1946             :   std::unordered_map<SubdomainID, SubdomainData> _sub_to_data;
    1947             : 
    1948             :   /// Holds a map from neighbor subomdain ids to the boundary ids that are attached to it
    1949             :   std::unordered_map<SubdomainID, std::set<BoundaryID>> _neighbor_subdomain_boundary_ids;
    1950             : 
    1951             :   /// Mesh blocks for interior lower-d elements in different types
    1952             :   std::set<SubdomainID> _lower_d_interior_blocks;
    1953             :   /// Mesh blocks for boundary lower-d elements in different types
    1954             :   std::set<SubdomainID> _lower_d_boundary_blocks;
    1955             :   /// Holds a map from a high-order element side to its corresponding lower-d element
    1956             :   std::unordered_map<std::pair<const Elem *, unsigned short int>, const Elem *>
    1957             :       _higher_d_elem_side_to_lower_d_elem;
    1958             :   std::unordered_map<const Elem *, unsigned short int> _lower_d_elem_to_higher_d_elem_side;
    1959             : 
    1960             :   /// Whether or not this Mesh is allowed to read a recovery file
    1961             :   bool _allow_recovery;
    1962             : 
    1963             :   /// Whether or not to allow generation of nodesets from sidesets
    1964             :   bool _construct_node_list_from_side_list;
    1965             : 
    1966             :   /// Whether or not to displace unrelated nodesets by nodesets
    1967             :   /// constructed from sidesets
    1968             :   bool _displace_node_list_by_side_list;
    1969             : 
    1970             :   /// Whether we need to delete remote elements after init'ing the EquationSystems
    1971             :   bool _need_delete;
    1972             : 
    1973             :   /// Whether to allow removal of remote elements
    1974             :   bool _allow_remote_element_removal;
    1975             : 
    1976             :   /// Set of elements ghosted by ghostGhostedBoundaries
    1977             :   std::set<Elem *> _ghost_elems_from_ghost_boundaries;
    1978             : 
    1979             :   /// A parallel mesh generator such as DistributedRectilinearMeshGenerator
    1980             :   /// already make everything ready. We do not need to gather all boundaries to
    1981             :   /// every single processor. In general, we should avoid using ghostGhostedBoundaries
    1982             :   /// when possible since it is not scalable
    1983             :   bool _need_ghost_ghosted_boundaries;
    1984             : 
    1985             :   /// Unique element integer IDs for each subdomain and each extra element integers
    1986             :   std::vector<std::unordered_map<SubdomainID, std::set<dof_id_type>>> _block_id_mapping;
    1987             :   /// Maximum integer ID for each extra element integer
    1988             :   std::vector<dof_id_type> _max_ids;
    1989             :   /// Minimum integer ID for each extra element integer
    1990             :   std::vector<dof_id_type> _min_ids;
    1991             :   /// Flags to indicate whether or not any two extra element integers are the same
    1992             :   std::vector<std::vector<bool>> _id_identical_flag;
    1993             : 
    1994             :   /// The maximum number of sides per element
    1995             :   unsigned int _max_sides_per_elem;
    1996             : 
    1997             :   /// The maximum number of nodes per element
    1998             :   unsigned int _max_nodes_per_elem;
    1999             : 
    2000             :   /// The maximum number of nodes per side
    2001             :   unsigned int _max_nodes_per_side;
    2002             : 
    2003             :   /// Compute the maximum numbers per element and side
    2004             :   void computeMaxPerElemAndSide();
    2005             : 
    2006             :   /// Whether this mesh is displaced
    2007             :   bool _is_displaced;
    2008             : 
    2009             :   /// Build extra data for faster access to the information of extra element integers
    2010             :   void buildElemIDInfo();
    2011             : 
    2012             :   /// Build lower-d mesh for all sides
    2013             :   void buildLowerDMesh();
    2014             : 
    2015             :   /// Type of coordinate system per subdomain
    2016             :   std::map<SubdomainID, Moose::CoordinateSystemType> & _coord_sys;
    2017             : 
    2018             :   /// Storage for RZ axis selection
    2019             :   unsigned int _rz_coord_axis;
    2020             : 
    2021             :   /// Map of subdomain ID to general axisymmetric axis
    2022             :   std::unordered_map<SubdomainID, std::pair<Point, RealVectorValue>> _subdomain_id_to_rz_coord_axis;
    2023             : 
    2024             :   /// A coordinate transformation object that describes how to transform this problem's coordinate
    2025             :   /// system into the canonical/reference coordinate system
    2026             :   std::unique_ptr<MooseAppCoordTransform> _coord_transform;
    2027             : 
    2028             :   /// Whether the coordinate system has been set
    2029             :   bool _coord_system_set;
    2030             : 
    2031             :   /// Set for holding user-provided coordinate system type block names
    2032             :   std::vector<SubdomainName> _provided_coord_blocks;
    2033             : 
    2034             :   /// Whether we have p-refinement (whether exclusively p- or hp-refinement)
    2035             :   bool _doing_p_refinement;
    2036             :   /// Maximum p-refinement level of all elements
    2037             :   unsigned int _max_p_level;
    2038             :   /// Maximum h-refinement level of all elements
    2039             :   unsigned int _max_h_level;
    2040             : 
    2041             :   template <typename T>
    2042             :   struct MeshType;
    2043             : };
    2044             : 
    2045             : inline MooseAppCoordTransform &
    2046      155472 : MooseMesh::coordTransform()
    2047             : {
    2048             :   mooseAssert(_coord_transform, "The coordinate transformation object is null.");
    2049      155472 :   return *_coord_transform;
    2050             : }
    2051             : 
    2052             : template <>
    2053             : struct MooseMesh::MeshType<libMesh::ReplicatedMesh>
    2054             : {
    2055             :   static const ParallelType value = ParallelType::REPLICATED;
    2056             : };
    2057             : 
    2058             : template <>
    2059             : struct MooseMesh::MeshType<libMesh::DistributedMesh>
    2060             : {
    2061             :   static const ParallelType value = ParallelType::DISTRIBUTED;
    2062             : };
    2063             : 
    2064             : /**
    2065             :  * The definition of the face_info_iterator struct.
    2066             :  */
    2067             : struct MooseMesh::face_info_iterator
    2068             :   : variant_filter_iterator<MeshBase::Predicate, const FaceInfo *>
    2069             : {
    2070             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2071             :   template <typename PredType, typename IterType>
    2072      330694 :   face_info_iterator(const IterType & d, const IterType & e, const PredType & p)
    2073      330694 :     : variant_filter_iterator<MeshBase::Predicate, const FaceInfo *>(d, e, p)
    2074             :   {
    2075      330694 :   }
    2076             : };
    2077             : 
    2078             : /**
    2079             :  * The definition of the const_face_info_iterator struct. It is similar to the
    2080             :  * iterator above, but also provides an additional conversion-to-const ctor.
    2081             :  */
    2082             : struct MooseMesh::const_face_info_iterator : variant_filter_iterator<MeshBase::Predicate,
    2083             :                                                                      const FaceInfo * const,
    2084             :                                                                      const FaceInfo * const &,
    2085             :                                                                      const FaceInfo * const *>
    2086             : {
    2087             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2088             :   template <typename PredType, typename IterType>
    2089             :   const_face_info_iterator(const IterType & d, const IterType & e, const PredType & p)
    2090             :     : variant_filter_iterator<MeshBase::Predicate,
    2091             :                               const FaceInfo * const,
    2092             :                               const FaceInfo * const &,
    2093             :                               const FaceInfo * const *>(d, e, p)
    2094             :   {
    2095             :   }
    2096             : 
    2097             :   // The conversion-to-const ctor.  Takes a regular iterator and calls the appropriate
    2098             :   // variant_filter_iterator copy constructor.  Note that this one is *not* templated!
    2099      330694 :   const_face_info_iterator(const MooseMesh::face_info_iterator & rhs)
    2100      330694 :     : variant_filter_iterator<MeshBase::Predicate,
    2101             :                               const FaceInfo * const,
    2102             :                               const FaceInfo * const &,
    2103      330694 :                               const FaceInfo * const *>(rhs)
    2104             :   {
    2105      330694 :   }
    2106             : };
    2107             : 
    2108             : /**
    2109             :  * The definition of the elem_info_iterator struct.
    2110             :  */
    2111             : struct MooseMesh::elem_info_iterator
    2112             :   : variant_filter_iterator<MeshBase::Predicate, const ElemInfo *>
    2113             : {
    2114             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2115             :   template <typename PredType, typename IterType>
    2116      171074 :   elem_info_iterator(const IterType & d, const IterType & e, const PredType & p)
    2117      171074 :     : variant_filter_iterator<MeshBase::Predicate, const ElemInfo *>(d, e, p)
    2118             :   {
    2119      171074 :   }
    2120             : };
    2121             : 
    2122             : /**
    2123             :  * The definition of the const_elem_info_iterator struct. It is similar to the
    2124             :  * iterator above, but also provides an additional conversion-to-const ctor.
    2125             :  */
    2126             : struct MooseMesh::const_elem_info_iterator : variant_filter_iterator<MeshBase::Predicate,
    2127             :                                                                      const ElemInfo * const,
    2128             :                                                                      const ElemInfo * const &,
    2129             :                                                                      const ElemInfo * const *>
    2130             : {
    2131             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2132             :   template <typename PredType, typename IterType>
    2133             :   const_elem_info_iterator(const IterType & d, const IterType & e, const PredType & p)
    2134             :     : variant_filter_iterator<MeshBase::Predicate,
    2135             :                               const ElemInfo * const,
    2136             :                               const ElemInfo * const &,
    2137             :                               const ElemInfo * const *>(d, e, p)
    2138             :   {
    2139             :   }
    2140             : 
    2141             :   // The conversion-to-const ctor.  Takes a regular iterator and calls the appropriate
    2142             :   // variant_filter_iterator copy constructor.  Note that this one is *not* templated!
    2143      171074 :   const_elem_info_iterator(const MooseMesh::elem_info_iterator & rhs)
    2144      171074 :     : variant_filter_iterator<MeshBase::Predicate,
    2145             :                               const ElemInfo * const,
    2146             :                               const ElemInfo * const &,
    2147      171074 :                               const ElemInfo * const *>(rhs)
    2148             :   {
    2149      171074 :   }
    2150             : };
    2151             : 
    2152             : /**
    2153             :  * The definition of the bnd_node_iterator struct.
    2154             :  */
    2155             : struct MooseMesh::bnd_node_iterator : variant_filter_iterator<MeshBase::Predicate, BndNode *>
    2156             : {
    2157             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2158             :   template <typename PredType, typename IterType>
    2159      169414 :   bnd_node_iterator(const IterType & d, const IterType & e, const PredType & p)
    2160      169414 :     : variant_filter_iterator<MeshBase::Predicate, BndNode *>(d, e, p)
    2161             :   {
    2162      169414 :   }
    2163             : };
    2164             : 
    2165             : /**
    2166             :  * The definition of the const_bnd_node_iterator struct.  It is similar to the
    2167             :  * iterator above, but also provides an additional conversion-to-const ctor.
    2168             :  */
    2169             : struct MooseMesh::const_bnd_node_iterator : variant_filter_iterator<MeshBase::Predicate,
    2170             :                                                                     BndNode * const,
    2171             :                                                                     BndNode * const &,
    2172             :                                                                     BndNode * const *>
    2173             : {
    2174             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2175             :   template <typename PredType, typename IterType>
    2176        4074 :   const_bnd_node_iterator(const IterType & d, const IterType & e, const PredType & p)
    2177             :     : variant_filter_iterator<MeshBase::Predicate,
    2178             :                               BndNode * const,
    2179             :                               BndNode * const &,
    2180        4074 :                               BndNode * const *>(d, e, p)
    2181             :   {
    2182        4074 :   }
    2183             : 
    2184             :   // The conversion-to-const ctor.  Takes a regular iterator and calls the appropriate
    2185             :   // variant_filter_iterator copy constructor.  Note that this one is *not* templated!
    2186      164884 :   const_bnd_node_iterator(const MooseMesh::bnd_node_iterator & rhs)
    2187      164884 :     : variant_filter_iterator<MeshBase::Predicate,
    2188             :                               BndNode * const,
    2189             :                               BndNode * const &,
    2190      164884 :                               BndNode * const *>(rhs)
    2191             :   {
    2192      164884 :   }
    2193             : };
    2194             : 
    2195             : /**
    2196             :  * The definition of the bnd_elem_iterator struct.
    2197             :  */
    2198             : struct MooseMesh::bnd_elem_iterator : variant_filter_iterator<MeshBase::Predicate, BndElement *>
    2199             : {
    2200             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2201             :   template <typename PredType, typename IterType>
    2202      164848 :   bnd_elem_iterator(const IterType & d, const IterType & e, const PredType & p)
    2203      164848 :     : variant_filter_iterator<MeshBase::Predicate, BndElement *>(d, e, p)
    2204             :   {
    2205      164848 :   }
    2206             : };
    2207             : 
    2208             : /**
    2209             :  * The definition of the const_bnd_elem_iterator struct.  It is similar to the regular
    2210             :  * iterator above, but also provides an additional conversion-to-const ctor.
    2211             :  */
    2212             : struct MooseMesh::const_bnd_elem_iterator : variant_filter_iterator<MeshBase::Predicate,
    2213             :                                                                     BndElement * const,
    2214             :                                                                     BndElement * const &,
    2215             :                                                                     BndElement * const *>
    2216             : {
    2217             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    2218             :   template <typename PredType, typename IterType>
    2219             :   const_bnd_elem_iterator(const IterType & d, const IterType & e, const PredType & p)
    2220             :     : variant_filter_iterator<MeshBase::Predicate,
    2221             :                               BndElement * const,
    2222             :                               BndElement * const &,
    2223             :                               BndElement * const *>(d, e, p)
    2224             :   {
    2225             :   }
    2226             : 
    2227             :   // The conversion-to-const ctor.  Takes a regular iterator and calls the appropriate
    2228             :   // variant_filter_iterator copy constructor.  Note that this one is *not* templated!
    2229      164540 :   const_bnd_elem_iterator(const bnd_elem_iterator & rhs)
    2230      164540 :     : variant_filter_iterator<MeshBase::Predicate,
    2231             :                               BndElement * const,
    2232             :                               BndElement * const &,
    2233      164540 :                               BndElement * const *>(rhs)
    2234             :   {
    2235      164540 :   }
    2236             : };
    2237             : 
    2238             : /**
    2239             :  * Some useful StoredRange typedefs.  These are defined *outside* the
    2240             :  * MooseMesh class to mimic the Const{Node,Elem}Range classes in libmesh.
    2241             :  */
    2242             : typedef libMesh::StoredRange<MooseMesh::const_bnd_node_iterator, const BndNode *> ConstBndNodeRange;
    2243             : typedef libMesh::StoredRange<MooseMesh::const_bnd_elem_iterator, const BndElement *>
    2244             :     ConstBndElemRange;
    2245             : 
    2246             : template <typename T>
    2247             : std::unique_ptr<T>
    2248       70012 : MooseMesh::buildTypedMesh(unsigned int dim)
    2249             : {
    2250             :   // If the requested mesh type to build doesn't match our current value for _use_distributed_mesh,
    2251             :   // then we need to make sure to make our state consistent because other objects, like the periodic
    2252             :   // boundary condition action, will be querying isDistributedMesh()
    2253       70012 :   if (_use_distributed_mesh != std::is_same<T, libMesh::DistributedMesh>::value)
    2254             :   {
    2255         801 :     if (getMeshPtr())
    2256           0 :       mooseError("A MooseMesh object is being asked to build a libMesh mesh that is a different "
    2257             :                  "parallel type than the libMesh mesh that it wraps. This is not allowed. Please "
    2258             :                  "create another MooseMesh object to wrap the new libMesh mesh");
    2259         801 :     setParallelType(MeshType<T>::value);
    2260             :   }
    2261             : 
    2262       70012 :   if (dim == libMesh::invalid_uint)
    2263             :   {
    2264      148308 :     if (isParamValid("dim"))
    2265      119916 :       dim = getParam<MooseEnum>("dim");
    2266             :     else
    2267             :       // Legacy selection of the default for the 'dim' parameter
    2268        9464 :       dim = 1;
    2269             :   }
    2270             : 
    2271       70012 :   auto mesh = std::make_unique<T>(_communicator, dim);
    2272             : 
    2273      210036 :   if (!getParam<bool>("allow_renumbering"))
    2274        2463 :     mesh->allow_renumbering(false);
    2275             : 
    2276       70012 :   mesh->allow_remote_element_removal(_allow_remote_element_removal);
    2277       70012 :   _app.attachRelationshipManagers(*mesh, *this);
    2278             : 
    2279       70012 :   if (_custom_partitioner_requested)
    2280             :   {
    2281             :     // Check of partitioner is supplied (not allowed if custom partitioner is used)
    2282        4677 :     if (!parameters().isParamSetByAddParam("partitioner"))
    2283           0 :       mooseError("If partitioner block is provided, partitioner keyword cannot be used!");
    2284             :     // Set custom partitioner
    2285        1559 :     if (!_custom_partitioner.get())
    2286           0 :       mooseError("Custom partitioner requested but not set!");
    2287        1559 :     mesh->partitioner() = _custom_partitioner->clone();
    2288             :   }
    2289             :   else
    2290       68453 :     setPartitionerHelper(mesh.get());
    2291             : 
    2292       70012 :   return mesh;
    2293           0 : }
    2294             : 
    2295             : inline bool
    2296        3698 : MooseMesh::skipDeletionRepartitionAfterRefine() const
    2297             : {
    2298        3698 :   return _skip_deletion_repartition_after_refine;
    2299             : }
    2300             : 
    2301             : inline void
    2302         868 : MooseMesh::setParallelType(ParallelType parallel_type)
    2303             : {
    2304         868 :   _parallel_type = parallel_type;
    2305         868 :   determineUseDistributedMesh();
    2306         868 : }
    2307             : 
    2308             : inline bool
    2309             : MooseMesh::hasElementID(const std::string & id_name) const
    2310             : {
    2311             :   return getMesh().has_elem_integer(id_name);
    2312             : }
    2313             : 
    2314             : inline unsigned int
    2315             : MooseMesh::getElementIDIndex(const std::string & id_name) const
    2316             : {
    2317             :   if (!hasElementID(id_name))
    2318             :     mooseError("Mesh does not have element ID for ", id_name);
    2319             :   return getMesh().get_elem_integer_index(id_name);
    2320             : }
    2321             : 
    2322             : inline bool
    2323             : MooseMesh::areElemIDsIdentical(const std::string & id_name1, const std::string & id_name2) const
    2324             : {
    2325             :   auto id1 = getElementIDIndex(id_name1);
    2326             :   auto id2 = getElementIDIndex(id_name2);
    2327             :   return _id_identical_flag[id1][id2];
    2328             : }
    2329             : 
    2330             : inline const std::vector<const FaceInfo *> &
    2331          46 : MooseMesh::faceInfo() const
    2332             : {
    2333          46 :   return _face_info;
    2334             : }
    2335             : 
    2336             : inline const std::vector<FaceInfo> &
    2337           4 : MooseMesh::allFaceInfo() const
    2338             : {
    2339           4 :   return _all_face_info;
    2340             : }
    2341             : 
    2342             : inline const std::map<boundary_id_type, std::vector<dof_id_type>> &
    2343             : MooseMesh::nodeSetNodes() const
    2344             : {
    2345             :   return _node_set_nodes;
    2346             : }
    2347             : 
    2348             : inline const std::unordered_map<std::pair<const Elem *, unsigned short int>, const Elem *> &
    2349             : MooseMesh::getLowerDElemMap() const
    2350             : {
    2351             :   return _higher_d_elem_side_to_lower_d_elem;
    2352             : }

Generated by: LCOV version 1.14