forked from idaholab/moose
/
FEProblemBase.h
1405 lines (1136 loc) · 51.4 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
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#ifndef FEPROBLEMBASE_H
#define FEPROBLEMBASE_H
// MOOSE includes
#include "SubProblem.h"
#include "AuxiliarySystem.h"
#include "GeometricSearchData.h"
#include "PostprocessorData.h"
#include "VectorPostprocessorData.h"
#include "Adaptivity.h"
#include "InitialConditionWarehouse.h"
#include "Restartable.h"
#include "SolverParams.h"
#include "PetscSupport.h"
#include "SlepcSupport.h"
#include "MooseApp.h"
#include "ExecuteMooseObjectWarehouse.h"
#include "AuxGroupExecuteMooseObjectWarehouse.h"
#include "MaterialWarehouse.h"
#include "MultiAppTransfer.h"
#include "NonlinearSystem.h"
// libMesh includes
#include "libmesh/enum_quadrature_type.h"
#include <unordered_map>
// Forward declarations
class DisplacedProblem;
class FEProblemBase;
class MooseMesh;
class NonlinearSystemBase;
class RandomInterface;
class RandomData;
class MeshChangedInterface;
class MultiMooseEnum;
class MaterialPropertyStorage;
class MaterialData;
class VectorPostprocessorData;
class MooseEnum;
class Resurrector;
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 GeneralUserObject;
class Function;
class KernelBase;
class IntegratedBC;
// libMesh forward declarations
namespace libMesh
{
class CouplingMatrix;
}
template<>
InputParameters validParams<FEProblemBase>();
enum MooseNonlinearConvergenceReason
{
MOOSE_NONLINEAR_ITERATING = 0,
MOOSE_CONVERGED_FNORM_ABS = 2,
MOOSE_CONVERGED_FNORM_RELATIVE = 3,
MOOSE_CONVERGED_SNORM_RELATIVE = 4,
MOOSE_DIVERGED_FUNCTION_COUNT = -2,
MOOSE_DIVERGED_FNORM_NAN = -4,
MOOSE_DIVERGED_LINE_SEARCH = -6
};
// The idea with these enums is to abstract the reasons for
// convergence/divergence, i.e. they could be used with linear algebra
// packages other than PETSc. They were directly inspired by PETSc,
// though. This enum could also be combined with the
// MooseNonlinearConvergenceReason enum but there might be some
// confusion (?)
enum MooseLinearConvergenceReason
{
MOOSE_LINEAR_ITERATING = 0,
// MOOSE_CONVERGED_RTOL_NORMAL = 1,
// MOOSE_CONVERGED_ATOL_NORMAL = 9,
MOOSE_CONVERGED_RTOL = 2,
MOOSE_CONVERGED_ATOL = 3,
MOOSE_CONVERGED_ITS = 4,
// MOOSE_CONVERGED_CG_NEG_CURVE = 5,
// MOOSE_CONVERGED_CG_CONSTRAINED = 6,
// MOOSE_CONVERGED_STEP_LENGTH = 7,
// MOOSE_CONVERGED_HAPPY_BREAKDOWN = 8,
MOOSE_DIVERGED_NULL = -2,
// MOOSE_DIVERGED_ITS = -3,
// MOOSE_DIVERGED_DTOL = -4,
// MOOSE_DIVERGED_BREAKDOWN = -5,
// MOOSE_DIVERGED_BREAKDOWN_BICG = -6,
// MOOSE_DIVERGED_NONSYMMETRIC = -7,
// MOOSE_DIVERGED_INDEFINITE_PC = -8,
MOOSE_DIVERGED_NANORINF = -9,
// MOOSE_DIVERGED_INDEFINITE_MAT = -10
MOOSE_DIVERGED_PCSETUP_FAILED = -11
};
/**
* Specialization of SubProblem for solving nonlinear equations plus auxiliary equations
*
*/
class FEProblemBase :
public SubProblem,
public Restartable
{
public:
FEProblemBase(const InputParameters & parameters);
virtual ~FEProblemBase();
virtual EquationSystems & es() override { return _eq; }
virtual MooseMesh & mesh() override { return _mesh; }
virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) override;
virtual 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
*/
void setCouplingMatrix(std::unique_ptr<CouplingMatrix> cm);
// DEPRECATED METHOD
void setCouplingMatrix(CouplingMatrix * cm);
const CouplingMatrix * couplingMatrix() { return _cm.get(); }
/// Set custom coupling matrix for variables requiring nonlocal contribution
void setNonlocalCouplingMatrix();
bool areCoupled(unsigned int ivar, unsigned int jvar);
std::vector<std::pair<MooseVariable *, MooseVariable *> > & couplingEntries(THREAD_ID tid);
std::vector<std::pair<MooseVariable *, MooseVariable *> > & nonlocalCouplingEntries(THREAD_ID tid);
/**
* Check for converence of the nonlinear solution
* @param msg Error message that gets sent back to the solver
* @param it Iteration counter
* @param xnorm Norm of the solution vector
* @param snorm Norm of the change in the solution vector
* @param fnorm Norm of the residual vector
* @param rtol Relative residual convergence tolerance
* @param stol Solution change convergence tolerance
* @param abstol Absolute residual convergence tolerance
* @param nfuncs Number of function evaluations
* @param max_funcs Maximum Number of function evaluations
* @param initial_residual_before_preset_bcs Residual norm prior to imposition of PresetBC values on solution vector
* @param div_threshold Maximum value of residual before triggering divergence check
*/
virtual MooseNonlinearConvergenceReason checkNonlinearConvergence(std::string &msg,
const PetscInt it,
const Real xnorm,
const Real snorm,
const Real fnorm,
const Real rtol,
const Real stol,
const Real abstol,
const PetscInt nfuncs,
const PetscInt max_funcs,
const Real initial_residual_before_preset_bcs,
const Real div_threshold);
/**
* Check for convergence of the linear solution
* @param msg Error message that gets sent back to the solver
* @param n Iteration counter
* @param rnorm Norm of the residual vector
* @param rtol Relative residual convergence tolerance
* @param atol Absolute residual convergence tolerance
* @param dtol Divergence tolerance
* @param maxits Maximum number of linear iterations allowed
*/
virtual MooseLinearConvergenceReason checkLinearConvergence(std::string &msg,
const PetscInt n,
const Real rnorm,
const Real rtol,
const Real atol,
const Real dtol,
const PetscInt maxits);
virtual bool hasVariable(const std::string & var_name) override;
virtual MooseVariable & getVariable(THREAD_ID tid, const std::string & var_name) override;
virtual bool hasScalarVariable(const std::string & var_name) override;
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, 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<MooseVariable *> & moose_vars, THREAD_ID tid) override;
/**
* Get the MOOSE variables to be reinited on each element.
*
* @param tid The thread id
*/
virtual const std::set<MooseVariable *> & getActiveElementalMooseVariables(THREAD_ID tid) override;
/**
* Whether or not a list of active elemental moose variables has been set.
*
* @return True if there has been a list of active elemental moose variables set, False otherwise
*/
virtual bool hasActiveElementalMooseVariables(THREAD_ID tid) override;
/**
* Clear the active elemental MooseVariable. 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 MooseVariables
*
* @param tid The thread id
*/
virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override;
virtual void setActiveMaterialProperties(const std::set<unsigned int> & mat_prop_ids, THREAD_ID tid) override;
virtual const std::set<unsigned int> & getActiveMaterialProperties(THREAD_ID tid) override;
virtual bool hasActiveMaterialProperties(THREAD_ID tid) override;
virtual void clearActiveMaterialProperties(THREAD_ID tid) override;
virtual void createQRules(QuadratureType type, Order order, Order volume_order=INVALID_ORDER, Order face_order=INVALID_ORDER);
/**
* @return The maximum number of quadrature points in use on any element in this problem.
*/
unsigned int getMaxQps() const;
/**
* @return The maximum number of quadrature points in use on any element in this problem.
*/
unsigned int getMaxShapeFunctions() const;
/**
* @return The maximum order for all scalar variables in this problem's systems.
*/
Order getMaxScalarOrder() const;
/**
* @return Flag indicating nonlocal coupling exists or not.
*/
void checkNonlocalCoupling();
void checkUserObjectJacobianRequirement(THREAD_ID tid);
void setVariableAllDoFMap(const std::vector<MooseVariable *> moose_vars);
const std::vector<MooseVariable *> & getUserObjectJacobianVariables(THREAD_ID tid) const { return _uo_jacobian_moose_vars[tid]; }
virtual Assembly & assembly(THREAD_ID tid) override { return *_assembly[tid]; }
/**
* Returns a list of all the variables in the problem (both from the NL and Aux systems.
*/
virtual std::vector<VariableName> getVariableNames();
virtual void initialSetup();
virtual void timestepSetup();
virtual void prepare(const Elem * elem, THREAD_ID tid) override;
virtual void prepareFace(const Elem * elem, THREAD_ID tid) override;
virtual void prepare(const Elem * elem, unsigned int ivar, unsigned int jvar, const std::vector<dof_id_type> & dof_indices, THREAD_ID tid) override;
virtual void prepareAssembly(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, THREAD_ID tid);
virtual bool reinitDirac(const Elem * elem, THREAD_ID tid) override;
virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
virtual void reinitElemPhys(const Elem * elem, std::vector<Point> phys_points_in_elem, THREAD_ID tid) override;
virtual void reinitElemFace(const Elem * elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override;
virtual void reinitNode(const Node * node, THREAD_ID tid) override;
virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid) override;
virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid) override;
virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid) override;
virtual void reinitNeighbor(const Elem * elem, unsigned int side, THREAD_ID tid) override;
virtual void reinitNeighborPhys(const Elem * neighbor, unsigned int neighbor_side, const std::vector<Point> & physical_points, THREAD_ID tid) override;
virtual void reinitNeighborPhys(const Elem * neighbor, const std::vector<Point> & physical_points, THREAD_ID tid) override;
virtual void reinitNodeNeighbor(const Node * node, THREAD_ID tid) override;
virtual void reinitScalars(THREAD_ID tid) override;
virtual void reinitOffDiagScalars(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, THREAD_ID tid);
virtual void newAssemblyArray(NonlinearSystemBase & nl);
virtual void deleteAssemblyArray();
virtual void initNullSpaceVectors(const InputParameters & parameters, NonlinearSystemBase & nl);
/**
* Whether or not this problem should utilize FE shape function caching.
*
* @param fe_cache True for using the cache false for not.
*/
virtual void useFECache(bool fe_cache) override;
virtual void init() override;
virtual void solve() override;
/**
* Set an exception. Usually this should not be directly called - but should be called through the mooseException() macro.
*
* @param message The error message about the exception.
*/
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 stop the solve.
*
* Note: Collective on MPI! Must be called simultaneously by all processors!
*
* Also: This will throw a MooseException!
*
* Note: DO NOT CALL THIS IN A THREADED REGION! This is meant to be called just after a threaded section.
*/
virtual void checkExceptionAndStopSolve();
virtual bool converged() override;
virtual unsigned int nNonlinearIterations() override;
virtual unsigned int nLinearIterations() override;
virtual Real finalNonlinearResidual() override;
virtual bool computingInitialResidual() override;
/**
* Returns true if we are currently computing Jacobian
*/
virtual bool currentlyComputingJacobian() { return _currently_computing_jacobian; }
/**
* Returns true if we are in or beyond the initialSetup stage
*/
virtual bool startedInitialSetup() { return _started_initial_setup; }
/**
* The relative L2 norm of the difference between solution and old solution vector.
*/
virtual Real relativeSolutionDifferenceNorm();
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; }
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();
/**
* 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);
///@{
/**
* 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
*/
void initPetscOutput();
#ifdef LIBMESH_HAVE_PETSC
/**
* Retrieve a writable reference the PETSc options (used by PetscSupport)
*/
Moose::PetscSupport::PetscOptions & getPetscOptions(){ return _petsc_options; }
#endif //LIBMESH_HAVE_PETSC
// Function /////
virtual void addFunction(std::string type, const std::string & name, InputParameters parameters);
virtual bool hasFunction(const std::string & name, THREAD_ID tid = 0);
virtual Function & getFunction(const std::string & name, THREAD_ID tid = 0);
// NL /////
NonlinearSystemBase & getNonlinearSystemBase() { return *_nl; }
virtual NonlinearSystem & getNonlinearSystem() { mooseDeprecated("FEProblemBase::getNonlinearSystem() is deprecated, please use FEProblemBase::getNonlinearSystemBase() \n"); return *(dynamic_cast<NonlinearSystem *>(_nl)); }
void addVariable(const std::string & var_name, const FEType & type, Real scale_factor, const std::set< SubdomainID > * const active_subdomains = NULL);
void addScalarVariable(const std::string & var_name, Order order, Real scale_factor = 1., const std::set< SubdomainID > * const active_subdomains = NULL);
void addKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
void addNodalKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
void addScalarKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
void addBoundaryCondition(const std::string & bc_name, const std::string & name, InputParameters parameters);
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 /////
void addAuxVariable(const std::string & var_name, const FEType & type, const std::set< SubdomainID > * const active_subdomains = NULL);
void addAuxScalarVariable(const std::string & var_name, Order order, Real scale_factor = 1., const std::set< SubdomainID > * const active_subdomains = NULL);
void addAuxKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
void addAuxScalarKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
AuxiliarySystem & getAuxiliarySystem() { return *_aux; }
// Dirac /////
void addDiracKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
// DG /////
void addDGKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
// Interface /////
void addInterfaceKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
// IC /////
void addInitialCondition(const std::string & ic_name, const std::string & name, InputParameters parameters);
void projectSolution();
// Materials /////
void addMaterial(const std::string & kernel_name, const std::string & name, InputParameters parameters);
/**
* Add the MooseVariables that the current materials depend on to the dependency list.
*
* This MUST be done after the dependency list has been set for all the other objects!
*/
virtual void prepareMaterials(SubdomainID blk_id, THREAD_ID tid);
virtual void reinitMaterials(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful = true);
virtual void reinitMaterialsFace(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful = true);
virtual void reinitMaterialsNeighbor(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful = true);
virtual void reinitMaterialsBoundary(BoundaryID boundary_id, THREAD_ID tid, bool swap_stateful = true);
/*
* Swap back underlying data storing stateful material properties
*/
virtual void swapBackMaterials(THREAD_ID tid);
virtual void swapBackMaterialsFace(THREAD_ID tid);
virtual void swapBackMaterialsNeighbor(THREAD_ID tid);
// Postprocessors /////
virtual void addPostprocessor(std::string pp_name, const std::string & name, InputParameters parameters);
// VectorPostprocessors /////
virtual void addVectorPostprocessor(std::string pp_name, const std::string & name, InputParameters parameters);
/**
* Initializes the postprocessor data
* @see SetupPostprocessorDataAction
*/
void initPostprocessorData(const std::string & name);
// UserObjects /////
virtual void addUserObject(std::string user_object_name, const std::string & name, InputParameters parameters);
/**
* Return the storage of all UserObjects.
*
* @see AdvancedOutput::initPostprocessorOrVectorPostprocessorLists
*/
const ExecuteMooseObjectWarehouse<UserObject> & getUserObjects() { return _all_user_objects; }
/**
* Get the user object by its name
* @param name The name of the user object being retrieved
* @return Const reference to the user object
*/
template <class T>
const T & getUserObject(const std::string & name, unsigned int tid = 0)
{
if (_all_user_objects.hasActiveObject(name, tid))
return *(std::dynamic_pointer_cast<T>(_all_user_objects.getActiveObject(name, tid)));
mooseError("Unable to find user object with name '" + name + "'");
}
/**
* Get the user object by its name
* @param name The name of the user object being retrieved
* @return Const reference to the user object
*/
const UserObject & getUserObjectBase(const std::string & name);
/**
* Check if there if a user object of given name
* @param name The name of the user object being checked for
* @return true if the user object exists, false otherwise
*/
bool hasUserObject(const std::string & name);
/**
* Check existence of the postprocessor.
* @param name The name of the post-processor
* @return true if it exists, otherwise false
*/
bool hasPostprocessor(const std::string & name);
/**
* Get a reference to the value associated with the postprocessor.
*/
PostprocessorValue & getPostprocessorValue(const PostprocessorName & name);
/**
* Get the reference to the old value of a post-processor
* @param name The name of the post-processor
* @return The reference to the old value
*/
PostprocessorValue & getPostprocessorValueOld(const std::string & name);
/**
* Get the reference to the older value of a post-processor
* @param name The name of the post-processor
* @return The reference to the old value
*/
PostprocessorValue & getPostprocessorValueOlder(const std::string & name);
/**
* Returns whether or not the current simulation has any multiapps
*/
bool hasMultiApps() const { return _multi_apps.hasActiveObjects(); }
bool hasMultiApp(const std::string & name);
/**
* Check existence of the VectorPostprocessor.
* @param name The name of the post-processor
* @return true if it exists, otherwise false
*/
bool hasVectorPostprocessor(const std::string & name);
/**
* Get a reference to the value associated with the VectorPostprocessor.
* @param name The name of the post-processor
* @param vector_name The name of the post-processor
* @return The reference to the current value
*/
VectorPostprocessorValue & getVectorPostprocessorValue(const VectorPostprocessorName & name, const std::string & vector_name);
/**
* Get the reference to the old value of a post-processor
* @param name The name of the post-processor
* @param vector_name The name of the post-processor
* @return The reference to the old value
*/
VectorPostprocessorValue & getVectorPostprocessorValueOld(const std::string & name, const std::string & vector_name);
/**
* Declare a new VectorPostprocessor vector
* @param name The name of the post-processor
* @param vector_name The name of the post-processor
* @return The reference to the vector declared
*/
VectorPostprocessorValue & declareVectorPostprocessorVector(const VectorPostprocessorName & name, const std::string & vector_name);
/**
* Whether or not the specified VectorPostprocessor has declared any vectors
*/
bool vectorPostprocessorHasVectors(const std::string & vpp_name) { return _vpps_data.hasVectors(vpp_name); }
/**
* Get the vectors for a specific VectorPostprocessor.
* @param vpp_name The name of the VectorPostprocessor
*/
const std::map<std::string, VectorPostprocessorData::VectorPostprocessorState> & getVectorPostprocessorVectors(const std::string & vpp_name);
// Dampers /////
void addDamper(std::string damper_name, const std::string & name, InputParameters parameters);
void setupDampers();
/**
* Whether or not this system has dampers.
*/
bool hasDampers() { return _has_dampers; }
// Indicators /////
void addIndicator(std::string indicator_name, const std::string & name, InputParameters parameters);
// Markers //////
void addMarker(std::string marker_name, const std::string & name, InputParameters parameters);
/**
* Add a MultiApp to the problem.
*/
void addMultiApp(const std::string & multi_app_name, const std::string & name, InputParameters parameters);
/**
* Get a MultiApp object by name.
*/
std::shared_ptr<MultiApp> getMultiApp(const std::string & multi_app_name);
/**
* Get Transfers by ExecFlagType and direction
*/
std::vector<std::shared_ptr<Transfer>> getTransfers(ExecFlagType type, MultiAppTransfer::DIRECTION direction) const;
/**
* Execute MultiAppTransfers associate with execution flag and direction.
* @param type The execution flag to execute.
* @param direction The direction (to or from) to transfer.
*/
void execMultiAppTransfers(ExecFlagType type, MultiAppTransfer::DIRECTION direction);
/**
* Execute the MultiApps associated with the ExecFlagType
*/
bool execMultiApps(ExecFlagType type, bool auto_advance = true);
/**
* Advance the MultiApps associated with the ExecFlagType
*/
void advanceMultiApps(ExecFlagType type);
/**
* Backup the MultiApps associated with the ExecFlagType
*/
void backupMultiApps(ExecFlagType type);
/**
* Restore the MultiApps associated with the ExecFlagType
* @param force Force restoration because something went wrong with the solve
*/
void restoreMultiApps(ExecFlagType type, bool force=false);
/**
* Find the smallest timestep over all MultiApps
*/
Real computeMultiAppsDT(ExecFlagType type);
/**
* Add a Transfer to the problem.
*/
void addTransfer(const std::string & transfer_name, const std::string & name, InputParameters parameters);
/**
* Execute the Transfers associated with the ExecFlagType
*
* Note: This does _not_ execute MultiApp Transfers!
* Those are executed automatically when MultiApps are executed.
*/
void execTransfers(ExecFlagType type);
/// Evaluates transient residual G in canonical semidiscrete form G(t,U,Udot) = F(t,U)
void computeTransientImplicitResidual(Real time, const NumericVector<Number>& u, const NumericVector<Number>& udot, NumericVector<Number>& residual);
/// Evaluates transient Jacobian J_a = dG/dU + a*dG/dUdot from canonical semidiscrete form G(t,U,Udot) = F(t,U)
void computeTransientImplicitJacobian(Real time, const NumericVector<Number>& u, const NumericVector<Number>& udot, Real shift, SparseMatrix<Number> &jacobian);
////
/**
* Computes the residual using whatever is sitting in the current solution vector then returns the L2 norm.
*
* @return The L2 norm of the residual
*/
virtual Real computeResidualL2Norm();
virtual void computeResidual(NonlinearImplicitSystem & sys, const NumericVector<Number> & soln, NumericVector<Number> & residual);
virtual void computeResidual(const NumericVector<Number> & soln, NumericVector<Number> & residual);
virtual void computeResidualType(const NumericVector<Number> & soln, NumericVector<Number> & residual, Moose::KernelType type = Moose::KT_ALL);
virtual void computeJacobian(NonlinearImplicitSystem & sys, const NumericVector<Number> & soln, SparseMatrix<Number> & jacobian);
virtual void computeJacobian(const NumericVector<Number> & soln, SparseMatrix<Number> & jacobian, Moose::KernelType kernel_type = Moose::KT_ALL);
/**
* Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices.
*
* Used by Physics-based preconditioning
*
* @param blocks The blocks to fill in (JacobianBlock is defined in ComputeJacobianBlocksThread)
*/
virtual void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks);
/**
* Really not a good idea to use this.
*
* It computes just one block of the Jacobian into a smaller matrix. Calling this in a loop is EXTREMELY ineffecient!
* Try to use computeJacobianBlocks() instead!
*
* @param jacobian The matrix you want to fill
* @param precond_system The libMesh::system of the preconditioning system
* @param ivar the block-row of the Jacobian
* @param jvar the block-column of the Jacobian
*
*/
virtual void computeJacobianBlock(SparseMatrix<Number> & jacobian, libMesh::System & precond_system, unsigned int ivar, unsigned int jvar);
virtual Real computeDamping(const NumericVector<Number>& soln, const NumericVector<Number>& update);
/**
* Check to see whether the problem should update the solution
* @return true if the problem should update the solution, false otherwise
*/
virtual bool shouldUpdateSolution();
/**
* Update the solution
* @param vec_solution Local solution vector that gets modified by this method
* @param ghosted_solution Ghosted solution vector
* @return true if the solution was modified, false otherwise
*/
virtual bool updateSolution(NumericVector<Number>& vec_solution, NumericVector<Number>& ghosted_solution);
/**
* Perform cleanup tasks after application of predictor to solution vector
* @param ghosted_solution Ghosted solution vector
*/
virtual void predictorCleanup(NumericVector<Number>& ghosted_solution);
virtual void computeBounds(NonlinearImplicitSystem & sys, NumericVector<Number> & lower, NumericVector<Number> & upper);
virtual void computeNearNullSpace(NonlinearImplicitSystem & sys, std::vector<NumericVector<Number>*> &sp);
virtual void computeNullSpace(NonlinearImplicitSystem & sys, std::vector<NumericVector<Number>*> &sp);
virtual void computeTransposeNullSpace(NonlinearImplicitSystem & sys, std::vector<NumericVector<Number>*> &sp);
virtual void computePostCheck(NonlinearImplicitSystem & sys,
const NumericVector<Number> & old_soln,
NumericVector<Number> & search_direction,
NumericVector<Number> & new_soln,
bool & changed_search_direction,
bool & changed_new_soln);
virtual void computeIndicatorsAndMarkers();
virtual void computeIndicators();
virtual void computeMarkers();
virtual NumericVector<Number> & residualVector(Moose::KernelType type);
virtual void addResidual(THREAD_ID tid) override;
virtual void addResidualNeighbor(THREAD_ID tid) override;
virtual void addResidualScalar(THREAD_ID tid = 0);
virtual void cacheResidual(THREAD_ID tid) override;
virtual void cacheResidualNeighbor(THREAD_ID tid) override;
virtual void addCachedResidual(THREAD_ID tid) override;
/**
* Allows for all the residual contributions that are currently cached to be added directly into the vector passed in.
*
* @param residual The vector to add the cached contributions to.
* @param tid The thread id.
*/
virtual void addCachedResidualDirectly(NumericVector<Number> & residual, THREAD_ID tid);
virtual void setResidual(NumericVector<Number> & residual, THREAD_ID tid) override;
virtual void setResidualNeighbor(NumericVector<Number> & residual, THREAD_ID tid) override;
virtual void addJacobian(SparseMatrix<Number> & jacobian, THREAD_ID tid) override;
virtual void addJacobianNeighbor(SparseMatrix<Number> & jacobian, THREAD_ID tid) override;
virtual void addJacobianBlock(SparseMatrix<Number> & jacobian, unsigned int ivar, unsigned int jvar, const DofMap & dof_map, std::vector<dof_id_type> & dof_indices, THREAD_ID tid) override;
virtual 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, THREAD_ID tid) override;
virtual void addJacobianScalar(SparseMatrix<Number> & jacobian, THREAD_ID tid = 0);
virtual void addJacobianOffDiagScalar(SparseMatrix<Number> & jacobian, unsigned int ivar, THREAD_ID tid = 0);
virtual void cacheJacobian(THREAD_ID tid) override;
virtual void cacheJacobianNeighbor(THREAD_ID tid) override;
virtual void addCachedJacobian(SparseMatrix<Number> & jacobian, THREAD_ID tid) override;
virtual void prepareShapes(unsigned int var, THREAD_ID tid) override;
virtual void prepareFaceShapes(unsigned int var, THREAD_ID tid) override;
virtual void prepareNeighborShapes(unsigned int var, THREAD_ID tid) override;
// Displaced problem /////
virtual void addDisplacedProblem(std::shared_ptr<DisplacedProblem> displaced_problem);
virtual std::shared_ptr<DisplacedProblem> getDisplacedProblem() { return _displaced_problem; }
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type = GeometricSearchData::ALL) override;
virtual void possiblyRebuildGeomSearchPatches();
virtual GeometricSearchData & geomSearchData() override { return _geometric_search_data; }
/**
* Communicate to the Resurector the name of the restart filer
* @param file_name The file name for restarting from
*/
void setRestartFile(const std::string & file_name);
///@{
/**
* Return a reference to the material property storage
* @return A const reference to the material property storage
*/
const MaterialPropertyStorage & getMaterialPropertyStorage() { return _material_props; }
const MaterialPropertyStorage & getBndMaterialPropertyStorage() { return _bnd_material_props; }
///@}
///@{
/**
* Return indicator/marker storage.
*/
const MooseObjectWarehouse<Indicator> & getIndicatorWarehouse() { return _indicators; }
const MooseObjectWarehouse<InternalSideIndicator> & getInternalSideIndicatorWarehouse() { return _internal_side_indicators; }
const MooseObjectWarehouse<Marker> & getMarkerWarehouse() { return _markers; }
///@}
/**
* Return InitialCondition storage
*/
const InitialConditionWarehouse & getInitialConditionWarehouse() const { return _ics; }
/**
* Get the solver parameters
*/
SolverParams & solverParams();
#ifdef LIBMESH_ENABLE_AMR
// Adaptivity /////
Adaptivity & adaptivity() { return _adaptivity; }
virtual void initialAdaptMesh();
virtual void adaptMesh();
/**
* @return The number of adaptivity cycles completed.
*/
unsigned int getNumCyclesCompleted() { return _cycles_completed; }
#endif //LIBMESH_ENABLE_AMR
/// Create XFEM controller object
void initXFEM(std::shared_ptr<XFEMInterface> xfem);
/// Get a pointer to the XFEM controller object
std::shared_ptr<XFEMInterface> getXFEM(){return _xfem;}
/// Find out whether the current analysis is using XFEM
bool haveXFEM() { return _xfem != NULL; }
/// Update the mesh due to changing XFEM cuts
virtual bool updateMeshXFEM();
virtual void meshChanged() override;
/**
* Register an object that derives from MeshChangedInterface
* to be notified when the mesh changes.
*/
void notifyWhenMeshChanges(MeshChangedInterface * mci);
virtual void checkProblemIntegrity();
void serializeSolution();
// debugging iface /////
void setKernelTypeResidual(Moose::KernelType kt) { _kernel_type = kt; }
/**
* Set flag that Jacobian is constant (for optimization purposes)
* @param state True if the Jacobian is constant, false otherwise
*/
void setConstJacobian(bool state) { _const_jacobian = state; }
void registerRandomInterface(RandomInterface & random_interface, const std::string & name);
void setKernelCoverageCheck(bool flag) { _kernel_coverage_check = flag; }
void setMaterialCoverageCheck(bool flag) { _material_coverage_check = flag; }
/**
* Updates the active boundary id
* @param id The BoundaryID to set as active
*
* The BoundaryRestrictable class has a member, _boundary_id, that is set
* to the boundary id that is being operated on, this method is used to set the value
* to which the BoundaryRestrictable class references.
*
* @see BoundaryRestrictable ComputeUserObjectThread::onBoundary
*/
void setCurrentBoundaryID(BoundaryID id){ _current_boundary_id = id; }
/**
* Return a reference to the active BoundaryID
* @return constant reference to the active BoundaryID
*
* @see setActiveBoundaryID
*/
const BoundaryID & getCurrentBoundaryID(){ return _current_boundary_id; }
/**
* Calls parentOutputPositionChanged() on all sub apps.
*/
void parentOutputPositionChanged();
///@{
/**
* These methods are used to determine whether stateful material properties need to be stored on
* internal sides. There are four situations where this may be the case: 1) DGKernels
* 2) IntegratedBCs 3)InternalSideUserObjects 4)ElementalAuxBCs
*
* Method 1:
* @param bnd_id the boundary id for which to see if stateful material properties need to be stored
* @param tid the THREAD_ID of the caller
* @return Boolean indicating whether material properties need to be stored
*
* Method 2:
* @param subdomain_id the subdomain id for which to see if stateful material properties need to be stored
* @param tid the THREAD_ID of the caller
* @return Boolean indicating whether material properties need to be stored
*/
bool needMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid);
bool needMaterialOnSide(SubdomainID subdomain_id, THREAD_ID tid);
///@}
/**
* Dimension of the subspace spanned by vectors with a given prefix.
* @param prefix Prefix of the vectors spanning the subspace.
*/
unsigned int subspaceDim(const std::string& prefix) const {if (_subspace_dim.count(prefix)) return _subspace_dim.find(prefix)->second; else return 0;}
/*
* Return a reference to the material warehouse of *all* Material objects.
*/
const MaterialWarehouse & getMaterialWarehouse() { return _all_materials; }
/*
* Return a reference to the material warehouse of Material objects to be computed.
*/
const MaterialWarehouse & getComputeMaterialWarehouse() { return _materials; }
const MaterialWarehouse & getDiscreteMaterialWarehouse() { return _discrete_materials; }
/**