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