-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathFEProblemBase.h
3171 lines (2666 loc) · 119 KB
/
FEProblemBase.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://mooseframework.inl.gov
//*
//* 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
// MOOSE includes
#include "SubProblem.h"
#include "GeometricSearchData.h"
#include "MeshDivision.h"
#include "MortarData.h"
#include "ReporterData.h"
#include "Adaptivity.h"
#include "InitialConditionWarehouse.h"
#include "FVInitialConditionWarehouse.h"
#include "ScalarInitialConditionWarehouse.h"
#include "Restartable.h"
#include "SolverParams.h"
#include "PetscSupport.h"
#include "MooseApp.h"
#include "ExecuteMooseObjectWarehouse.h"
#include "MaterialWarehouse.h"
#include "MooseVariableFE.h"
#include "MultiAppTransfer.h"
#include "Postprocessor.h"
#include "HashMap.h"
#include "VectorPostprocessor.h"
#include "PerfGraphInterface.h"
#include "Attributes.h"
#include "MooseObjectWarehouse.h"
#include "MaterialPropertyRegistry.h"
#include "RestartableEquationSystems.h"
#include "SolutionInvalidity.h"
#include "PetscSupport.h"
#include "libmesh/enum_quadrature_type.h"
#include "libmesh/equation_systems.h"
#include <unordered_map>
#include <memory>
// Forward declarations
class AuxiliarySystem;
class DisplacedProblem;
class MooseMesh;
class NonlinearSystemBase;
class LinearSystem;
class SolverSystem;
class NonlinearSystem;
class RandomInterface;
class RandomData;
class MeshChangedInterface;
class MultiMooseEnum;
class MaterialPropertyStorage;
class MaterialData;
class MooseEnum;
class Assembly;
class JacobianBlock;
class Control;
class MultiApp;
class TransientMultiApp;
class ScalarInitialCondition;
class Indicator;
class InternalSideIndicator;
class Marker;
class Material;
class Transfer;
class XFEMInterface;
class SideUserObject;
class NodalUserObject;
class ElementUserObject;
class InternalSideUserObject;
class InterfaceUserObject;
class GeneralUserObject;
class Positions;
class Function;
class Distribution;
class Sampler;
class KernelBase;
class IntegratedBCBase;
class LineSearch;
class UserObject;
class AutomaticMortarGeneration;
class VectorPostprocessor;
class Convergence;
class MooseAppCoordTransform;
class MortarUserObject;
class SolutionInvalidity;
// libMesh forward declarations
namespace libMesh
{
class CouplingMatrix;
class NonlinearImplicitSystem;
class LinearImplicitSystem;
} // namespace libMesh
enum class MooseLinearConvergenceReason
{
ITERATING = 0,
// CONVERGED_RTOL_NORMAL = 1,
// CONVERGED_ATOL_NORMAL = 9,
CONVERGED_RTOL = 2,
CONVERGED_ATOL = 3,
CONVERGED_ITS = 4,
// CONVERGED_CG_NEG_CURVE = 5,
// CONVERGED_CG_CONSTRAINED = 6,
// CONVERGED_STEP_LENGTH = 7,
// CONVERGED_HAPPY_BREAKDOWN = 8,
DIVERGED_NULL = -2,
// DIVERGED_ITS = -3,
// DIVERGED_DTOL = -4,
// DIVERGED_BREAKDOWN = -5,
// DIVERGED_BREAKDOWN_BICG = -6,
// DIVERGED_NONSYMMETRIC = -7,
// DIVERGED_INDEFINITE_PC = -8,
DIVERGED_NANORINF = -9,
// DIVERGED_INDEFINITE_MAT = -10
DIVERGED_PCSETUP_FAILED = -11
};
/**
* Specialization of SubProblem for solving nonlinear equations plus auxiliary equations
*
*/
class FEProblemBase : public SubProblem, public Restartable
{
public:
static InputParameters validParams();
FEProblemBase(const InputParameters & parameters);
virtual ~FEProblemBase();
enum class CoverageCheckMode
{
FALSE,
TRUE,
OFF,
ON,
SKIP_LIST,
ONLY_LIST,
};
virtual libMesh::EquationSystems & es() override { return _req.set().es(); }
virtual MooseMesh & mesh() override { return _mesh; }
virtual const MooseMesh & mesh() const override { return _mesh; }
const MooseMesh & mesh(bool use_displaced) const override;
void setCoordSystem(const std::vector<SubdomainName> & blocks, const MultiMooseEnum & coord_sys);
void setAxisymmetricCoordAxis(const MooseEnum & rz_coord_axis);
/**
* Set the coupling between variables
* TODO: allow user-defined coupling
* @param type Type of coupling
*/
void setCoupling(Moose::CouplingType type);
Moose::CouplingType coupling() { return _coupling; }
/**
* Set custom coupling matrix
* @param cm coupling matrix to be set
* @param nl_sys_num which nonlinear system we are setting the coupling matrix for
*/
void setCouplingMatrix(std::unique_ptr<libMesh::CouplingMatrix> cm,
const unsigned int nl_sys_num);
// DEPRECATED METHOD
void setCouplingMatrix(libMesh::CouplingMatrix * cm, const unsigned int nl_sys_num);
const libMesh::CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const override;
/// Set custom coupling matrix for variables requiring nonlocal contribution
void setNonlocalCouplingMatrix();
bool
areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const;
/**
* Whether or not MOOSE will perform a user object/auxiliary kernel state check
*/
bool hasUOAuxStateCheck() const { return _uo_aux_state_check; }
/**
* Return a flag to indicate whether we are executing user objects and auxliary kernels for state
* check
* Note: This function can return true only when hasUOAuxStateCheck() returns true, i.e. the check
* has been activated by users through Problem/check_uo_aux_state input parameter.
*/
bool checkingUOAuxState() const { return _checking_uo_aux_state; }
/**
* Whether to trust the user coupling matrix even if we want to do things like be paranoid and
* create a full coupling matrix. See https://github.com/idaholab/moose/issues/16395 for detailed
* background
*/
void trustUserCouplingMatrix();
std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> &
couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num);
std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> &
nonlocalCouplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num);
virtual bool hasVariable(const std::string & var_name) const override;
bool hasSolverVariable(const std::string & var_name) const;
using SubProblem::getVariable;
virtual const MooseVariableFieldBase &
getVariable(const THREAD_ID tid,
const std::string & var_name,
Moose::VarKindType expected_var_type = Moose::VarKindType::VAR_ANY,
Moose::VarFieldType expected_var_field_type =
Moose::VarFieldType::VAR_FIELD_ANY) const override;
MooseVariableFieldBase & getActualFieldVariable(const THREAD_ID tid,
const std::string & var_name) override;
virtual MooseVariable & getStandardVariable(const THREAD_ID tid,
const std::string & var_name) override;
virtual VectorMooseVariable & getVectorVariable(const THREAD_ID tid,
const std::string & var_name) override;
virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid,
const std::string & var_name) override;
virtual bool hasScalarVariable(const std::string & var_name) const override;
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid,
const std::string & var_name) override;
virtual libMesh::System & getSystem(const std::string & var_name) override;
/**
* Set the MOOSE variables to be reinited on each element.
* @param moose_vars A set of variables that need to be reinited each time reinit() is called.
*
* @param tid The thread id
*/
virtual void setActiveElementalMooseVariables(const std::set<MooseVariableFEBase *> & moose_vars,
const THREAD_ID tid) override;
/**
* Clear the active elemental MooseVariableFEBase. If there are no active variables then they
* will all be reinited. Call this after finishing the computation that was using a restricted set
* of MooseVariableFEBases
*
* @param tid The thread id
*/
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override;
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) override;
virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) override;
virtual void setActiveFEVariableCoupleableVectorTags(std::set<TagID> & vtags,
const THREAD_ID tid) override;
virtual void setActiveFEVariableCoupleableMatrixTags(std::set<TagID> & mtags,
const THREAD_ID tid) override;
virtual void clearActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) override;
virtual void clearActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) override;
virtual void setActiveScalarVariableCoupleableVectorTags(std::set<TagID> & vtags,
const THREAD_ID tid) override;
virtual void setActiveScalarVariableCoupleableMatrixTags(std::set<TagID> & mtags,
const THREAD_ID tid) override;
virtual void createQRules(libMesh::QuadratureType type,
libMesh::Order order,
libMesh::Order volume_order = libMesh::INVALID_ORDER,
libMesh::Order face_order = libMesh::INVALID_ORDER,
SubdomainID block = Moose::ANY_BLOCK_ID,
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
* can only cause the quadrature level to increase. If volume_order is
* lower than or equal to the current volume/elem quadrature rule order,
* then nothing is done (i.e. this function is idempotent).
*/
void bumpVolumeQRuleOrder(libMesh::Order order, SubdomainID block);
void bumpAllQRuleOrder(libMesh::Order order, SubdomainID block);
/**
* @return The maximum number of quadrature points in use on any element in this problem.
*/
unsigned int getMaxQps() const;
/**
* @return The maximum order for all scalar variables in this problem's systems.
*/
libMesh::Order getMaxScalarOrder() const;
/**
* @return Flag indicating nonlocal coupling exists or not.
*/
void checkNonlocalCoupling();
void checkUserObjectJacobianRequirement(THREAD_ID tid);
void setVariableAllDoFMap(const std::vector<const MooseVariableFEBase *> & moose_vars);
const std::vector<const MooseVariableFEBase *> &
getUserObjectJacobianVariables(const THREAD_ID tid) const
{
return _uo_jacobian_moose_vars[tid];
}
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override;
virtual const Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) const override;
/**
* Returns a list of all the variables in the problem (both from the NL and Aux systems.
*/
virtual std::vector<VariableName> getVariableNames();
void initialSetup() override;
void checkDuplicatePostprocessorVariableNames();
void timestepSetup() override;
void customSetup(const ExecFlagType & exec_type) override;
void residualSetup() override;
void jacobianSetup() override;
virtual void prepare(const Elem * elem, const THREAD_ID tid) override;
virtual void prepareFace(const Elem * elem, const THREAD_ID tid) override;
virtual void prepare(const Elem * elem,
unsigned int ivar,
unsigned int jvar,
const std::vector<dof_id_type> & dof_indices,
const THREAD_ID tid) override;
virtual void setCurrentSubdomainID(const Elem * elem, const THREAD_ID tid) override;
virtual void
setNeighborSubdomainID(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
virtual void setNeighborSubdomainID(const Elem * elem, const THREAD_ID tid);
virtual void prepareAssembly(const THREAD_ID tid) override;
virtual void addGhostedElem(dof_id_type elem_id) override;
virtual void addGhostedBoundary(BoundaryID boundary_id) override;
virtual void ghostGhostedBoundaries() override;
virtual void sizeZeroes(unsigned int size, const THREAD_ID tid);
virtual bool reinitDirac(const Elem * elem, const THREAD_ID tid) override;
virtual void reinitElem(const Elem * elem, const THREAD_ID tid) override;
virtual void reinitElemPhys(const Elem * elem,
const std::vector<Point> & phys_points_in_elem,
const THREAD_ID tid) override;
void reinitElemFace(const Elem * elem, unsigned int side, BoundaryID, const THREAD_ID tid);
virtual void reinitElemFace(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
virtual void reinitLowerDElem(const Elem * lower_d_elem,
const THREAD_ID tid,
const std::vector<Point> * const pts = nullptr,
const std::vector<Real> * const weights = nullptr) override;
virtual void reinitNode(const Node * node, const THREAD_ID tid) override;
virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, const THREAD_ID tid) override;
virtual void reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid) override;
virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes,
const THREAD_ID tid) override;
virtual void reinitNeighbor(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
virtual void reinitNeighborPhys(const Elem * neighbor,
unsigned int neighbor_side,
const std::vector<Point> & physical_points,
const THREAD_ID tid) override;
virtual void reinitNeighborPhys(const Elem * neighbor,
const std::vector<Point> & physical_points,
const THREAD_ID tid) override;
virtual void
reinitElemNeighborAndLowerD(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
virtual void reinitScalars(const THREAD_ID tid,
bool reinit_for_derivative_reordering = false) override;
virtual void reinitOffDiagScalars(const THREAD_ID tid) override;
/// Fills "elems" with the elements that should be looped over for Dirac Kernels
virtual void getDiracElements(std::set<const Elem *> & elems) override;
virtual void clearDiracInfo() override;
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid);
virtual void neighborSubdomainSetup(SubdomainID subdomain, const THREAD_ID tid);
virtual void newAssemblyArray(std::vector<std::shared_ptr<SolverSystem>> & solver_systems);
virtual void initNullSpaceVectors(const InputParameters & parameters,
std::vector<std::shared_ptr<NonlinearSystemBase>> & nl);
virtual void init() override;
virtual void solve(const unsigned int nl_sys_num);
/**
* Build and solve a linear system
* @param linear_sys_num The number of the linear system (1,..,num. of lin. systems)
* @param po The petsc options for the solve, if not supplied, the defaults are used
*/
virtual void solveLinearSystem(const unsigned int linear_sys_num,
const Moose::PetscSupport::PetscOptions * po = nullptr);
///@{
/**
* In general, {evaluable elements} >= {local elements} U {algebraic ghosting elements}. That is,
* the number of evaluable elements does NOT necessarily equal to the number of local and
* algebraic ghosting elements. For example, if using a Lagrange basis for all variables,
* if a non-local, non-algebraically-ghosted element is surrounded by neighbors which are
* local or algebraically ghosted, then all the nodal (Lagrange) degrees of freedom associated
* with the non-local, non-algebraically-ghosted element will be evaluable, and hence that
* element will be considered evaluable.
*
* getNonlinearEvaluableElementRange() returns the evaluable element range based on the nonlinear
* system dofmap;
* getAuxliaryEvaluableElementRange() returns the evaluable element range based on the auxiliary
* system dofmap;
* getEvaluableElementRange() returns the element range that is evaluable based on both the
* nonlinear dofmap and the auxliary dofmap.
*/
const libMesh::ConstElemRange & getEvaluableElementRange();
const libMesh::ConstElemRange & getNonlinearEvaluableElementRange();
///@}
///@{
/**
* These are the element and nodes that contribute to the jacobian and
* residual for this local processor.
*
* getCurrentAlgebraicElementRange() returns the element range that contributes to the
* system
* getCurrentAlgebraicNodeRange() returns the node range that contributes to the
* system
* getCurrentAlgebraicBndNodeRange returns the boundary node ranges that contributes
* to the system
*/
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange();
const libMesh::ConstNodeRange & getCurrentAlgebraicNodeRange();
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange();
///@}
///@{
/**
* These functions allow setting custom ranges for the algebraic elements, nodes,
* and boundary nodes that contribute to the jacobian and residual for this local
* processor.
*
* setCurrentAlgebraicElementRange() sets the element range that contributes to the
* system. A nullptr will reset the range to use the mesh's range.
*
* setCurrentAlgebraicNodeRange() sets the node range that contributes to the
* system. A nullptr will reset the range to use the mesh's range.
*
* setCurrentAlgebraicBndNodeRange() sets the boundary node range that contributes
* to the system. A nullptr will reset the range to use the mesh's range.
*
* @param range A pointer to the const range object representing the algebraic
* elements, nodes, or boundary nodes.
*/
void setCurrentAlgebraicElementRange(libMesh::ConstElemRange * range);
void setCurrentAlgebraicNodeRange(libMesh::ConstNodeRange * range);
void setCurrentAlgebraicBndNodeRange(ConstBndNodeRange * range);
///@}
/**
* Set an exception, which is stored at this point by toggling a member variable in
* this class, and which must be followed up with by a call to
* checkExceptionAndStopSolve().
*
* @param message The error message describing the exception, which will get printed
* when checkExceptionAndStopSolve() is called
*/
virtual void setException(const std::string & message);
/**
* Whether or not an exception has occurred.
*/
virtual bool hasException() { return _has_exception; }
/**
* Check to see if an exception has occurred on any processor and, if possible,
* force the solve to fail, which will result in the time step being cut.
*
* Notes:
* * The exception have be registered by calling setException() prior to calling this.
* * This is collective on MPI, and must be called simultaneously by all processors!
* * If called when the solve can be interruped, it will do so and also throw a
* MooseException, which must be handled.
* * If called at a stage in the execution when the solve cannot be interupted (i.e.,
* there is no solve active), it will generate an error and terminate the application.
* * DO NOT CALL THIS IN A THREADED REGION! This is meant to be called just after a
* threaded section.
*
* @param print_message whether to print a message with exception information
*/
virtual void checkExceptionAndStopSolve(bool print_message = true);
virtual bool solverSystemConverged(const unsigned int solver_sys_num) override;
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const override;
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const override;
virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const override;
virtual bool computingPreSMOResidual(const unsigned int nl_sys_num) const override;
/**
* Return solver type as a human readable string
*/
virtual std::string solverTypeString(unsigned int solver_sys_num = 0);
/**
* Returns true if we are in or beyond the initialSetup stage
*/
virtual bool startedInitialSetup() { return _started_initial_setup; }
virtual void onTimestepBegin() override;
virtual void onTimestepEnd() override;
virtual Real & time() const { return _time; }
virtual Real & timeOld() const { return _time_old; }
virtual int & timeStep() const { return _t_step; }
virtual Real & dt() const { return _dt; }
virtual Real & dtOld() const { return _dt_old; }
/**
* Returns the time associated with the requested \p state
*/
Real getTimeFromStateArg(const Moose::StateArg & state) const;
virtual void transient(bool trans) { _transient = trans; }
virtual bool isTransient() const override { return _transient; }
virtual void addTimeIntegrator(const std::string & type,
const std::string & name,
InputParameters & parameters);
virtual void
addPredictor(const std::string & type, const std::string & name, InputParameters & parameters);
virtual void copySolutionsBackwards();
/**
* Advance all of the state holding vectors / datastructures so that we can move to the next
* timestep.
*/
virtual void advanceState();
virtual void restoreSolutions();
/**
* Allocate vectors and save old solutions into them.
*/
virtual void saveOldSolutions();
/**
* Restore old solutions from the backup vectors and deallocate them.
*/
virtual void restoreOldSolutions();
/**
* Declare that we need up to old (1) or older (2) solution states for a given type of iteration
* @param oldest_needed oldest solution state needed
* @param iteration_type the type of iteration for which old/older states are needed
*/
void needSolutionState(unsigned int oldest_needed, Moose::SolutionIterationType iteration_type);
/**
* Output the current step.
* Will ensure that everything is in the proper state to be outputted.
* Then tell the OutputWarehouse to do its thing
* @param type The type execution flag (see Moose.h)
*/
virtual void outputStep(ExecFlagType type);
/**
* Method called at the end of the simulation.
*/
virtual void postExecute();
///@{
/**
* Ability to enable/disable all output calls
*
* This is needed by Multiapps and applications to disable output for cases when
* executioners call other executions and when Multiapps are sub cycling.
*/
void allowOutput(bool state);
template <typename T>
void allowOutput(bool state);
///@}
/**
* Indicates that the next call to outputStep should be forced
*
* This is needed by the MultiApp system, if forceOutput is called the next call to outputStep,
* regardless of the type supplied to the call, will be executed with EXEC_FORCED.
*
* Forced output will NOT override the allowOutput flag.
*/
void forceOutput();
/**
* Reinitialize PETSc output for proper linear/nonlinear iteration display. This also may be used
* for some PETSc-related solver settings
*/
virtual void initPetscOutputAndSomeSolverSettings();
/**
* Retrieve a writable reference the PETSc options (used by PetscSupport)
*/
Moose::PetscSupport::PetscOptions & getPetscOptions() { return _petsc_options; }
/**
* Output information about the object just added to the problem
*/
void logAdd(const std::string & system,
const std::string & name,
const std::string & type,
const InputParameters & params) const;
// Function /////
virtual void
addFunction(const std::string & type, const std::string & name, InputParameters & parameters);
virtual bool hasFunction(const std::string & name, const THREAD_ID tid = 0);
virtual Function & getFunction(const std::string & name, const THREAD_ID tid = 0);
/// Add a MeshDivision
virtual void
addMeshDivision(const std::string & type, const std::string & name, InputParameters & params);
/// Get a MeshDivision
MeshDivision & getMeshDivision(const std::string & name, const THREAD_ID tid = 0) const;
/// Adds a Convergence object
virtual void
addConvergence(const std::string & type, const std::string & name, InputParameters & parameters);
/// Gets a Convergence object
virtual Convergence & getConvergence(const std::string & name, const THREAD_ID tid = 0) const;
/// Gets the Convergence objects
virtual const std::vector<std::shared_ptr<Convergence>> &
getConvergenceObjects(const THREAD_ID tid = 0) const;
/// Returns true if the problem has a Convergence object of the given name
virtual bool hasConvergence(const std::string & name, const THREAD_ID tid = 0) const;
/// Returns true if the problem needs to add the default nonlinear convergence
bool needToAddDefaultNonlinearConvergence() const
{
return _need_to_add_default_nonlinear_convergence;
}
/// Sets _need_to_add_default_nonlinear_convergence to true
void setNeedToAddDefaultNonlinearConvergence()
{
_need_to_add_default_nonlinear_convergence = true;
}
/**
* Adds the default nonlinear Convergence associated with the problem
*
* This is called if the user does not supply 'nonlinear_convergence'.
*
* @param[in] params Parameters to apply to Convergence parameters
*/
virtual void addDefaultNonlinearConvergence(const InputParameters & params);
/**
* Returns true if an error will result if the user supplies 'nonlinear_convergence'
*
* Some problems are strongly tied to their convergence, and it does not make
* sense to use any convergence other than their default and additionally
* would be error-prone.
*/
virtual bool onlyAllowDefaultNonlinearConvergence() const { return false; }
/**
* add a MOOSE line search
*/
virtual void addLineSearch(const InputParameters & /*parameters*/)
{
mooseError("Line search not implemented for this problem type yet.");
}
/**
* execute MOOSE line search
*/
virtual void lineSearch();
/**
* getter for the MOOSE line search
*/
LineSearch * getLineSearch() override { return _line_search.get(); }
/**
* The following functions will enable MOOSE to have the capability to import distributions
*/
virtual void
addDistribution(const std::string & type, const std::string & name, InputParameters & parameters);
virtual Distribution & getDistribution(const std::string & name);
/**
* The following functions will enable MOOSE to have the capability to import Samplers
*/
virtual void
addSampler(const std::string & type, const std::string & name, InputParameters & parameters);
virtual Sampler & getSampler(const std::string & name, const THREAD_ID tid = 0);
// NL /////
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num);
const NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num) const;
void setCurrentNonlinearSystem(const unsigned int nl_sys_num);
NonlinearSystemBase & currentNonlinearSystem();
const NonlinearSystemBase & currentNonlinearSystem() const;
virtual const SystemBase & systemBaseNonlinear(const unsigned int sys_num) const override;
virtual SystemBase & systemBaseNonlinear(const unsigned int sys_num) override;
virtual const SystemBase & systemBaseAuxiliary() const override;
virtual SystemBase & systemBaseAuxiliary() override;
virtual NonlinearSystem & getNonlinearSystem(const unsigned int sys_num);
/**
* Get constant reference to a system in this problem
* @param sys_num The number of the system
*/
virtual const SystemBase & getSystemBase(const unsigned int sys_num) const;
/**
* Get non-constant reference to a system in this problem
* @param sys_num The number of the system
*/
virtual SystemBase & getSystemBase(const unsigned int sys_num);
/**
* Get non-constant reference to a linear system
* @param sys_num The number of the linear system
*/
LinearSystem & getLinearSystem(unsigned int sys_num);
/**
* Get a constant reference to a linear system
* @param sys_num The number of the linear system
*/
const LinearSystem & getLinearSystem(unsigned int sys_num) const;
/**
* Get non-constant reference to a solver system
* @param sys_num The number of the solver system
*/
SolverSystem & getSolverSystem(unsigned int sys_num);
/**
* Get a constant reference to a solver system
* @param sys_num The number of the solver system
*/
const SolverSystem & getSolverSystem(unsigned int sys_num) const;
/**
* Set the current linear system pointer
* @param sys_num The number of linear system
*/
void setCurrentLinearSystem(unsigned int sys_num);
/// Get a non-constant reference to the current linear system
LinearSystem & currentLinearSystem();
/// Get a constant reference to the current linear system
const LinearSystem & currentLinearSystem() const;
/**
* Get a constant base class reference to a linear system
* @param sys_num The number of the linear system
*/
virtual const SystemBase & systemBaseLinear(unsigned int sys_num) const override;
/**
* Get a non-constant base class reference to a linear system
* @param sys_num The number of the linear system
*/
virtual SystemBase & systemBaseLinear(unsigned int sys_num) override;
/**
* Canonical method for adding a non-linear variable
* @param var_type the type of the variable, e.g. MooseVariableScalar
* @param var_name the variable name, e.g. 'u'
* @param params the InputParameters from which to construct the variable
*/
virtual void
addVariable(const std::string & var_type, const std::string & var_name, InputParameters & params);
virtual void addKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void addHDGKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void addNodalKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void addScalarKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void addBoundaryCondition(const std::string & bc_name,
const std::string & name,
InputParameters & parameters);
virtual void addHDGIntegratedBC(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void
addConstraint(const std::string & c_name, const std::string & name, InputParameters & parameters);
virtual void setInputParametersFEProblem(InputParameters & parameters)
{
parameters.set<FEProblemBase *>("_fe_problem_base") = this;
}
// Aux /////
/**
* Canonical method for adding an auxiliary variable
* @param var_type the type of the variable, e.g. MooseVariableScalar
* @param var_name the variable name, e.g. 'u'
* @param params the InputParameters from which to construct the variable
*/
virtual void addAuxVariable(const std::string & var_type,
const std::string & var_name,
InputParameters & params);
virtual void addAuxVariable(const std::string & var_name,
const libMesh::FEType & type,
const std::set<SubdomainID> * const active_subdomains = NULL);
virtual void addAuxArrayVariable(const std::string & var_name,
const libMesh::FEType & type,
unsigned int components,
const std::set<SubdomainID> * const active_subdomains = NULL);
virtual void addAuxScalarVariable(const std::string & var_name,
libMesh::Order order,
Real scale_factor = 1.,
const std::set<SubdomainID> * const active_subdomains = NULL);
virtual void addAuxKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void addAuxScalarKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
AuxiliarySystem & getAuxiliarySystem() { return *_aux; }
// Dirac /////
virtual void addDiracKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
// DG /////
virtual void addDGKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
// FV /////
virtual void addFVKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void addLinearFVKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
virtual void
addFVBC(const std::string & fv_bc_name, const std::string & name, InputParameters & parameters);
virtual void addLinearFVBC(const std::string & fv_bc_name,
const std::string & name,
InputParameters & parameters);
virtual void addFVInterfaceKernel(const std::string & fv_ik_name,
const std::string & name,
InputParameters & parameters);
// Interface /////
virtual void addInterfaceKernel(const std::string & kernel_name,
const std::string & name,
InputParameters & parameters);
// IC /////
virtual void addInitialCondition(const std::string & ic_name,
const std::string & name,
InputParameters & parameters);
/**
* Add an initial condition for a finite volume variables
* @param ic_name The name of the boundary condition object
* @param name The user-defined name from the input file
* @param parameters The input parameters for construction
*/
virtual void addFVInitialCondition(const std::string & ic_name,
const std::string & name,
InputParameters & parameters);
void projectSolution();
/**
* Retrieves the current initial condition state.
* @return current initial condition state
*/
unsigned short getCurrentICState();
/**
* Project initial conditions for custom \p elem_range and \p bnd_node_range
* This is needed when elements/boundary nodes are added to a specific subdomain
* at an intermediate step
*/
void projectInitialConditionOnCustomRange(libMesh::ConstElemRange & elem_range,
ConstBndNodeRange & bnd_node_range);
// Materials /////
virtual void addMaterial(const std::string & material_name,
const std::string & name,
InputParameters & parameters);
virtual void addMaterialHelper(std::vector<MaterialWarehouse *> warehouse,
const std::string & material_name,
const std::string & name,
InputParameters & parameters);
virtual void addInterfaceMaterial(const std::string & material_name,
const std::string & name,
InputParameters & parameters);
virtual void addFunctorMaterial(const std::string & functor_material_name,
const std::string & name,
InputParameters & parameters);
/**
* Add the MooseVariables and the material properties that the current materials depend on to the
* dependency list.
* @param consumer_needed_mat_props The material properties needed by consumer objects (other than
* the materials themselves)
* @param blk_id The subdomain ID for which we are preparing our list of needed vars and props
* @param tid The thread ID we are preparing the requirements for
*
* This MUST be done after the moose variable dependency list has been set for all the other
* objects using the \p setActiveElementalMooseVariables API!
*/
void prepareMaterials(const std::unordered_set<unsigned int> & consumer_needed_mat_props,
const SubdomainID blk_id,
const THREAD_ID tid);
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful = true);
/**
* reinit materials on element faces
* @param blk_id The subdomain on which the element owning the face lives
* @param tid The thread id
* @param swap_stateful Whether to swap stateful material properties between \p MaterialData and
* \p MaterialPropertyStorage
* @param execute_stateful Whether to execute material objects that have stateful properties. This
* should be \p false when for example executing material objects for mortar contexts in which
* stateful properties don't make sense
*/
void reinitMaterialsFace(SubdomainID blk_id,
const THREAD_ID tid,
bool swap_stateful = true,
const std::deque<MaterialBase *> * reinit_mats = nullptr);
/**
* reinit materials on the neighboring element face
* @param blk_id The subdomain on which the neighbor element lives
* @param tid The thread id
* @param swap_stateful Whether to swap stateful material properties between \p MaterialData and
* \p MaterialPropertyStorage
* @param execute_stateful Whether to execute material objects that have stateful properties. This
* should be \p false when for example executing material objects for mortar contexts in which
* stateful properties don't make sense
*/
void reinitMaterialsNeighbor(SubdomainID blk_id,
const THREAD_ID tid,
bool swap_stateful = true,
const std::deque<MaterialBase *> * reinit_mats = nullptr);
/**
* reinit materials on a boundary
* @param boundary_id The boundary on which to reinit corresponding materials
* @param tid The thread id
* @param swap_stateful Whether to swap stateful material properties between \p MaterialData and
* \p MaterialPropertyStorage
* @param execute_stateful Whether to execute material objects that have stateful properties.
* This should be \p false when for example executing material objects for mortar contexts in
* which stateful properties don't make sense
*/
void reinitMaterialsBoundary(BoundaryID boundary_id,
const THREAD_ID tid,
bool swap_stateful = true,
const std::deque<MaterialBase *> * reinit_mats = nullptr);
void
reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful = true);
/*
* Swap back underlying data storing stateful material properties
*/
virtual void swapBackMaterials(const THREAD_ID tid);
virtual void swapBackMaterialsFace(const THREAD_ID tid);
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid);
/**
* Record and set the material properties required by the current computing thread.
* @param mat_prop_ids The set of material properties required by the current computing thread.
*
* @param tid The thread id
*/
void setActiveMaterialProperties(const std::unordered_set<unsigned int> & mat_prop_ids,
const THREAD_ID tid);
/**
* Method to check whether or not a list of active material roperties has been set. This method
* is called by reinitMaterials to determine whether Material computeProperties methods need to be
* called. If the return is False, this check prevents unnecessary material property computation
* @param tid The thread id
*
* @return True if there has been a list of active material properties set, False otherwise
*/
bool hasActiveMaterialProperties(const THREAD_ID tid) const;