forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MooseMesh.h
1526 lines (1297 loc) · 54.7 KB
/
MooseMesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "MooseObject.h"
#include "BndNode.h"
#include "BndElement.h"
#include "Restartable.h"
#include "MooseEnum.h"
#include "PerfGraphInterface.h"
#include "MooseHashing.h"
#include <memory> //std::unique_ptr
#include <unordered_map>
#include <unordered_set>
// libMesh
#include "libmesh/elem_range.h"
#include "libmesh/mesh_base.h"
#include "libmesh/node_range.h"
#include "libmesh/nanoflann.hpp"
#include "libmesh/vector_value.h"
#include "libmesh/point.h"
// forward declaration
class MooseMesh;
class Assembly;
class RelationshipManager;
// libMesh forward declarations
namespace libMesh
{
class ExodusII_IO;
class QBase;
class PeriodicBoundaries;
class Partitioner;
class GhostingFunctor;
class BoundingBox;
}
// Useful typedefs
typedef StoredRange<std::set<Node *>::iterator, Node *> SemiLocalNodeRange;
template <>
InputParameters validParams<MooseMesh>();
/**
* Helper object for holding qp mapping info.
*/
class QpMap
{
public:
QpMap() : _distance(std::numeric_limits<Real>::max()) {}
/// The qp to map from
unsigned int _from;
/// The qp to map to
unsigned int _to;
/// The distance between them
Real _distance;
};
/// This data structure is used to store geometric and variable related
/// metadata about each cell face in the mesh. This info is used by face loops
/// (e.g. for finite volumes method numerical flux loop). These objects can be
/// created and cached up front. Since it only stores information that changes
/// when the mesh is modified it only needs an update whenever the mesh
/// changes.
class FaceInfo
{
public:
FaceInfo(const Elem * elem, unsigned int side, const Elem * neighbor);
/// This enum is used to indicate which side(s) of a face a particular
/// variable is defined on. This is important for certain BC-related finite
/// volume calculations. Because of the way side-sets and variable
/// block-restriction work in MOOSE, there may be boundary conditions applied
/// to internal faces on the mesh where a variable is only active on one or
/// even zero sides of the face. For such faces, FV needs to know which
/// sides (if any) to add BC residual contributions to.
enum class VarFaceNeighbors
{
BOTH,
NEITHER,
ELEM,
NEIGHBOR
};
/// Returns the face area of face id
Real faceArea() const { return _face_area; }
/// Sets/gets the coordinate transformation factor (for e.g. rz, spherical
/// coords) to be used for integration over faces.
Real & faceCoord() { return _face_coord; }
Real faceCoord() const { return _face_coord; }
/// Returns the unit normal vector for the face oriented outward from the face's elem element.
const Point & normal() const { return _normal; }
/// Returns true if this face resides on the mesh boundary.
bool isBoundary() const { return (_neighbor == nullptr); }
/// Returns the coordinates of the face centroid.
const Point & faceCentroid() const { return _face_centroid; }
///@{
/// Returns the elem and neighbor elements adjacent to the face.
/// If a face is on a mesh boundary, the neighborPtr
/// will return nullptr - the elem will never be null.
const Elem & elem() const { return *_elem; }
const Elem * neighborPtr() const { return _neighbor; }
const Elem & neighbor() const
{
if (!_neighbor)
mooseError("FaceInfo object 'const Elem & neighbor()' is called but neighbor element pointer "
"is null. This occurs for faces at the domain boundary");
return *_neighbor;
}
///@}
/// Returns the element centroids of the elements on the elem and neighbor sides of the face.
/// If no neighbor face is defined, a "ghost" neighbor centroid is calculated by
/// reflecting/extrapolating from the elem centroid through the face centroid
/// - i.e. the vector from the elem element centroid to the face centroid is
/// doubled in length. The tip of this new vector is the neighbor centroid.
/// This is important for FV dirichlet BCs.
const Point & elemCentroid() const { return _elem_centroid; }
const Point & neighborCentroid() const { return _neighbor_centroid; }
///@}
///@{
/// Returns the elem and neighbor centroids. If no neighbor element exists, then
/// the maximum unsigned int is returned for the neighbor side ID.
unsigned int elemSideID() const { return _elem_side_id; }
unsigned int neighborSideID() const { return _neighbor_side_id; }
///@}
///@{
/// This is just a convenient cache of DOF indices (into the solution
/// vector) associated with each variable on this face.
const std::vector<dof_id_type> & elemDofIndices(const std::string & var_name) const
{
auto it = _elem_dof_indices.find(var_name);
if (it == _elem_dof_indices.end())
mooseError("Variable ", var_name, " not found in FaceInfo object");
return it->second;
}
std::vector<dof_id_type> & elemDofIndices(const std::string & var_name)
{
return _elem_dof_indices[var_name];
}
const std::vector<dof_id_type> & neighborDofIndices(const std::string & var_name) const
{
auto it = _neighbor_dof_indices.find(var_name);
if (it == _neighbor_dof_indices.end())
mooseError("Variable ", var_name, " not found in FaceInfo object");
return it->second;
}
std::vector<dof_id_type> & neighborDofIndices(const std::string & var_name)
{
return _neighbor_dof_indices[var_name];
}
///@}
/// Returns which side(s) the given variable is defined on for this face.
VarFaceNeighbors faceType(const std::string & var_name) const
{
auto it = _face_types_by_var.find(var_name);
if (it == _face_types_by_var.end())
mooseError("Variable ", var_name, " not found in variable to VarFaceNeighbors map");
return it->second;
}
/// Mutably returns which side(s) the given variable is defined on for this face.
VarFaceNeighbors & faceType(const std::string & var_name) { return _face_types_by_var[var_name]; }
const std::set<BoundaryID> & boundaryIDs() const { return _boundary_ids; }
/// Returns the set of boundary ids for all boundaries that include this face.
std::set<BoundaryID> & boundaryIDs() { return _boundary_ids; }
private:
Real _face_area;
Real _face_coord = 0;
Real _elem_volume;
Real _neighbor_volume;
Point _normal;
/// the elem and neighbor elems
const Elem * _elem;
const Elem * _neighbor;
/// the elem and neighbor local side ids
unsigned int _elem_side_id;
unsigned int _neighbor_side_id;
Point _elem_centroid;
Point _neighbor_centroid;
Point _face_centroid;
/// cached locations of variables in solution vectors
/// TODO: make this more efficient by not using a map if possible
std::map<std::string, std::vector<dof_id_type>> _elem_dof_indices;
std::map<std::string, std::vector<dof_id_type>> _neighbor_dof_indices;
/// a map that provides the information what face type this is for each variable
std::map<std::string, VarFaceNeighbors> _face_types_by_var;
/// the set of boundary ids that this face is associated with
std::set<BoundaryID> _boundary_ids;
};
/**
* MooseMesh wraps a libMesh::Mesh object and enhances its capabilities
* by caching additional data and storing more state.
*/
class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterface
{
public:
/**
* Typical "Moose-style" constructor and copy constructor.
*/
static InputParameters validParams();
MooseMesh(const InputParameters & parameters);
MooseMesh(const MooseMesh & other_mesh);
MooseMesh() = delete;
MooseMesh & operator=(const MooseMesh & other_mesh) = delete;
virtual ~MooseMesh();
// The type of libMesh::MeshBase that will be used
enum class ParallelType
{
DEFAULT,
REPLICATED,
DISTRIBUTED
};
/**
* Clone method. Allocates memory you are responsible to clean up.
*/
virtual MooseMesh & clone() const;
/**
* A safer version of the clone() method that hands back an
* allocated object wrapped in a smart pointer. This makes it much
* less likely that the caller will leak the memory in question.
*/
virtual std::unique_ptr<MooseMesh> safeClone() const = 0;
/**
* Method to construct a libMesh::MeshBase object that is normally set and used by the MooseMesh
* object during the "init()" phase.
*/
std::unique_ptr<MeshBase> buildMeshBaseObject(ParallelType override_type = ParallelType::DEFAULT);
/**
* Method to set the mesh_base object. If this method is NOT called prior to calling init(), a
* MeshBase object will be automatically constructed and set.
*/
void setMeshBase(std::unique_ptr<MeshBase> mesh_base);
/**
* Initialize the Mesh object. Most of the time this will turn around
* and call build_mesh so the child class can build the Mesh object.
*
* However, during Recovery this will read the CPA file...
*/
virtual void init();
/**
* Must be overridden by child classes.
*
* This is where the Mesh object is actually created and filled in.
*/
virtual void buildMesh() = 0;
/**
* Returns MeshBase::mesh_dimsension(), (not
* MeshBase::spatial_dimension()!) of the underlying libMesh mesh
* object.
*/
virtual unsigned int dimension() const;
/**
* Returns the effective spatial dimension determined by the coordinates actually used by the
* mesh. This means that a 1D mesh that has non-zero z or y coordinates is actually a 2D or 3D
* mesh, respectively. Likewise a 2D mesh that has non-zero z coordinates is actually 3D mesh.
*/
virtual unsigned int effectiveSpatialDimension() const;
/**
* Returns a vector of boundary IDs for the requested element on the
* requested side.
*/
std::vector<BoundaryID> getBoundaryIDs(const Elem * const elem,
const unsigned short int side) const;
/**
* Returns a const pointer to a lower dimensional element that
* corresponds to a side of a higher dimensional element. This
* relationship is established through an internal_parent; if there is
* no lowerDElem, nullptr is returned.
*/
const Elem * getLowerDElem(const Elem *, unsigned short int) const;
/**
* Returns a const reference to a set of all user-specified
* boundary IDs. On a distributed mesh this will *only* include
* boundary IDs which exist on local or ghosted elements; a copy and
* a call to _communicator.set_union() will be necessary to get the
* global ID set.
*/
const std::set<BoundaryID> & getBoundaryIDs() const;
/**
* Calls BoundaryInfo::build_node_list()/build_side_list() and *makes separate copies* of
* Nodes/Elems in those lists.
*
* Allocates memory which is cleaned up in the freeBndNodes()/freeBndElems() functions.
*/
void buildNodeList();
void buildBndElemList();
/**
* If not already created, creates a map from every node to all
* elements to which they are connected.
*/
const std::map<dof_id_type, std::vector<dof_id_type>> & nodeToElemMap();
/**
* If not already created, creates a map from every node to all
* _active_ _semilocal_ elements to which they are connected.
* Semilocal elements include local elements and elements that share at least
* one node with a local element.
* \note Extra ghosted elements are not included in this map!
*/
const std::map<dof_id_type, std::vector<dof_id_type>> & nodeToActiveSemilocalElemMap();
/**
* These structs are required so that the bndNodes{Begin,End} and
* bndElems{Begin,End} functions work...
*/
struct bnd_node_iterator;
struct const_bnd_node_iterator;
struct bnd_elem_iterator;
struct const_bnd_elem_iterator;
/**
* Return iterators to the beginning/end of the boundary nodes list.
*/
virtual bnd_node_iterator bndNodesBegin();
virtual bnd_node_iterator bndNodesEnd();
/**
* Return iterators to the beginning/end of the boundary elements list.
*/
virtual bnd_elem_iterator bndElemsBegin();
virtual bnd_elem_iterator bndElemsEnd();
/**
* Calls BoundaryInfo::build_node_list_from_side_list().
*/
void buildNodeListFromSideList();
/**
* Calls BoundaryInfo::build_side_list().
* Fills in the three passed vectors with list logical (element, side, id) tuples.
* This function will eventually be deprecated in favor of the one below, which
* returns a single std::vector of (elem-id, side-id, bc-id) tuples instead.
*/
void buildSideList(std::vector<dof_id_type> & el,
std::vector<unsigned short int> & sl,
std::vector<boundary_id_type> & il);
/**
* As above, but uses the non-deprecated std::tuple interface.
*/
std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>> buildSideList();
/**
* Calls BoundaryInfo::build_active_side_list
* @return A container of active (element, side, id) tuples.
*/
std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>> buildActiveSideList();
/**
* Calls BoundaryInfo::side_with_boundary_id().
*/
unsigned int sideWithBoundaryID(const Elem * const elem, const BoundaryID boundary_id) const;
/**
* Calls local_nodes_begin/end() on the underlying libMesh mesh object.
*/
MeshBase::const_node_iterator localNodesBegin();
MeshBase::const_node_iterator localNodesEnd();
/**
* Calls active_local_nodes_begin/end() on the underlying libMesh mesh object.
*/
MeshBase::const_element_iterator activeLocalElementsBegin();
const MeshBase::const_element_iterator activeLocalElementsEnd();
/**
* Calls n_nodes/elem() on the underlying libMesh mesh object.
*/
virtual dof_id_type nNodes() const;
virtual dof_id_type nElem() const;
/**
* Calls max_node/elem_id() on the underlying libMesh mesh object.
* This may be larger than n_nodes/elem() in cases where the id
* numbering is not contiguous.
*/
virtual dof_id_type maxNodeId() const;
virtual dof_id_type maxElemId() const;
/**
* Various accessors (pointers/references) for Node "i".
*
* If the requested node is a remote node on a distributed mesh,
* only the query accessors are valid to call, and they return NULL.
*/
virtual const Node & node(const dof_id_type i) const;
virtual Node & node(const dof_id_type i);
virtual const Node & nodeRef(const dof_id_type i) const;
virtual Node & nodeRef(const dof_id_type i);
virtual const Node * nodePtr(const dof_id_type i) const;
virtual Node * nodePtr(const dof_id_type i);
virtual const Node * queryNodePtr(const dof_id_type i) const;
virtual Node * queryNodePtr(const dof_id_type i);
/**
* Various accessors (pointers/references) for Elem "i".
*
* If the requested elem is a remote element on a distributed mesh,
* only the query accessors are valid to call, and they return NULL.
*/
virtual Elem * elem(const dof_id_type i);
virtual const Elem * elem(const dof_id_type i) const;
virtual Elem * elemPtr(const dof_id_type i);
virtual const Elem * elemPtr(const dof_id_type i) const;
virtual Elem * queryElemPtr(const dof_id_type i);
virtual const Elem * queryElemPtr(const dof_id_type i) const;
/**
* Setter/getter for the _is_prepared flag.
*/
bool prepared() const;
virtual void prepared(bool state);
/**
* If this method is called, we will call libMesh's prepare_for_use method when we
* call Moose's prepare method. This should only be set when the mesh structure is changed
* by MeshModifiers (i.e. Element deletion).
*/
void needsPrepareForUse();
/**
* Declares that the MooseMesh has changed, invalidates cached data
* and rebuilds caches. Sets a flag so that clients of the
* MooseMesh also know when it has changed.
*/
void meshChanged();
/**
* Declares a callback function that is executed at the conclusion
* of meshChanged(). Ther user can implement actions required after
* changing the mesh here.
**/
virtual void onMeshChanged();
/**
* Cache information about what elements were refined and coarsened in the previous step.
*/
void cacheChangedLists();
/**
* Return a range that is suitable for threaded execution over elements that were just refined.
*
* @return The _Parent_ elements that are now set to be INACTIVE. Their _children_ are the new
* elements.
*/
ConstElemPointerRange * refinedElementRange() const;
/**
* Return a range that is suitable for threaded execution over elements that were just coarsened.
* Note that these are the _Parent_ elements that are now set to be INACTIVE. Their _children_
* are the elements that were just removed. Use coarsenedElementChildren() to get the element
* IDs for the children that were just removed for a particular parent element.
*/
ConstElemPointerRange * coarsenedElementRange() const;
/**
* Get the newly removed children element ids for an element that was just coarsened.
*
* @param elem Pointer to the parent element that was coarsened to.
* @return The child element ids in Elem::child() order.
*/
const std::vector<const Elem *> & coarsenedElementChildren(const Elem * elem) const;
/**
* Clears the "semi-local" node list and rebuilds it. Semi-local nodes
* consist of all nodes that belong to local and ghost elements.
*/
void updateActiveSemiLocalNodeRange(std::set<dof_id_type> & ghosted_elems);
/**
* Returns true if the node is semi-local
* @param node Node pointer
* @return true is the node is semi-local, false otherwise
*/
bool isSemiLocal(Node * const node) const;
///@{
/**
* Return pointers to range objects for various types of ranges
* (local nodes, boundary elems, etc.).
*/
ConstElemRange * getActiveLocalElementRange();
NodeRange * getActiveNodeRange();
SemiLocalNodeRange * getActiveSemiLocalNodeRange() const;
ConstNodeRange * getLocalNodeRange();
StoredRange<MooseMesh::const_bnd_node_iterator, const BndNode *> * getBoundaryNodeRange();
StoredRange<MooseMesh::const_bnd_elem_iterator, const BndElement *> * getBoundaryElementRange();
///@}
/**
* Returns a map of boundaries to elements.
*/
const std::unordered_map<boundary_id_type, std::unordered_set<dof_id_type>> &
getBoundariesToElems() const;
/**
* Returns a read-only reference to the set of subdomains currently
* present in the Mesh.
*/
const std::set<SubdomainID> & meshSubdomains() const;
/**
* Returns a read-only reference to the set of boundary IDs currently
* present in the Mesh.
*/
const std::set<BoundaryID> & meshBoundaryIds() const;
/**
* Returns a read-only reference to the set of sidesets currently
* present in the Mesh.
*/
const std::set<BoundaryID> & meshSidesetIds() const;
/**
* Returns a read-only reference to the set of nodesets currently
* present in the Mesh.
*/
const std::set<BoundaryID> & meshNodesetIds() const;
/**
* Sets the mapping between BoundaryID and normal vector
* Is called by AddAllSideSetsByNormals
*/
void setBoundaryToNormalMap(std::unique_ptr<std::map<BoundaryID, RealVectorValue>> boundary_map);
// DEPRECATED METHOD
void setBoundaryToNormalMap(std::map<BoundaryID, RealVectorValue> * boundary_map);
/**
* Sets the set of BoundaryIDs
* Is called by AddAllSideSetsByNormals
*/
void setMeshBoundaryIDs(std::set<BoundaryID> boundary_IDs);
/**
* Returns the normal vector associated with a given BoundaryID.
* It's only valid to call this when AddAllSideSetsByNormals is active.
*/
const RealVectorValue & getNormalByBoundaryID(BoundaryID id) const;
/**
* Calls prepare_for_use() if force=true on the underlying Mesh object, then communicates various
* boundary information on parallel meshes. Also calls update() internally.
*/
void prepare(bool force = false);
/**
* Calls buildNodeListFromSideList(), buildNodeList(), and buildBndElemList().
*/
void update();
/**
* Returns the level of uniform refinement requested (zero if AMR is disabled).
*/
unsigned int uniformRefineLevel() const;
/**
* Set uniform refinement level
*/
void setUniformRefineLevel(unsigned int);
/**
* This will add the boundary ids to be ghosted to this processor
*/
void addGhostedBoundary(BoundaryID boundary_id);
/**
* This sets the inflation amount for the bounding box for each partition for use in
* ghosting boundaries
*/
void setGhostedBoundaryInflation(const std::vector<Real> & inflation);
/**
* Return a writable reference to the set of ghosted boundary IDs.
*/
const std::set<unsigned int> & getGhostedBoundaries() const;
/**
* Return a writable reference to the _ghosted_boundaries_inflation vector.
*/
const std::vector<Real> & getGhostedBoundaryInflation() const;
/**
* Actually do the ghosting of boundaries that need to be ghosted to this processor.
*/
void ghostGhostedBoundaries();
/**
* Whether or not we want to ghost ghosted boundaries
*/
void needGhostGhostedBoundaries(bool needghost) { _need_ghost_ghosted_boundaries = needghost; }
/**
* Getter for the patch_size parameter.
*/
unsigned int getPatchSize() const;
/**
* Getter for the ghosting_patch_size parameter.
*/
unsigned int getGhostingPatchSize() const { return _ghosting_patch_size; };
/**
* Getter for the maximum leaf size parameter.
*/
unsigned int getMaxLeafSize() const { return _max_leaf_size; };
/**
* Set the patch size update strategy
*/
void setPatchUpdateStrategy(Moose::PatchUpdateType patch_update_strategy);
/**
* Get the current patch update strategy.
*/
const Moose::PatchUpdateType & getPatchUpdateStrategy() const;
/**
* Get a (slightly inflated) processor bounding box.
*
* @param inflation_multiplier This amount will be multiplied by the length of the diagonal of the
* bounding box to find the amount to inflate the bounding box by in all directions.
*/
BoundingBox getInflatedProcessorBoundingBox(Real inflation_multiplier = 0.01) const;
/**
* Implicit conversion operator from MooseMesh -> libMesh::MeshBase.
*/
operator libMesh::MeshBase &();
operator const libMesh::MeshBase &() const;
/**
* Accessor for the underlying libMesh Mesh object.
*/
MeshBase & getMesh();
const MeshBase & getMesh() const;
/**
* Not implemented -- always returns NULL.
*/
virtual ExodusII_IO * exReader() const;
/**
* Calls print_info() on the underlying Mesh.
*/
void printInfo(std::ostream & os = libMesh::out) const;
/**
* Return list of blocks to which the given node belongs.
*/
const std::set<SubdomainID> & getNodeBlockIds(const Node & node) const;
/**
* Return a writable reference to a vector of node IDs that belong
* to nodeset_id.
*/
const std::vector<dof_id_type> & getNodeList(boundary_id_type nodeset_id) const;
/**
* Add a new node to the mesh. If there is already a node located at the point passed
* then the node will not be added. In either case a reference to the node at that location
* will be returned
*/
const Node * addUniqueNode(const Point & p, Real tol = 1e-6);
/**
* Adds a fictitious "QuadratureNode". This doesn't actually add it to the libMesh mesh...
* we just keep track of these here in MooseMesh.
*
* QuadratureNodes are fictitious "Nodes" that are located at quadrature points. This is useful
* for using the geometric search system to do searches based on quadrature point locations....
*
* @param elem The element
* @param side The side number on which we want to add a quadrature node
* @param qp The number of the quadrature point
* @param bid The boundary ID for the point to be added with
* @param point The physical location of the point
*/
Node * addQuadratureNode(const Elem * elem,
const unsigned short int side,
const unsigned int qp,
BoundaryID bid,
const Point & point);
/**
* Get a specified quadrature node.
*
* @param elem The element the quadrature point is on
* @param side The side the quadrature point is on
* @param qp The quadrature point number associated with the point
*/
Node * getQuadratureNode(const Elem * elem, const unsigned short int side, const unsigned int qp);
/**
* Clear out any existing quadrature nodes.
* Most likely called before re-adding them.
*/
void clearQuadratureNodes();
/**
* Get the associated BoundaryID for the boundary name.
*
* @return param boundary_name The name of the boundary.
* @return the boundary id from the passed boundary name.
*/
BoundaryID getBoundaryID(const BoundaryName & boundary_name) const;
/**
* Get the associated BoundaryID for the boundary names that are passed in.
*
* @return param boundary_name The names of the boundaries.
* @return the boundary ids from the passed boundary names.
*/
std::vector<BoundaryID> getBoundaryIDs(const std::vector<BoundaryName> & boundary_name,
bool generate_unknown = false) const;
/**
* Get the associated subdomain ID for the subdomain name.
*
* @param subdomain_name The name of the subdomain
* @return The subdomain id from the passed subdomain name.
*/
SubdomainID getSubdomainID(const SubdomainName & subdomain_name) const;
/**
* Get the associated subdomainIDs for the subdomain names that are passed in.
*
* @param subdomain_name The names of the subdomains
* @return The subdomain ids from the passed subdomain name.
*/
std::vector<SubdomainID> getSubdomainIDs(const std::vector<SubdomainName> & subdomain_name) const;
/**
* This method sets the name for \p subdomain_id to \p name
*/
void setSubdomainName(SubdomainID subdomain_id, const SubdomainName & name);
/**
* This method sets the name for \p subdomain_id on the provided \p mesh to \p name
*/
static void
setSubdomainName(MeshBase & mesh, SubdomainID subdomain_id, const SubdomainName & name);
/**
* Return the name of a block given an id.
*/
const std::string & getSubdomainName(SubdomainID subdomain_id);
/**
* This method returns a writable reference to a boundary name based on the id parameter
*/
void setBoundaryName(BoundaryID boundary_id, BoundaryName name);
/**
* Return the name of the boundary given the id.
*/
const std::string & getBoundaryName(BoundaryID boundary_id);
/**
* This routine builds a multimap of boundary ids to matching boundary ids across all periodic
* boundaries
* in the system.
*/
void buildPeriodicNodeMap(std::multimap<dof_id_type, dof_id_type> & periodic_node_map,
unsigned int var_number,
PeriodicBoundaries * pbs) const;
/**
* This routine builds a datastructure of node ids organized by periodic boundary ids
*/
void buildPeriodicNodeSets(std::map<BoundaryID, std::set<dof_id_type>> & periodic_node_sets,
unsigned int var_number,
PeriodicBoundaries * pbs) const;
/**
* Returns the width of the requested dimension
*/
Real dimensionWidth(unsigned int component) const;
///@{
/**
* Returns the min or max of the requested dimension respectively
*/
virtual Real getMinInDimension(unsigned int component) const;
virtual Real getMaxInDimension(unsigned int component) const;
///@}
/**
* This routine determines whether the Mesh is a regular orthogonal mesh (i.e. square in 2D, cubic
* in 3D). If it is, then we can use a number of convenience functions when periodic boundary
* conditions are applied. This routine populates the _range vector which is necessary for these
* convenience functions.
*
* Note: This routine can potentially identify meshes with concave faces that still "fit" in the
* convex hull of the corresponding regular orthogonal mesh. This case is highly unlikely in
* practice and if a user does this, well.... release the kicker!
*/
bool detectOrthogonalDimRanges(Real tol = 1e-6);
/**
* For "regular orthogonal" meshes, determine if variable var_num is periodic with respect to the
* primary and secondary BoundaryIDs, record this fact in the _periodic_dim data structure.
*/
void addPeriodicVariable(unsigned int var_num, BoundaryID primary, BoundaryID secondary);
/**
* Returns whether this generated mesh is periodic in the given dimension for the given variable.
* @param nonlinear_var_num - The nonlinear variable number
* @param component - An integer representing the desired component (dimension)
*/
bool isTranslatedPeriodic(unsigned int nonlinear_var_num, unsigned int component) const;
/**
* This function returns the minimum vector between two points on the mesh taking into account
* periodicity for the given variable number.
* @param nonlinear_var_num - The nonlinear variable number
* @param p, q - The points between which to compute a minimum vector
* @return RealVectorValue - The vector pointing from p to q
*/
RealVectorValue minPeriodicVector(unsigned int nonlinear_var_num, Point p, Point q) const;
/**
* This function returns the distance between two points on the mesh taking into account
* periodicity for the given variable number.
* @param nonlinear_var_num - The nonlinear variable number
* @param p, q - The points for which to compute a minimum distance
* @return Real - The L2 distance between p and q
*/
Real minPeriodicDistance(unsigned int nonlinear_var_num, Point p, Point q) const;
/**
* This function attempts to return the paired boundary ids for the given component. For example,
* in a generated 2D mesh, passing 0 for the "x" component will return (3, 1).
* @param component - An integer representing the desired component (dimension)
* @return std::pair pointer - The matching boundary pairs for the passed component
*/
const std::pair<BoundaryID, BoundaryID> * getPairedBoundaryMapping(unsigned int component);
/**
* Create the refinement and coarsening maps necessary for projection of stateful material
* properties when using adaptivity.
*
* @param assembly Pointer to the Assembly object for this Mesh.
*/
void buildRefinementAndCoarseningMaps(Assembly * assembly);
/**
* Get the refinement map for a given element type. This will tell you what quadrature points
* to copy from and to for stateful material properties on newly created elements from Adaptivity.
*
* @param elem The element that represents the element type you need the refinement map for.
* @param parent_side The side of the parent to map (-1 if not mapping parent sides)
* @param child The child number (-1 if not mapping child internal sides)
* @param child_side The side number of the child (-1 if not mapping sides)
*/
const std::vector<std::vector<QpMap>> &
getRefinementMap(const Elem & elem, int parent_side, int child, int child_side);
/**
* Get the coarsening map for a given element type. This will tell you what quadrature points
* to copy from and to for stateful material properties on newly created elements from Adaptivity.
*
* @param elem The element that represents the element type you need the coarsening map for.
* @param input_side The side to map
*/
const std::vector<std::pair<unsigned int, QpMap>> & getCoarseningMap(const Elem & elem,
int input_side);
/**
* Change all the boundary IDs for a given side from old_id to new_id. If delete_prev is true,
* also actually remove the side with old_id from the BoundaryInfo object.
*/
void
changeBoundaryId(const boundary_id_type old_id, const boundary_id_type new_id, bool delete_prev);
/**
* Change all the boundary IDs for a given side from old_id to new_id for the given \p mesh. If
* delete_prev is true, also actually remove the side with old_id from the BoundaryInfo object.
*/
static void changeBoundaryId(MeshBase & mesh,
const boundary_id_type old_id,
const boundary_id_type new_id,
bool delete_prev);
/**
* Get the list of boundary ids associated with the given subdomain id.
*
* @param subdomain_id The subdomain ID you want to get the boundary ids for.
* @return All boundary IDs connected to elements in the give
*/
const std::set<BoundaryID> & getSubdomainBoundaryIds(SubdomainID subdomain_id) const;
/**
* Get the list of boundaries that contact the given subdomain.
*
* @param subdomain_id The subdomain ID you want to get the boundary ids for.
* @return All boundary IDs connected to elements in the given subdomain
*/
std::set<BoundaryID> getSubdomainInterfaceBoundaryIds(const SubdomainID subdomain_id) const;
/**
* Get the list of subdomains associated with the given boundary.
*
* @param subdomain_id The boundary ID you want to get the subdomain IDs for.
* @return All subdomain IDs associated with given boundary ID
*/
std::set<SubdomainID> getBoundaryConnectedBlocks(const BoundaryID bid) const;
/**
* Get the list of subdomains contacting the given boundary.
*
* @param subdomain_id The boundary ID you want to get the subdomain IDs for.
* @return All subdomain IDs contacting given boundary ID
*/
std::set<SubdomainID> getInterfaceConnectedBlocks(const BoundaryID bid) const;
/**
* Returns true if the requested node is in the list of boundary nodes, false otherwise.
*/
bool isBoundaryNode(dof_id_type node_id) const;
/**
* Returns true if the requested node is in the list of boundary nodes for the specified boundary,
* false otherwise.
*/
bool isBoundaryNode(dof_id_type node_id, BoundaryID bnd_id) const;
/**
* Returns true if the requested element is in the list of boundary elements, false otherwise.
*/
bool isBoundaryElem(dof_id_type elem_id) const;
/**
* Returns true if the requested element is in the list of boundary elements for the specified
* boundary, false otherwise.
*/
bool isBoundaryElem(dof_id_type elem_id, BoundaryID bnd_id) const;
/**
* Generate a unified error message if the underlying libMesh mesh is a DistributedMesh. Clients
* of MooseMesh can use this function to throw an error if they know they don't work with
* DistributedMesh.
*
* See, for example, the NodalVariableValue class.
*/
void errorIfDistributedMesh(std::string name) const;
/**
* Returns the final Mesh distribution type.
*/
bool isDistributedMesh() const { return _use_distributed_mesh; }
/**
* Tell the user if the distribution was overriden for any reason
*/
bool isParallelTypeForced() const { return _parallel_type_overridden; }