forked from idaholab/moose
/
Assembly.h
3161 lines (2750 loc) · 116 KB
/
Assembly.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 "DenseMatrix.h"
#include "MooseArray.h"
#include "MooseTypes.h"
#include "MooseVariableFE.h"
#include "ArbitraryQuadrature.h"
#include "libmesh/dense_vector.h"
#include "libmesh/enum_quadrature_type.h"
#include "libmesh/fe_type.h"
#include "libmesh/point.h"
#include "libmesh/fe_base.h"
#include "libmesh/numeric_vector.h"
#include "libmesh/elem_side_builder.h"
#include "DualRealOps.h"
#include <unordered_map>
// libMesh forward declarations
namespace libMesh
{
class DofMap;
class CouplingMatrix;
class Elem;
template <typename>
class VectorValue;
typedef VectorValue<Real> RealVectorValue;
template <typename T>
class FEGenericBase;
typedef FEGenericBase<Real> FEBase;
typedef FEGenericBase<VectorValue<Real>> FEVectorBase;
class Node;
template <typename T>
class NumericVector;
template <typename T>
class SparseMatrix;
}
// MOOSE Forward Declares
class FaceInfo;
class MooseMesh;
class ArbitraryQuadrature;
class SystemBase;
class MooseVariableFieldBase;
class MooseVariableBase;
template <typename>
class MooseVariableFE;
class MooseVariableScalar;
typedef MooseVariableFE<Real> MooseVariable;
typedef MooseVariableFE<RealVectorValue> VectorMooseVariable;
typedef MooseVariableFE<RealEigenVector> ArrayMooseVariable;
class XFEMInterface;
class SubProblem;
class NodeFaceConstraint;
/// Computes a conversion multiplier for use when computing integraals for the
/// current coordinate system type. This allows us to handle cases where we use RZ,
/// spherical, or other non-cartesian coordinate systems. The factor returned
/// by this function should generally be multiplied against all integration
/// terms. Note that the computed factor is particular to a specific point on
/// the mesh. The result is stored in the factor argument. point is the point
/// at which to compute the factor. point and factor can be either Point and
/// Real or ADPoint and ADReal.
template <typename P, typename C>
void coordTransformFactor(const SubProblem & s,
SubdomainID sub_id,
const P & point,
C & factor,
SubdomainID neighbor_sub_id = libMesh::Elem::invalid_subdomain_id);
template <typename P, typename C>
void coordTransformFactor(const MooseMesh & mesh,
SubdomainID sub_id,
const P & point,
C & factor,
SubdomainID neighbor_sub_id = libMesh::Elem::invalid_subdomain_id);
/**
* Keeps track of stuff related to assembling
*
*/
class Assembly
{
public:
Assembly(SystemBase & sys, THREAD_ID tid);
virtual ~Assembly();
/**
* Workaround for C++ compilers thinking they can't just cast a
* const-reference-to-pointer to const-reference-to-const-pointer
*/
template <typename T>
static const T * const & constify_ref(T * const & inref)
{
const T * const * ptr = &inref;
return *ptr;
}
/**
* Get a reference to a pointer that will contain the current volume FE.
* @param type The type of FE
* @param dim The dimension of the current volume
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEBase * const & getFE(FEType type, unsigned int dim) const
{
buildFE(type);
return constify_ref(_fe[dim][type]);
}
/**
* Get a reference to a pointer that will contain the current 'neighbor' FE.
* @param type The type of FE
* @param dim The dimension of the current volume
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEBase * const & getFENeighbor(FEType type, unsigned int dim) const
{
buildNeighborFE(type);
return constify_ref(_fe_neighbor[dim][type]);
}
/**
* Get a reference to a pointer that will contain the current "face" FE.
* @param type The type of FE
* @param dim The dimension of the current face
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEBase * const & getFEFace(FEType type, unsigned int dim) const
{
buildFaceFE(type);
return constify_ref(_fe_face[dim][type]);
}
/**
* Get a reference to a pointer that will contain the current "neighbor" FE.
* @param type The type of FE
* @param dim The dimension of the neighbor face
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEBase * const & getFEFaceNeighbor(FEType type, unsigned int dim) const
{
buildFaceNeighborFE(type);
return constify_ref(_fe_face_neighbor[dim][type]);
}
/**
* Get a reference to a pointer that will contain the current volume FEVector.
* @param type The type of FEVector
* @param dim The dimension of the current volume
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEVectorBase * const & getVectorFE(FEType type, unsigned int dim) const
{
buildVectorFE(type);
return constify_ref(_vector_fe[dim][type]);
}
/**
* GetVector a reference to a pointer that will contain the current 'neighbor' FE.
* @param type The type of FE
* @param dim The dimension of the current volume
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEVectorBase * const & getVectorFENeighbor(FEType type, unsigned int dim) const
{
buildVectorNeighborFE(type);
return constify_ref(_vector_fe_neighbor[dim][type]);
}
/**
* GetVector a reference to a pointer that will contain the current "face" FE.
* @param type The type of FE
* @param dim The dimension of the current face
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEVectorBase * const & getVectorFEFace(FEType type, unsigned int dim) const
{
buildVectorFaceFE(type);
return constify_ref(_vector_fe_face[dim][type]);
}
/**
* GetVector a reference to a pointer that will contain the current "neighbor" FE.
* @param type The type of FE
* @param dim The dimension of the neighbor face
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const FEVectorBase * const & getVectorFEFaceNeighbor(FEType type, unsigned int dim) const
{
buildVectorFaceNeighborFE(type);
return constify_ref(_vector_fe_face_neighbor[dim][type]);
}
/**
* Returns the reference to the current quadrature being used
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
const QBase * const & qRule() const { return constify_ref(_current_qrule); }
/**
* Returns the reference to the current quadrature being used
* @return A _reference_ to the pointer. Make sure to store this as a reference!
*/
QBase * const & writeableQRule() { return _current_qrule; }
/**
* Returns the reference to the quadrature points
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Point> & qPoints() const { return _current_q_points; }
/**
* Returns the reference to the mortar segment element quadrature points
* @return A _reference_. Make sure to store this as a reference!
*/
const std::vector<Point> & qPointsMortar() const { return _fe_msm->get_xyz(); }
/**
* The current points in physical space where we have reinited through reinitAtPhysical()
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Point> & physicalPoints() const { return _current_physical_points; }
/**
* Returns the reference to the transformed jacobian weights
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Real> & JxW() const { return _current_JxW; }
const MooseArray<ADReal> & adJxW() const { return _ad_JxW; }
const MooseArray<ADReal> & adJxWFace() const { return _ad_JxW_face; }
const MooseArray<ADReal> & adCurvatures() const;
/**
* Returns the reference to the coordinate transformation coefficients
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Real> & coordTransformation() const { return _coord; }
/**
* Returns the reference to the coordinate transformation coefficients on the mortar segment mesh
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Real> & mortarCoordTransformation() const { return _coord_msm; }
/**
* Returns the reference to the AD version of the coordinate transformation coefficients
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<ADReal> & adCoordTransformation() const
{
// Coord values for non-cartesian coordinate systems are functions of the locations of the
// quadrature points in physical space. We also have no way of knowing whether this was called
// from a volumetric or face object so we should set both volumetric and face xyz to true
_calculate_xyz = true;
_calculate_face_xyz = true;
_calculate_ad_coord = true;
return _ad_coord;
}
/**
* Get the coordinate system type
* @return A reference to the coordinate system type
*/
const Moose::CoordinateSystemType & coordSystem() { return _coord_type; }
/**
* Returns the reference to the current quadrature being used on a current face
* @return A _reference_. Make sure to store this as a reference!
*/
const QBase * const & qRuleFace() const { return constify_ref(_current_qrule_face); }
/**
* Returns the reference to the current quadrature being used on a current face
* @return A _reference_. Make sure to store this as a reference!
*/
QBase * const & writeableQRuleFace() { return _current_qrule_face; }
/**
* Returns the reference to the current quadrature being used
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Point> & qPointsFace() const { return _current_q_points_face; }
/**
* Returns the reference to the transformed jacobian weights on a current face
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Real> & JxWFace() const { return _current_JxW_face; }
/**
* Returns the array of normals for quadrature points on a current side
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Point> & normals() const { return _current_normals; }
/**
* Returns the array of neighbor normals for quadrature points on a current side
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Point> & neighborNormals() const { return _current_neighbor_normals; }
/***
* Returns the array of normals for quadrature points on a current side
*/
const std::vector<Eigen::Map<RealDIMValue>> & mappedNormals() const { return _mapped_normals; }
/**
* Returns the array of tangents for quadrature points on a current side
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<std::vector<Point>> & tangents() const { return _current_tangents; }
/**
* Returns an integer ID of the current element given the index associated with the integer
*/
const dof_id_type & extraElemID(unsigned int id) const { return _extra_elem_ids[id]; }
/**
* Returns an integer ID of the current element given the index associated with the integer
*/
const dof_id_type & extraElemIDNeighbor(unsigned int id) const
{
return _neighbor_extra_elem_ids[id];
}
const MooseArray<ADPoint> & adNormals() const { return _ad_normals; }
const MooseArray<ADPoint> & adQPoints() const
{
_calculate_xyz = true;
return _ad_q_points;
}
const MooseArray<ADPoint> & adQPointsFace() const
{
_calculate_face_xyz = true;
return _ad_q_points_face;
}
template <bool is_ad>
const MooseArray<MooseADWrapper<Point, is_ad>> & genericQPoints() const;
/**
* Return the current element
* @return A _reference_. Make sure to store this as a reference!
*/
const Elem * const & elem() const { return _current_elem; }
/**
* Return the current subdomain ID
*/
const SubdomainID & currentSubdomainID() const { return _current_subdomain_id; }
/**
* set the current subdomain ID
*/
void setCurrentSubdomainID(SubdomainID i) { _current_subdomain_id = i; }
/**
* Return the current boundary ID
*/
const BoundaryID & currentBoundaryID() const { return _current_boundary_id; }
/**
* set the current boundary ID
*/
void setCurrentBoundaryID(BoundaryID i) { _current_boundary_id = i; }
/**
* Returns the reference to the current element volume
* @return A _reference_. Make sure to store this as a reference!
*/
const Real & elemVolume() { return _current_elem_volume; }
/**
* Returns the current side
* @return A _reference_. Make sure to store this as a reference!
*/
const unsigned int & side() const { return _current_side; }
/**
* Returns the current neighboring side
* @return A _reference_. Make sure to store this as a reference!
*/
const unsigned int & neighborSide() const { return _current_neighbor_side; }
/**
* Returns the side element
* @return A _reference_. Make sure to store this as a reference!
*/
const Elem *& sideElem() { return _current_side_elem; }
/**
* Returns the reference to the volume of current side element
* @return A _reference_. Make sure to store this as a reference!
*/
const Real & sideElemVolume() { return _current_side_volume; }
/**
* Return the neighbor element
* @return A _reference_. Make sure to store this as a reference!
*/
const Elem * const & neighbor() const { return _current_neighbor_elem; }
/**
* Return the lower dimensional element
* @return A _reference_. Make sure to store this as a reference!
*/
const Elem * const & lowerDElem() const { return _current_lower_d_elem; }
/**
* Return the neighboring lower dimensional element
* @return A _reference_. Make sure to store this as a reference!
*/
const Elem * const & neighborLowerDElem() const { return _current_neighbor_lower_d_elem; }
/*
* @return The current lower-dimensional element volume
*/
const Real & lowerDElemVolume() const;
/*
* @return The current neighbor lower-dimensional element volume
*/
const Real & neighborLowerDElemVolume() const;
/**
* Return the current subdomain ID
*/
const SubdomainID & currentNeighborSubdomainID() const { return _current_neighbor_subdomain_id; }
/**
* set the current subdomain ID
*/
void setCurrentNeighborSubdomainID(SubdomainID i) { _current_neighbor_subdomain_id = i; }
/**
* Returns the reference to the current neighbor volume
* @return A _reference_. Make sure to store this as a reference!
*/
const Real & neighborVolume()
{
_need_neighbor_elem_volume = true;
return _current_neighbor_volume;
}
/**
* Returns the reference to the current quadrature being used on a current neighbor
* @return A _reference_. Make sure to store this as a reference!
*/
const QBase * const & qRuleNeighbor() const { return constify_ref(_current_qrule_neighbor); }
/**
* Returns the reference to the current quadrature being used on a current neighbor
* @return A _reference_. Make sure to store this as a reference!
*/
QBase * const & writeableQRuleNeighbor() { return _current_qrule_neighbor; }
/**
* Returns the reference to the transformed jacobian weights on a current face
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Real> & JxWNeighbor() const;
/**
* Returns the reference to the current quadrature points being used on the neighbor face
* @return A _reference_. Make sure to store this as a reference!
*/
const MooseArray<Point> & qPointsFaceNeighbor() const { return _current_q_points_face_neighbor; }
/**
* Returns the reference to the node
* @return A _reference_. Make sure to store this as a reference!
*/
const Node * const & node() const { return _current_node; }
/**
* Returns the reference to the neighboring node
* @return A _reference_. Make sure to store this as a reference!
*/
const Node * const & nodeNeighbor() const { return _current_neighbor_node; }
/**
* Creates block-specific volume, face and arbitrary qrules based on the
* orders and the flag of whether or not to allow negative qweights passed in.
* Any quadrature rules specified using this function override those created
* via in the non-block-specific/global createQRules function. order is used
* for arbitrary volume quadrature rules, while volume_order and face_order
* are for elem and face quadrature respectively.
*/
void createQRules(QuadratureType type,
Order order,
Order volume_order,
Order face_order,
SubdomainID block,
bool allow_negative_qweights = true);
/**
* Increases the element/volume quadrature order for the specified mesh
* block if and only if the current volume quadrature order is lower. This
* works exactly like the bumpAllQRuleOrder function, except it only
* affects the volume quadrature rule (not face quadrature).
*/
void bumpVolumeQRuleOrder(Order volume_order, SubdomainID block);
/**
* Increases the element/volume and face/area quadrature orders for the specified mesh
* block if and only if the current volume or face quadrature order is lower. This
* can only cause the quadrature level to increase. If order is
* lower than or equal to the current volume+face quadrature rule order,
* then nothing is done (i.e. this function is idempotent).
*/
void bumpAllQRuleOrder(Order order, SubdomainID block);
/**
* Set the qrule to be used for volume integration.
*
* Note: This is normally set internally, only use if you know what you are doing!
*
* @param qrule The qrule you want to set
* @param dim The spatial dimension of the qrule
*/
void setVolumeQRule(QBase * qrule, unsigned int dim);
/**
* Set the qrule to be used for face integration.
*
* Note: This is normally set internally, only use if you know what you are doing!
*
* @param qrule The qrule you want to set
* @param dim The spatial dimension of the qrule
*/
void setFaceQRule(QBase * qrule, unsigned int dim);
/**
* Specifies a custom qrule for integration on mortar segment mesh
*
* Used to properly integrate QUAD face elements using quadrature on TRI mortar segment elements.
* For example, to exactly integrate a FIRST order QUAD element, SECOND order quadrature on TRI
* mortar segments is needed.
*/
void setMortarQRule(Order order);
/**
* Indicates that dual shape functions are used for mortar constraint
*/
void activateDual() { _need_dual = true; }
/**
* Indicates whether dual shape functions are used (computation is now repeated on each element
* so expense of computing dual shape functions is no longer trivial)
*/
bool needDual() const { return _need_dual; }
/**
* Set the cached quadrature rules to nullptr
*/
void clearCachedQRules();
private:
/**
* Set the qrule to be used for lower dimensional integration.
*
* @param qrule The qrule you want to set
* @param dim The spatial dimension of the qrule
*/
void setLowerQRule(QBase * qrule, unsigned int dim);
public:
/**
* Set the qrule to be used for neighbor integration.
*
* Note: This is normally set internally, only use if you know what you are doing!
*
* @param qrule The qrule you want to set
* @param dim The spatial dimension of the qrule
*/
void setNeighborQRule(QBase * qrule, unsigned int dim);
/**
* Reinitialize objects (JxW, q_points, ...) for an elements
*
* @param elem The element we want to reinitialize on
*/
void reinit(const Elem * elem);
/**
* Set the volumetric quadrature rule based on the provided element
*/
void setVolumeQRule(const Elem * elem);
/**
* Reinitialize FE data for the given element on the given side, optionally
* with a given set of reference points
*/
void reinitElemFaceRef(const Elem * elem,
unsigned int elem_side,
Real tolerance,
const std::vector<Point> * const pts = nullptr,
const std::vector<Real> * const weights = nullptr);
/**
* Reinitialize FE data for the given neighbor_element on the given side with a given set of
* reference points
*/
void reinitNeighborFaceRef(const Elem * neighbor_elem,
unsigned int neighbor_side,
Real tolerance,
const std::vector<Point> * const pts,
const std::vector<Real> * const weights = nullptr);
/**
* Reintialize dual basis coefficients based on a customized quadrature rule
*/
void reinitDual(const Elem * elem, const std::vector<Point> & pts, const std::vector<Real> & JxW);
/**
* Reinitialize FE data for a lower dimenesional element with a given set of reference points
*/
void reinitLowerDElem(const Elem * elem,
const std::vector<Point> * const pts = nullptr,
const std::vector<Real> * const weights = nullptr);
/**
* reinitialize a neighboring lower dimensional element
*/
void reinitNeighborLowerDElem(const Elem * elem);
/**
* reinitialize a mortar segment mesh element in order to get a proper JxW
*/
void reinitMortarElem(const Elem * elem);
/**
* Returns a reference to JxW for mortar segment elements
*/
const std::vector<Real> & jxWMortar() const { return *_JxW_msm; }
/**
* Returns a reference to the quadrature rule for the mortar segments
*/
const QBase * const & qRuleMortar() const { return constify_ref(_qrule_msm); }
private:
/**
* compute AD things on an element face
*/
void computeADFace(const Elem & elem, const unsigned int side);
public:
/**
* Reinitialize the assembly data at specific physical point in the given element.
*/
void reinitAtPhysical(const Elem * elem, const std::vector<Point> & physical_points);
/**
* Reinitialize the assembly data at specific points in the reference element.
*/
void reinit(const Elem * elem, const std::vector<Point> & reference_points);
/**
* Set the face quadrature rule based on the provided element and side
*/
void setFaceQRule(const Elem * const elem, const unsigned int side);
/**
* Reinitialize the assembly data on an side of an element
*/
void reinit(const Elem * elem, unsigned int side);
/**
* Reinitialize the assembly data on the side of a element at the custom reference points
*/
void reinit(const Elem * elem, unsigned int side, const std::vector<Point> & reference_points);
void reinitFVFace(const FaceInfo & fi);
/**
* Reinitialize an element and its neighbor along a particular side.
*
* @param elem Element being reinitialized
* @param side Side of the element
* @param neighbor Neighbor facing the element on the side 'side'
* @param neighbor_side The side id on the neighboring element.
* @param neighbor_reference_points Optional argument specifying the neighbor reference points. If
* not passed, then neighbor reference points will be determined by doing an inverse map based on
* the physical location of the \p elem quadrature points
*/
void reinitElemAndNeighbor(const Elem * elem,
unsigned int side,
const Elem * neighbor,
unsigned int neighbor_side,
const std::vector<Point> * neighbor_reference_points = nullptr);
/**
* Reinitializes the neighbor at the physical coordinates on neighbor side given.
*/
void reinitNeighborAtPhysical(const Elem * neighbor,
unsigned int neighbor_side,
const std::vector<Point> & physical_points);
/**
* Reinitializes the neighbor at the physical coordinates within element given.
*/
void reinitNeighborAtPhysical(const Elem * neighbor, const std::vector<Point> & physical_points);
void reinitNeighbor(const Elem * neighbor, const std::vector<Point> & reference_points);
/**
* Reinitialize assembly data for a node
*/
void reinit(const Node * node);
/**
* Initialize the Assembly object and set the CouplingMatrix for use throughout.
*/
void init(const CouplingMatrix * cm);
/// Create pair of variables requiring nonlocal jacobian contributions
void initNonlocalCoupling();
/// Sizes and zeroes the Jacobian blocks used for the current element
void prepareJacobianBlock();
/// Sizes and zeroes the residual for the current element
void prepareResidual();
void prepare();
void prepareNonlocal();
/**
* Used for preparing the dense residual and jacobian blocks for one particular variable.
*
* @param var The variable that needs to have its datastructures prepared
*/
void prepareVariable(MooseVariableFieldBase * var);
void prepareVariableNonlocal(MooseVariableFieldBase * var);
void prepareNeighbor();
/**
* Prepare the Jacobians and residuals for a lower dimensional element. This method may be called
* when performing mortar finite element simulations
*/
void prepareLowerD();
void prepareBlock(unsigned int ivar, unsigned jvar, const std::vector<dof_id_type> & dof_indices);
void prepareBlockNonlocal(unsigned int ivar,
unsigned jvar,
const std::vector<dof_id_type> & idof_indices,
const std::vector<dof_id_type> & jdof_indices);
void prepareScalar();
void prepareOffDiagScalar();
template <typename T>
void copyShapes(MooseVariableField<T> & v);
void copyShapes(unsigned int var);
template <typename T>
void copyFaceShapes(MooseVariableField<T> & v);
void copyFaceShapes(unsigned int var);
template <typename T>
void copyNeighborShapes(MooseVariableField<T> & v);
void copyNeighborShapes(unsigned int var);
/**
* Key structure for APIs manipulating global vectors/matrices. Developers in blessed classes may
* create keys using simple curly braces \p {} or may be more explicit and use \p
* Assembly::GlobalDataKey{}
*/
class GlobalDataKey
{
// Blessed classes
friend class Assembly;
friend class SubProblem;
friend class FEProblemBase;
friend class DisplacedProblem;
friend class ComputeMortarFunctor;
friend class NonlinearSystemBase;
GlobalDataKey() {}
GlobalDataKey(const GlobalDataKey &) {}
};
/**
* Key structure for APIs adding/caching local element residuals/Jacobians. Developers in blessed
* classes may create keys using simple curly braces \p {} or may be more explicit and use \p
* Assembly::LocalDataKey{}
*/
class LocalDataKey
{
// Blessed classes
friend class Assembly;
friend class TaggingInterface;
LocalDataKey() {}
LocalDataKey(const LocalDataKey &) {}
};
/**
* Add local residuals of all field variables for a set of tags onto the global residual vectors
* associated with the tags.
*/
void addResidual(GlobalDataKey, const std::vector<VectorTag> & vector_tags);
/**
* Add local neighbor residuals of all field variables for a set of tags onto the global residual
* vectors associated with the tags.
*/
void addResidualNeighbor(GlobalDataKey, const std::vector<VectorTag> & vector_tags);
/**
* Add local neighbor residuals of all field variables for a set of tags onto the global residual
* vectors associated with the tags.
*/
void addResidualLower(GlobalDataKey, const std::vector<VectorTag> & vector_tags);
/**
* Add residuals of all scalar variables for a set of tags onto the global residual vectors
* associated with the tags.
*/
void addResidualScalar(GlobalDataKey, const std::vector<VectorTag> & vector_tags);
/**
* Takes the values that are currently in _sub_Re of all field variables and appends them to
* the cached values.
*/
void cacheResidual(GlobalDataKey, const std::vector<VectorTag> & tags);
/**
* Takes the values that are currently in _sub_Rn of all field variables and appends them to
* the cached values.
*/
void cacheResidualNeighbor(GlobalDataKey, const std::vector<VectorTag> & tags);
/**
* Takes the values that are currently in _sub_Rl and appends them to the cached values.
*/
void cacheResidualLower(GlobalDataKey, const std::vector<VectorTag> & tags);
/**
* Pushes all cached residuals to the global residual vectors associated with each tag.
*
* Note that this will also clear the cache.
*/
void addCachedResiduals(GlobalDataKey, const std::vector<VectorTag> & tags);
/**
* Clears all of the residuals in _cached_residual_rows and _cached_residual_values
*
* This method is designed specifically for use after calling
* FEProblemBase::addCachedResidualDirectly() and DisplacedProblem::addCachedResidualDirectly() to
* ensure that we don't have any extra residuals hanging around that we didn't have the vectors
* for
*/
void clearCachedResiduals(GlobalDataKey);
/**
* Adds the values that have been cached by calling cacheResidual(), cacheResidualNeighbor(),
* and/or cacheResidualLower() to a user-defined residual (that is, not necessarily the vector
* that vector_tag points to)
*
* Note that this will also clear the cache.
*/
void addCachedResidualDirectly(NumericVector<Number> & residual,
GlobalDataKey,
const VectorTag & vector_tag);
/**
* Sets local residuals of all field variables to the global residual vector for a tag.
*/
void setResidual(NumericVector<Number> & residual, GlobalDataKey, const VectorTag & vector_tag);
/**
* Sets local neighbor residuals of all field variables to the global residual vector for a tag.
*/
void setResidualNeighbor(NumericVector<Number> & residual,
GlobalDataKey,
const VectorTag & vector_tag);
/**
* Adds all local Jacobian to the global Jacobian matrices.
*/
void addJacobian(GlobalDataKey);
/**
* Adds non-local Jacobian to the global Jacobian matrices.
*/
void addJacobianNonlocal(GlobalDataKey);
/**
* Add ElementNeighbor, NeighborElement, and NeighborNeighbor portions of the Jacobian for compute
* objects like DGKernels
*/
void addJacobianNeighbor(GlobalDataKey);
/**
* Add Jacobians for pairs of scalar variables into the global Jacobian matrices.
*/
void addJacobianScalar(GlobalDataKey);
/**
* Add Jacobians for a scalar variables with all other field variables into the global Jacobian
* matrices.
*/
void addJacobianOffDiagScalar(unsigned int ivar, GlobalDataKey);
/**
* Adds element matrix for ivar rows and jvar columns to the global Jacobian matrix.
*/
void addJacobianBlock(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,
const DofMap & dof_map,
std::vector<dof_id_type> & dof_indices,
GlobalDataKey,
TagID tag);
/**
* Add element matrix for ivar rows and jvar columns to the global Jacobian matrix for given
* tags.
*/
void addJacobianBlockTags(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,
const DofMap & dof_map,
std::vector<dof_id_type> & dof_indices,
GlobalDataKey,
const std::set<TagID> & tags);
/**
* Adds non-local element matrix for ivar rows and jvar columns to the global Jacobian matrix.
*/
void addJacobianBlockNonlocal(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,
const DofMap & dof_map,
const std::vector<dof_id_type> & idof_indices,
const std::vector<dof_id_type> & jdof_indices,
GlobalDataKey,
TagID tag);
/**
* Adds non-local element matrix for ivar rows and jvar columns to the global Jacobian matrix.
*/
void addJacobianBlockNonlocalTags(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,
const DofMap & dof_map,
const std::vector<dof_id_type> & idof_indices,
const std::vector<dof_id_type> & jdof_indices,
GlobalDataKey,
const std::set<TagID> & tags);
/**
* Add *all* portions of the Jacobian except PrimaryPrimary, e.g. LowerLower, LowerSecondary,
* LowerPrimary, SecondaryLower, SecondarySecondary, SecondaryPrimary, PrimaryLower,
* PrimarySecondary, for mortar-like objects. Primary indicates the interior parent element on the
* primary side of the mortar interface. Secondary indicates the neighbor of the interior parent
* element. Lower denotes the lower-dimensional element living on the primary side of the mortar
* interface.
*/
void addJacobianNeighborLowerD(GlobalDataKey);
/**
* Add portions of the Jacobian of LowerLower, LowerSecondary, and SecondaryLower for
* boundary conditions. Secondary indicates the boundary element. Lower denotes the
* lower-dimensional element living on the boundary side.
*/
void addJacobianLowerD(GlobalDataKey);
/**
* Cache *all* portions of the Jacobian, e.g. LowerLower, LowerSecondary, LowerPrimary,
* SecondaryLower, SecondarySecondary, SecondaryPrimary, PrimaryLower, PrimarySecondary,
* PrimaryPrimary for mortar-like objects. Primary indicates the interior parent element on the
* primary side of the mortar interface. Secondary indicates the interior parent element on the
* secondary side of the interface. Lower denotes the lower-dimensional element living on the
* secondary side of the mortar interface; it's the boundary face of the \p Secondary element.
*/
void cacheJacobianMortar(GlobalDataKey);
/**
* Adds three neighboring element matrices for ivar rows and jvar columns to the global Jacobian
* matrix.
*/
void addJacobianNeighbor(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,