forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assembly.h
1898 lines (1623 loc) · 67.5 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 "MooseArray.h"
#include "MooseTypes.h"
#include "libmesh/dense_matrix.h"
#include "libmesh/dense_vector.h"
#include "libmesh/enum_quadrature_type.h"
#include "libmesh/fe_type.h"
#include "libmesh/point.h"
#include "metaphysicl/numberarray.h"
#include "metaphysicl/dualnumber.h"
// 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 MooseMesh;
class ArbitraryQuadrature;
class SystemBase;
class MooseVariableFEBase;
class MooseVariableBase;
template <typename>
class MooseVariableFE;
class MooseVariableScalar;
typedef MooseVariableFE<Real> MooseVariable;
typedef MooseVariableFE<RealVectorValue> VectorMooseVariable;
typedef MooseVariableFE<RealArrayValue> ArrayMooseVariable;
class XFEMInterface;
class SubProblem;
/**
* Keeps track of stuff related to assembling
*
*/
class Assembly
{
public:
Assembly(SystemBase & sys, THREAD_ID tid);
virtual ~Assembly();
/**
* 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 _const_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 _const_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 _const_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 _const_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 _const_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 _const_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 _const_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 _const_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 _const_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; }
/**
* 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; }
template <ComputeStage compute_stage>
const MooseArray<ADReal> & adJxW() const
{
return _ad_JxW;
}
template <ComputeStage compute_stage>
const MooseArray<ADReal> & adJxWFace() const
{
return _current_JxW_face;
}
template <ComputeStage compute_stage>
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 AD version of the coordinate transformation coefficients
* @return A _reference_. Make sure to store this as a reference!
*/
template <ComputeStage compute_stage>
const MooseArray<ADReal> & adCoordTransformation() const
{
return _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 _const_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 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; }
template <ComputeStage compute_stage>
const ADPoint & adNormals() const
{
return _current_normals;
}
template <ComputeStage compute_stage>
const ADPoint & adQPoints() const
{
return _current_q_points;
}
template <ComputeStage compute_stage>
const ADPoint & adQPointsFace() const
{
return _current_q_points_face;
}
/**
* 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; }
/**
* 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 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() const;
/**
* 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 _const_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 { return _current_JxW_neighbor; }
/**
* 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 the volume, face and arbitrary qrules based on the orders passed in.
*/
void createQRules(QuadratureType type, Order order, Order volume_order, Order face_order);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* Reinitialize FE data for a lower dimenesional element with a given set of reference points
*/
void reinitLowerDElemRef(const Elem * elem,
const std::vector<Point> * const pts,
const std::vector<Real> * const weights = nullptr);
/**
* 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 _const_qrule_msm; }
private:
/**
* compute AD things on an element face
*/
void computeADFace(const Elem * elem, 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);
/**
* 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);
/**
* 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.
*/
void reinitElemAndNeighbor(const Elem * elem,
unsigned int side,
const Elem * neighbor,
unsigned int neighbor_side);
/**
* 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);
/// Deprecated init method
void init();
/// 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(MooseVariableFEBase * var);
void prepareVariableNonlocal(MooseVariableFEBase * 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(MooseVariableFE<T> & v);
void copyShapes(unsigned int var);
template <typename T>
void copyFaceShapes(MooseVariableFE<T> & v);
void copyFaceShapes(unsigned int var);
template <typename T>
void copyNeighborShapes(MooseVariableFE<T> & v);
void copyNeighborShapes(unsigned int var);
void addResidual(NumericVector<Number> & residual, TagID tag_id = 0);
void addResidual(const std::map<TagName, TagID> & tags);
void addResidualNeighbor(NumericVector<Number> & residual, TagID tag_id = 0);
void addResidualNeighbor(const std::map<TagName, TagID> & tags);
void addResidualScalar(TagID tag_id);
void addResidualScalar(const std::map<TagName, TagID> & tags);
/**
* Takes the values that are currently in _sub_Re and appends them to the cached values.
*/
void cacheResidual();
/**
* Cache individual residual contributions. These will ultimately get added to the residual when
* addCachedResidual() is called.
*
* @param dof The degree of freedom to add the residual contribution to
* @param value The value of the residual contribution.
* @param TagID the contribution should go to the tagged residual
*/
void cacheResidualContribution(dof_id_type dof, Real value, TagID tag_id);
/**
* Cache individual residual contributions. These will ultimately get added to the residual when
* addCachedResidual() is called.
*
* @param dof The degree of freedom to add the residual contribution to
* @param value The value of the residual contribution.
* @param tags the contribution should go to all tags
*/
void cacheResidualContribution(dof_id_type dof, Real value, const std::set<TagID> & tags);
/**
* Lets an external class cache residual at a set of nodes
*/
void cacheResidualNodes(const DenseVector<Number> & res,
const std::vector<dof_id_type> & dof_index,
TagID tag = 0);
/**
* Takes the values that are currently in _sub_Rn and appends them to the cached values.
*/
void cacheResidualNeighbor();
/**
* Takes the values that are currently in _sub_Rl and appends them to the cached values.
*/
void cacheResidualLower();
void addCachedResiduals();
/**
* Adds the values that have been cached by calling cacheResidual(), cacheResidualNeighbor(),
* and/or cacheResidualLower() to the residual.
*
* Note that this will also clear the cache.
*/
void addCachedResidual(NumericVector<Number> & residual, TagID tag_id);
void setResidual(NumericVector<Number> & residual, TagID tag_id = 0);
void setResidualNeighbor(NumericVector<Number> & residual, TagID tag_id = 0);
void addJacobian();
/**
* Adds element matrix for ivar rows and jvar columns
*/
void addJacobianCoupledVarPair(MooseVariableBase * ivar, MooseVariableBase * jvar);
void addJacobianNonlocal();
void addJacobianBlock(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,
const DofMap & dof_map,
std::vector<dof_id_type> & dof_indices);
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);
/**
* Add ElementNeighbor, NeighborElement, and NeighborNeighbor portions of the Jacobian for compute
* objects like DGKernels
*/
void addJacobianNeighbor();
/**
* Add LowerLower, LowerSlave (LowerElement), LowerMaster (LowerNeighbor), SlaveLower
* (ElementLower), and MasterLower (NeighborLower) portions of the Jacobian for compute objects
* like MortarConstraints
*/
void addJacobianLower();
void addJacobianNeighbor(SparseMatrix<Number> & jacobian,
unsigned int ivar,
unsigned int jvar,
const DofMap & dof_map,
std::vector<dof_id_type> & dof_indices,
std::vector<dof_id_type> & neighbor_dof_indices);
void addJacobianScalar();
void addJacobianOffDiagScalar(unsigned int ivar);
/**
* Takes the values that are currently in _sub_Kee and appends them to the cached values.
*/
void cacheJacobian();
/**
* Caches element matrix for ivar rows and jvar columns
*/
void cacheJacobianCoupledVarPair(MooseVariableBase * ivar, MooseVariableBase * jvar);
/**
* Takes the values that are currently in _sub_Keg and appends them to the cached values.
*/
void cacheJacobianNonlocal();
/**
* Takes the values that are currently in the neighbor Dense Matrices and appends them to the
* cached values.
*/
void cacheJacobianNeighbor();
/**
* Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor()
* to the jacobian matrix.
*
* Note that this will also clear the cache.
*/
void addCachedJacobian(SparseMatrix<Number> & jacobian);
void addCachedJacobian();
DenseVector<Number> & residualBlock(unsigned int var_num, TagID tag_id = 0)
{
return _sub_Re[tag_id][var_num];
}
DenseVector<Number> & residualBlockNeighbor(unsigned int var_num, TagID tag_id = 0)
{
return _sub_Rn[tag_id][var_num];
}
DenseVector<Number> & residualBlockLower(unsigned int var_num, TagID tag_id = 0)
{
return _sub_Rl[tag_id][var_num];
}
DenseMatrix<Number> & jacobianBlock(unsigned int ivar, unsigned int jvar, TagID tag = 0);
DenseMatrix<Number> & jacobianBlockNonlocal(unsigned int ivar, unsigned int jvar, TagID tag = 0);
DenseMatrix<Number> & jacobianBlockNeighbor(Moose::DGJacobianType type,
unsigned int ivar,
unsigned int jvar,
TagID tag = 0);
/**
* Returns the jacobian block for the given mortar Jacobian type
*/
DenseMatrix<Number> & jacobianBlockLower(Moose::ConstraintJacobianType type,
unsigned int ivar,
unsigned int jvar,
TagID tag = 0);
void cacheJacobianBlock(DenseMatrix<Number> & jac_block,
const std::vector<dof_id_type> & idof_indices,
const std::vector<dof_id_type> & jdof_indices,
Real scaling_factor,
TagID tag = 0);
void cacheJacobianBlockNonlocal(DenseMatrix<Number> & jac_block,
const std::vector<dof_id_type> & idof_indices,
const std::vector<dof_id_type> & jdof_indices,
Real scaling_factor,
TagID tag = 0);
std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> & couplingEntries()
{
return _cm_ff_entry;
}
std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> & nonlocalCouplingEntries()
{
return _cm_nonlocal_entry;
}
// Read-only references
const VariablePhiValue & phi() const { return _phi; }
template <typename T, ComputeStage compute_stage>
const typename VariableTestGradientType<T, compute_stage>::type &
adGradPhi(const MooseVariableFE<T> & v) const
{
return gradPhi(v);
}
const VariablePhiValue & phi(const MooseVariable &) const { return _phi; }
const VariablePhiGradient & gradPhi() const { return _grad_phi; }
const VariablePhiGradient & gradPhi(const MooseVariable &) const { return _grad_phi; }
const VariablePhiSecond & secondPhi() const { return _second_phi; }
const VariablePhiSecond & secondPhi(const MooseVariable &) const { return _second_phi; }
const VariablePhiValue & phiFace() const { return _phi_face; }
const VariablePhiValue & phiFace(const MooseVariable &) const { return _phi_face; }
const VariablePhiGradient & gradPhiFace() const { return _grad_phi_face; }
const VariablePhiGradient & gradPhiFace(const MooseVariable &) const { return _grad_phi_face; }
const VariablePhiSecond & secondPhiFace(const MooseVariable &) const { return _second_phi_face; }
const VariablePhiValue & phiNeighbor(const MooseVariable &) const { return _phi_neighbor; }
const VariablePhiGradient & gradPhiNeighbor(const MooseVariable &) const
{
return _grad_phi_neighbor;
}
const VariablePhiSecond & secondPhiNeighbor(const MooseVariable &) const
{
return _second_phi_neighbor;
}
const VariablePhiValue & phiFaceNeighbor(const MooseVariable &) const
{
return _phi_face_neighbor;
}
const VariablePhiGradient & gradPhiFaceNeighbor(const MooseVariable &) const
{
return _grad_phi_face_neighbor;
}
const VariablePhiSecond & secondPhiFaceNeighbor(const MooseVariable &) const
{
return _second_phi_face_neighbor;
}
const VectorVariablePhiValue & phi(const VectorMooseVariable &) const { return _vector_phi; }
const VectorVariablePhiGradient & gradPhi(const VectorMooseVariable &) const
{
return _vector_grad_phi;
}
const VectorVariablePhiSecond & secondPhi(const VectorMooseVariable &) const
{
return _vector_second_phi;
}
const VectorVariablePhiCurl & curlPhi(const VectorMooseVariable &) const
{
return _vector_curl_phi;
}
const VectorVariablePhiValue & phiFace(const VectorMooseVariable &) const
{
return _vector_phi_face;
}
const VectorVariablePhiGradient & gradPhiFace(const VectorMooseVariable &) const
{
return _vector_grad_phi_face;
}
const VectorVariablePhiSecond & secondPhiFace(const VectorMooseVariable &) const
{
return _vector_second_phi_face;
}
const VectorVariablePhiCurl & curlPhiFace(const VectorMooseVariable &) const
{
return _vector_curl_phi_face;
}
const VectorVariablePhiValue & phiNeighbor(const VectorMooseVariable &) const
{
return _vector_phi_neighbor;
}
const VectorVariablePhiGradient & gradPhiNeighbor(const VectorMooseVariable &) const
{
return _vector_grad_phi_neighbor;
}
const VectorVariablePhiSecond & secondPhiNeighbor(const VectorMooseVariable &) const
{
return _vector_second_phi_neighbor;
}
const VectorVariablePhiCurl & curlPhiNeighbor(const VectorMooseVariable &) const
{
return _vector_curl_phi_neighbor;
}
const VectorVariablePhiValue & phiFaceNeighbor(const VectorMooseVariable &) const
{
return _vector_phi_face_neighbor;
}
const VectorVariablePhiGradient & gradPhiFaceNeighbor(const VectorMooseVariable &) const
{
return _vector_grad_phi_face_neighbor;
}
const VectorVariablePhiSecond & secondPhiFaceNeighbor(const VectorMooseVariable &) const
{
return _vector_second_phi_face_neighbor;
}
const VectorVariablePhiCurl & curlPhiFaceNeighbor(const VectorMooseVariable &) const
{
return _vector_curl_phi_face_neighbor;
}
// Writeable references
VariablePhiValue & phi(const MooseVariable &) { return _phi; }
VariablePhiGradient & gradPhi(const MooseVariable &) { return _grad_phi; }
VariablePhiSecond & secondPhi(const MooseVariable &) { return _second_phi; }
VariablePhiValue & phiFace(const MooseVariable &) { return _phi_face; }
VariablePhiGradient & gradPhiFace(const MooseVariable &) { return _grad_phi_face; }
VariablePhiSecond & secondPhiFace(const MooseVariable &) { return _second_phi_face; }
VariablePhiValue & phiNeighbor(const MooseVariable &) { return _phi_neighbor; }
VariablePhiGradient & gradPhiNeighbor(const MooseVariable &) { return _grad_phi_neighbor; }
VariablePhiSecond & secondPhiNeighbor(const MooseVariable &) { return _second_phi_neighbor; }
VariablePhiValue & phiFaceNeighbor(const MooseVariable &) { return _phi_face_neighbor; }
VariablePhiGradient & gradPhiFaceNeighbor(const MooseVariable &)
{
return _grad_phi_face_neighbor;
}
VariablePhiSecond & secondPhiFaceNeighbor(const MooseVariable &)
{
return _second_phi_face_neighbor;
}
// Writeable references with vector variable
VectorVariablePhiValue & phi(const VectorMooseVariable &) { return _vector_phi; }
VectorVariablePhiGradient & gradPhi(const VectorMooseVariable &) { return _vector_grad_phi; }
VectorVariablePhiSecond & secondPhi(const VectorMooseVariable &) { return _vector_second_phi; }
VectorVariablePhiCurl & curlPhi(const VectorMooseVariable &) { return _vector_curl_phi; }
VectorVariablePhiValue & phiFace(const VectorMooseVariable &) { return _vector_phi_face; }
VectorVariablePhiGradient & gradPhiFace(const VectorMooseVariable &)
{
return _vector_grad_phi_face;
}
VectorVariablePhiSecond & secondPhiFace(const VectorMooseVariable &)
{
return _vector_second_phi_face;
}
VectorVariablePhiCurl & curlPhiFace(const VectorMooseVariable &) { return _vector_curl_phi_face; }
VectorVariablePhiValue & phiNeighbor(const VectorMooseVariable &) { return _vector_phi_neighbor; }
VectorVariablePhiGradient & gradPhiNeighbor(const VectorMooseVariable &)
{
return _vector_grad_phi_neighbor;
}
VectorVariablePhiSecond & secondPhiNeighbor(const VectorMooseVariable &)
{
return _vector_second_phi_neighbor;
}
VectorVariablePhiCurl & curlPhiNeighbor(const VectorMooseVariable &)
{
return _vector_curl_phi_neighbor;
}
VectorVariablePhiValue & phiFaceNeighbor(const VectorMooseVariable &)
{
return _vector_phi_face_neighbor;
}
VectorVariablePhiGradient & gradPhiFaceNeighbor(const VectorMooseVariable &)
{
return _vector_grad_phi_face_neighbor;
}
VectorVariablePhiSecond & secondPhiFaceNeighbor(const VectorMooseVariable &)
{
return _vector_second_phi_face_neighbor;
}
VectorVariablePhiCurl & curlPhiFaceNeighbor(const VectorMooseVariable &)
{
return _vector_curl_phi_face_neighbor;
}
// Writeable references with array variable
VariablePhiValue & phi(const ArrayMooseVariable &) { return _phi; }
VariablePhiGradient & gradPhi(const ArrayMooseVariable &) { return _grad_phi; }
VariablePhiSecond & secondPhi(const ArrayMooseVariable &) { return _second_phi; }
VariablePhiValue & phiFace(const ArrayMooseVariable &) { return _phi_face; }
VariablePhiGradient & gradPhiFace(const ArrayMooseVariable &) { return _grad_phi_face; }
VariablePhiSecond & secondPhiFace(const ArrayMooseVariable &) { return _second_phi_face; }
VariablePhiValue & phiNeighbor(const ArrayMooseVariable &) { return _phi_neighbor; }
VariablePhiGradient & gradPhiNeighbor(const ArrayMooseVariable &) { return _grad_phi_neighbor; }
VariablePhiSecond & secondPhiNeighbor(const ArrayMooseVariable &) { return _second_phi_neighbor; }
VariablePhiValue & phiFaceNeighbor(const ArrayMooseVariable &) { return _phi_face_neighbor; }
VariablePhiGradient & gradPhiFaceNeighbor(const ArrayMooseVariable &)
{
return _grad_phi_face_neighbor;
}
VariablePhiSecond & secondPhiFaceNeighbor(const ArrayMooseVariable &)
{
return _second_phi_face_neighbor;
}
template <typename OutputType>
const typename OutputTools<OutputType>::VariablePhiValue & fePhi(FEType type) const
{
buildFE(type);
return _fe_shape_data[type]->_phi;
}
template <typename OutputType>
const typename OutputTools<OutputType>::VariablePhiGradient & feGradPhi(FEType type) const
{
buildFE(type);
return _fe_shape_data[type]->_grad_phi;
}
template <typename OutputType>
const typename VariableTestGradientType<OutputType, ComputeStage::JACOBIAN>::type &
feADGradPhi(FEType type) const
{
return _ad_grad_phi_data[type];
}
template <typename OutputType>