Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
3 : //*
4 : //* All rights reserved, see COPYRIGHT for full restrictions
5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 : //*
7 : //* Licensed under LGPL 2.1, please see LICENSE for details
8 : //* https://www.gnu.org/licenses/lgpl-2.1.html
9 :
10 : #pragma once
11 :
12 : // MOOSE includes
13 : #include "SubProblem.h"
14 : #include "GeometricSearchData.h"
15 : #include "MeshDivision.h"
16 : #include "MortarData.h"
17 : #include "ReporterData.h"
18 : #include "Adaptivity.h"
19 : #include "InitialConditionWarehouse.h"
20 : #include "FVInitialConditionWarehouse.h"
21 : #include "ScalarInitialConditionWarehouse.h"
22 : #include "Restartable.h"
23 : #include "SolverParams.h"
24 : #include "PetscSupport.h"
25 : #include "MooseApp.h"
26 : #include "ExecuteMooseObjectWarehouse.h"
27 : #include "MaterialWarehouse.h"
28 : #include "MooseVariableFE.h"
29 : #include "MultiAppTransfer.h"
30 : #include "Postprocessor.h"
31 : #include "HashMap.h"
32 : #include "VectorPostprocessor.h"
33 : #include "PerfGraphInterface.h"
34 : #include "Attributes.h"
35 : #include "MooseObjectWarehouse.h"
36 : #include "MaterialPropertyRegistry.h"
37 : #include "RestartableEquationSystems.h"
38 : #include "SolutionInvalidity.h"
39 : #include "PetscSupport.h"
40 :
41 : #include "libmesh/enum_quadrature_type.h"
42 : #include "libmesh/equation_systems.h"
43 :
44 : #include <unordered_map>
45 : #include <memory>
46 :
47 : // Forward declarations
48 : class AuxiliarySystem;
49 : class DisplacedProblem;
50 : class MooseMesh;
51 : class NonlinearSystemBase;
52 : class LinearSystem;
53 : class SolverSystem;
54 : class NonlinearSystem;
55 : class RandomInterface;
56 : class RandomData;
57 : class MeshChangedInterface;
58 : class MeshDisplacedInterface;
59 : class MultiMooseEnum;
60 : class MaterialPropertyStorage;
61 : class MaterialData;
62 : class MooseEnum;
63 : class Assembly;
64 : class JacobianBlock;
65 : class Control;
66 : class MultiApp;
67 : class TransientMultiApp;
68 : class ScalarInitialCondition;
69 : class Indicator;
70 : class InternalSideIndicatorBase;
71 : class Marker;
72 : class Material;
73 : class Transfer;
74 : class XFEMInterface;
75 : class SideUserObject;
76 : class NodalUserObject;
77 : class ElementUserObject;
78 : class InternalSideUserObject;
79 : class InterfaceUserObject;
80 : class GeneralUserObject;
81 : class Positions;
82 : class Function;
83 : class Distribution;
84 : class Sampler;
85 : class KernelBase;
86 : class IntegratedBCBase;
87 : class LineSearch;
88 : class UserObject;
89 : class AutomaticMortarGeneration;
90 : class VectorPostprocessor;
91 : class Convergence;
92 : class MooseAppCoordTransform;
93 : class MortarUserObject;
94 : class SolutionInvalidity;
95 :
96 : // libMesh forward declarations
97 : namespace libMesh
98 : {
99 : class CouplingMatrix;
100 : class NonlinearImplicitSystem;
101 : class LinearImplicitSystem;
102 : } // namespace libMesh
103 :
104 : enum class MooseLinearConvergenceReason
105 : {
106 : ITERATING = 0,
107 : // CONVERGED_RTOL_NORMAL = 1,
108 : // CONVERGED_ATOL_NORMAL = 9,
109 : CONVERGED_RTOL = 2,
110 : CONVERGED_ATOL = 3,
111 : CONVERGED_ITS = 4,
112 : // CONVERGED_CG_NEG_CURVE = 5,
113 : // CONVERGED_CG_CONSTRAINED = 6,
114 : // CONVERGED_STEP_LENGTH = 7,
115 : // CONVERGED_HAPPY_BREAKDOWN = 8,
116 : DIVERGED_NULL = -2,
117 : // DIVERGED_ITS = -3,
118 : // DIVERGED_DTOL = -4,
119 : // DIVERGED_BREAKDOWN = -5,
120 : // DIVERGED_BREAKDOWN_BICG = -6,
121 : // DIVERGED_NONSYMMETRIC = -7,
122 : // DIVERGED_INDEFINITE_PC = -8,
123 : DIVERGED_NANORINF = -9,
124 : // DIVERGED_INDEFINITE_MAT = -10
125 : DIVERGED_PCSETUP_FAILED = -11
126 : };
127 :
128 : /**
129 : * Specialization of SubProblem for solving nonlinear equations plus auxiliary equations
130 : *
131 : */
132 : class FEProblemBase : public SubProblem, public Restartable
133 : {
134 : public:
135 : static InputParameters validParams();
136 :
137 : FEProblemBase(const InputParameters & parameters);
138 : virtual ~FEProblemBase();
139 :
140 : enum class CoverageCheckMode
141 : {
142 : FALSE,
143 : TRUE,
144 : OFF,
145 : ON,
146 : SKIP_LIST,
147 : ONLY_LIST,
148 : };
149 :
150 1629455 : virtual libMesh::EquationSystems & es() override { return _req.set().es(); }
151 76150230 : virtual MooseMesh & mesh() override { return _mesh; }
152 2463185334 : virtual const MooseMesh & mesh() const override { return _mesh; }
153 : const MooseMesh & mesh(bool use_displaced) const override;
154 :
155 : void setCoordSystem(const std::vector<SubdomainName> & blocks, const MultiMooseEnum & coord_sys);
156 : void setAxisymmetricCoordAxis(const MooseEnum & rz_coord_axis);
157 :
158 : /**
159 : * Set the coupling between variables
160 : * TODO: allow user-defined coupling
161 : * @param type Type of coupling
162 : */
163 : void setCoupling(Moose::CouplingType type);
164 :
165 517675 : Moose::CouplingType coupling() const { return _coupling; }
166 :
167 : /**
168 : * Set custom coupling matrix
169 : * @param cm coupling matrix to be set
170 : * @param nl_sys_num which nonlinear system we are setting the coupling matrix for
171 : */
172 : void setCouplingMatrix(std::unique_ptr<libMesh::CouplingMatrix> cm,
173 : const unsigned int nl_sys_num);
174 :
175 : // DEPRECATED METHOD
176 : void setCouplingMatrix(libMesh::CouplingMatrix * cm, const unsigned int nl_sys_num);
177 :
178 : const libMesh::CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const override;
179 :
180 : /// Set custom coupling matrix for variables requiring nonlocal contribution
181 : void setNonlocalCouplingMatrix();
182 :
183 : bool
184 : areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const;
185 :
186 : /**
187 : * Whether or not MOOSE will perform a user object/auxiliary kernel state check
188 : */
189 : bool hasUOAuxStateCheck() const { return _uo_aux_state_check; }
190 :
191 : /**
192 : * Return a flag to indicate whether we are executing user objects and auxliary kernels for state
193 : * check
194 : * Note: This function can return true only when hasUOAuxStateCheck() returns true, i.e. the check
195 : * has been activated by users through Problem/check_uo_aux_state input parameter.
196 : */
197 4204 : bool checkingUOAuxState() const { return _checking_uo_aux_state; }
198 :
199 : /**
200 : * Whether to trust the user coupling matrix even if we want to do things like be paranoid and
201 : * create a full coupling matrix. See https://github.com/idaholab/moose/issues/16395 for detailed
202 : * background
203 : */
204 : void trustUserCouplingMatrix();
205 :
206 : std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> &
207 : couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num);
208 : std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> &
209 : nonlocalCouplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num);
210 :
211 : virtual bool hasVariable(const std::string & var_name) const override;
212 : // NOTE: hasAuxiliaryVariable defined in parent class
213 : bool hasSolverVariable(const std::string & var_name) const;
214 : using SubProblem::getVariable;
215 : virtual const MooseVariableFieldBase &
216 : getVariable(const THREAD_ID tid,
217 : const std::string & var_name,
218 : Moose::VarKindType expected_var_type = Moose::VarKindType::VAR_ANY,
219 : Moose::VarFieldType expected_var_field_type =
220 : Moose::VarFieldType::VAR_FIELD_ANY) const override;
221 : MooseVariableFieldBase & getActualFieldVariable(const THREAD_ID tid,
222 : const std::string & var_name) override;
223 : virtual MooseVariable & getStandardVariable(const THREAD_ID tid,
224 : const std::string & var_name) override;
225 : virtual VectorMooseVariable & getVectorVariable(const THREAD_ID tid,
226 : const std::string & var_name) override;
227 : virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid,
228 : const std::string & var_name) override;
229 :
230 : virtual bool hasScalarVariable(const std::string & var_name) const override;
231 : virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid,
232 : const std::string & var_name) override;
233 : virtual libMesh::System & getSystem(const std::string & var_name) override;
234 :
235 : /**
236 : * Set the MOOSE variables to be reinited on each element.
237 : * @param moose_vars A set of variables that need to be reinited each time reinit() is called.
238 : *
239 : * @param tid The thread id
240 : */
241 : virtual void setActiveElementalMooseVariables(const std::set<MooseVariableFEBase *> & moose_vars,
242 : const THREAD_ID tid) override;
243 :
244 : /**
245 : * Clear the active elemental MooseVariableFEBase. If there are no active variables then they
246 : * will all be reinited. Call this after finishing the computation that was using a restricted set
247 : * of MooseVariableFEBases
248 : *
249 : * @param tid The thread id
250 : */
251 : virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override;
252 :
253 : virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) override;
254 :
255 : virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) override;
256 :
257 : virtual void setActiveFEVariableCoupleableVectorTags(std::set<TagID> & vtags,
258 : const THREAD_ID tid) override;
259 :
260 : virtual void setActiveFEVariableCoupleableMatrixTags(std::set<TagID> & mtags,
261 : const THREAD_ID tid) override;
262 :
263 : virtual void clearActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) override;
264 :
265 : virtual void clearActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) override;
266 :
267 : virtual void setActiveScalarVariableCoupleableVectorTags(std::set<TagID> & vtags,
268 : const THREAD_ID tid) override;
269 :
270 : virtual void setActiveScalarVariableCoupleableMatrixTags(std::set<TagID> & mtags,
271 : const THREAD_ID tid) override;
272 :
273 : virtual void createQRules(libMesh::QuadratureType type,
274 : libMesh::Order order,
275 : libMesh::Order volume_order = libMesh::INVALID_ORDER,
276 : libMesh::Order face_order = libMesh::INVALID_ORDER,
277 : SubdomainID block = Moose::ANY_BLOCK_ID,
278 : bool allow_negative_qweights = true);
279 :
280 : /**
281 : * Increases the element/volume quadrature order for the specified mesh
282 : * block if and only if the current volume quadrature order is lower. This
283 : * can only cause the quadrature level to increase. If volume_order is
284 : * lower than or equal to the current volume/elem quadrature rule order,
285 : * then nothing is done (i.e. this function is idempotent).
286 : */
287 : void bumpVolumeQRuleOrder(libMesh::Order order, SubdomainID block);
288 :
289 : void bumpAllQRuleOrder(libMesh::Order order, SubdomainID block);
290 :
291 : /**
292 : * @return The maximum number of quadrature points in use on any element in this problem.
293 : */
294 : unsigned int getMaxQps() const;
295 :
296 : /**
297 : * @return The maximum order for all scalar variables in this problem's systems.
298 : */
299 : libMesh::Order getMaxScalarOrder() const;
300 :
301 : /**
302 : * @return Flag indicating nonlocal coupling exists or not.
303 : */
304 : void checkNonlocalCoupling();
305 : void checkUserObjectJacobianRequirement(THREAD_ID tid);
306 : void setVariableAllDoFMap(const std::vector<const MooseVariableFEBase *> & moose_vars);
307 :
308 : const std::vector<const MooseVariableFEBase *> &
309 1692 : getUserObjectJacobianVariables(const THREAD_ID tid) const
310 : {
311 1692 : return _uo_jacobian_moose_vars[tid];
312 : }
313 :
314 : virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override;
315 : virtual const Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) const override;
316 :
317 : /**
318 : * Returns a list of all the variables in the problem (both from the NL and Aux systems.
319 : */
320 : virtual std::vector<VariableName> getVariableNames();
321 :
322 : void initialSetup() override;
323 : void checkDuplicatePostprocessorVariableNames();
324 : void timestepSetup() override;
325 : void customSetup(const ExecFlagType & exec_type) override;
326 : void residualSetup() override;
327 : void jacobianSetup() override;
328 :
329 : virtual void prepare(const Elem * elem, const THREAD_ID tid) override;
330 : virtual void prepareFace(const Elem * elem, const THREAD_ID tid) override;
331 : virtual void prepare(const Elem * elem,
332 : unsigned int ivar,
333 : unsigned int jvar,
334 : const std::vector<dof_id_type> & dof_indices,
335 : const THREAD_ID tid) override;
336 :
337 : virtual void setCurrentSubdomainID(const Elem * elem, const THREAD_ID tid) override;
338 : virtual void
339 : setNeighborSubdomainID(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
340 : virtual void setNeighborSubdomainID(const Elem * elem, const THREAD_ID tid);
341 : virtual void prepareAssembly(const THREAD_ID tid) override;
342 :
343 : virtual void addGhostedElem(dof_id_type elem_id) override;
344 : virtual void addGhostedBoundary(BoundaryID boundary_id) override;
345 : virtual void ghostGhostedBoundaries() override;
346 :
347 : virtual void sizeZeroes(unsigned int size, const THREAD_ID tid);
348 : virtual bool reinitDirac(const Elem * elem, const THREAD_ID tid) override;
349 :
350 : virtual void reinitElem(const Elem * elem, const THREAD_ID tid) override;
351 : virtual void reinitElemPhys(const Elem * elem,
352 : const std::vector<Point> & phys_points_in_elem,
353 : const THREAD_ID tid) override;
354 : void reinitElemFace(const Elem * elem, unsigned int side, BoundaryID, const THREAD_ID tid);
355 : virtual void reinitElemFace(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
356 : virtual void reinitLowerDElem(const Elem * lower_d_elem,
357 : const THREAD_ID tid,
358 : const std::vector<Point> * const pts = nullptr,
359 : const std::vector<Real> * const weights = nullptr) override;
360 : virtual void reinitNode(const Node * node, const THREAD_ID tid) override;
361 : virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, const THREAD_ID tid) override;
362 : virtual void reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid) override;
363 : virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes,
364 : const THREAD_ID tid) override;
365 : virtual void reinitNeighbor(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
366 : virtual void reinitNeighborPhys(const Elem * neighbor,
367 : unsigned int neighbor_side,
368 : const std::vector<Point> & physical_points,
369 : const THREAD_ID tid) override;
370 : virtual void reinitNeighborPhys(const Elem * neighbor,
371 : const std::vector<Point> & physical_points,
372 : const THREAD_ID tid) override;
373 : virtual void
374 : reinitElemNeighborAndLowerD(const Elem * elem, unsigned int side, const THREAD_ID tid) override;
375 : virtual void reinitScalars(const THREAD_ID tid,
376 : bool reinit_for_derivative_reordering = false) override;
377 : virtual void reinitOffDiagScalars(const THREAD_ID tid) override;
378 :
379 : /// Fills "elems" with the elements that should be looped over for Dirac Kernels
380 : virtual void getDiracElements(std::set<const Elem *> & elems) override;
381 : virtual void clearDiracInfo() override;
382 :
383 : virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid);
384 : virtual void neighborSubdomainSetup(SubdomainID subdomain, const THREAD_ID tid);
385 :
386 : virtual void newAssemblyArray(std::vector<std::shared_ptr<SolverSystem>> & solver_systems);
387 : virtual void initNullSpaceVectors(const InputParameters & parameters,
388 : std::vector<std::shared_ptr<NonlinearSystemBase>> & nl);
389 :
390 : virtual void init() override;
391 : virtual void solve(const unsigned int nl_sys_num);
392 :
393 : /**
394 : * Build and solve a linear system
395 : * @param linear_sys_num The number of the linear system (1,..,num. of lin. systems)
396 : * @param po The petsc options for the solve, if not supplied, the defaults are used
397 : */
398 : virtual void solveLinearSystem(const unsigned int linear_sys_num,
399 : const Moose::PetscSupport::PetscOptions * po = nullptr);
400 :
401 : ///@{
402 : /**
403 : * In general, {evaluable elements} >= {local elements} U {algebraic ghosting elements}. That is,
404 : * the number of evaluable elements does NOT necessarily equal to the number of local and
405 : * algebraic ghosting elements. For example, if using a Lagrange basis for all variables,
406 : * if a non-local, non-algebraically-ghosted element is surrounded by neighbors which are
407 : * local or algebraically ghosted, then all the nodal (Lagrange) degrees of freedom associated
408 : * with the non-local, non-algebraically-ghosted element will be evaluable, and hence that
409 : * element will be considered evaluable.
410 : *
411 : * getNonlinearEvaluableElementRange() returns the evaluable element range based on the nonlinear
412 : * system dofmap;
413 : * getAuxliaryEvaluableElementRange() returns the evaluable element range based on the auxiliary
414 : * system dofmap;
415 : * getEvaluableElementRange() returns the element range that is evaluable based on both the
416 : * nonlinear dofmap and the auxliary dofmap.
417 : */
418 : const libMesh::ConstElemRange & getEvaluableElementRange();
419 : const libMesh::ConstElemRange & getNonlinearEvaluableElementRange();
420 : ///@}
421 :
422 : ///@{
423 : /**
424 : * These are the element and nodes that contribute to the jacobian and
425 : * residual for this local processor.
426 : *
427 : * getCurrentAlgebraicElementRange() returns the element range that contributes to the
428 : * system
429 : * getCurrentAlgebraicNodeRange() returns the node range that contributes to the
430 : * system
431 : * getCurrentAlgebraicBndNodeRange returns the boundary node ranges that contributes
432 : * to the system
433 : */
434 : const libMesh::ConstElemRange & getCurrentAlgebraicElementRange();
435 : const libMesh::ConstNodeRange & getCurrentAlgebraicNodeRange();
436 : const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange();
437 : ///@}
438 :
439 : ///@{
440 : /**
441 : * These functions allow setting custom ranges for the algebraic elements, nodes,
442 : * and boundary nodes that contribute to the jacobian and residual for this local
443 : * processor.
444 : *
445 : * setCurrentAlgebraicElementRange() sets the element range that contributes to the
446 : * system. A nullptr will reset the range to use the mesh's range.
447 : *
448 : * setCurrentAlgebraicNodeRange() sets the node range that contributes to the
449 : * system. A nullptr will reset the range to use the mesh's range.
450 : *
451 : * setCurrentAlgebraicBndNodeRange() sets the boundary node range that contributes
452 : * to the system. A nullptr will reset the range to use the mesh's range.
453 : *
454 : * @param range A pointer to the const range object representing the algebraic
455 : * elements, nodes, or boundary nodes.
456 : */
457 : void setCurrentAlgebraicElementRange(libMesh::ConstElemRange * range);
458 : void setCurrentAlgebraicNodeRange(libMesh::ConstNodeRange * range);
459 : void setCurrentAlgebraicBndNodeRange(ConstBndNodeRange * range);
460 : ///@}
461 :
462 : /**
463 : * Set an exception, which is stored at this point by toggling a member variable in
464 : * this class, and which must be followed up with by a call to
465 : * checkExceptionAndStopSolve().
466 : *
467 : * @param message The error message describing the exception, which will get printed
468 : * when checkExceptionAndStopSolve() is called
469 : */
470 : virtual void setException(const std::string & message);
471 :
472 : /**
473 : * Whether or not an exception has occurred.
474 : */
475 532622572 : virtual bool hasException() { return _has_exception; }
476 :
477 : /**
478 : * Check to see if an exception has occurred on any processor and, if possible,
479 : * force the solve to fail, which will result in the time step being cut.
480 : *
481 : * Notes:
482 : * * The exception have be registered by calling setException() prior to calling this.
483 : * * This is collective on MPI, and must be called simultaneously by all processors!
484 : * * If called when the solve can be interruped, it will do so and also throw a
485 : * MooseException, which must be handled.
486 : * * If called at a stage in the execution when the solve cannot be interupted (i.e.,
487 : * there is no solve active), it will generate an error and terminate the application.
488 : * * DO NOT CALL THIS IN A THREADED REGION! This is meant to be called just after a
489 : * threaded section.
490 : *
491 : * @param print_message whether to print a message with exception information
492 : */
493 : virtual void checkExceptionAndStopSolve(bool print_message = true);
494 :
495 : virtual bool solverSystemConverged(const unsigned int solver_sys_num) override;
496 : virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const override;
497 : virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const override;
498 : virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const override;
499 : virtual bool computingPreSMOResidual(const unsigned int nl_sys_num) const override;
500 :
501 : /**
502 : * Return solver type as a human readable string
503 : */
504 : virtual std::string solverTypeString(unsigned int solver_sys_num = 0);
505 :
506 : /**
507 : * Returns true if we are in or beyond the initialSetup stage
508 : */
509 73662 : virtual bool startedInitialSetup() { return _started_initial_setup; }
510 :
511 : virtual void onTimestepBegin() override;
512 : virtual void onTimestepEnd() override;
513 :
514 9834189 : virtual Real & time() const { return _time; }
515 993759 : virtual Real & timeOld() const { return _time_old; }
516 1484467 : virtual int & timeStep() const { return _t_step; }
517 13489433 : virtual Real & dt() const { return _dt; }
518 1002278 : virtual Real & dtOld() const { return _dt_old; }
519 : /**
520 : * Returns the time associated with the requested \p state
521 : */
522 : Real getTimeFromStateArg(const Moose::StateArg & state) const;
523 :
524 30785 : virtual void transient(bool trans) { _transient = trans; }
525 2537432607 : virtual bool isTransient() const override { return _transient; }
526 :
527 : virtual void addTimeIntegrator(const std::string & type,
528 : const std::string & name,
529 : InputParameters & parameters);
530 : virtual void
531 : addPredictor(const std::string & type, const std::string & name, InputParameters & parameters);
532 :
533 : virtual void copySolutionsBackwards();
534 :
535 : /**
536 : * Advance all of the state holding vectors / datastructures so that we can move to the next
537 : * timestep.
538 : */
539 : virtual void advanceState();
540 :
541 : virtual void restoreSolutions();
542 :
543 : /**
544 : * Allocate vectors and save old solutions into them.
545 : */
546 : virtual void saveOldSolutions();
547 :
548 : /**
549 : * Restore old solutions from the backup vectors and deallocate them.
550 : */
551 : virtual void restoreOldSolutions();
552 :
553 : /**
554 : * Declare that we need up to old (1) or older (2) solution states for a given type of iteration
555 : * @param oldest_needed oldest solution state needed
556 : * @param iteration_type the type of iteration for which old/older states are needed
557 : */
558 : void needSolutionState(unsigned int oldest_needed, Moose::SolutionIterationType iteration_type);
559 :
560 : /**
561 : * Output the current step.
562 : * Will ensure that everything is in the proper state to be outputted.
563 : * Then tell the OutputWarehouse to do its thing
564 : * @param type The type execution flag (see Moose.h)
565 : */
566 : virtual void outputStep(ExecFlagType type);
567 :
568 : /**
569 : * Method called at the end of the simulation.
570 : */
571 : virtual void postExecute();
572 :
573 : ///@{
574 : /**
575 : * Ability to enable/disable all output calls
576 : *
577 : * This is needed by Multiapps and applications to disable output for cases when
578 : * executioners call other executions and when Multiapps are sub cycling.
579 : */
580 : void allowOutput(bool state);
581 : template <typename T>
582 : void allowOutput(bool state);
583 : ///@}
584 :
585 : /**
586 : * Indicates that the next call to outputStep should be forced
587 : *
588 : * This is needed by the MultiApp system, if forceOutput is called the next call to outputStep,
589 : * regardless of the type supplied to the call, will be executed with EXEC_FORCED.
590 : *
591 : * Forced output will NOT override the allowOutput flag.
592 : */
593 : void forceOutput();
594 :
595 : /**
596 : * Reinitialize PETSc output for proper linear/nonlinear iteration display. This also may be used
597 : * for some PETSc-related solver settings
598 : */
599 : virtual void initPetscOutputAndSomeSolverSettings();
600 :
601 : /**
602 : * Retrieve a writable reference the PETSc options (used by PetscSupport)
603 : */
604 206659 : Moose::PetscSupport::PetscOptions & getPetscOptions() { return _petsc_options; }
605 :
606 : /**
607 : * Output information about the object just added to the problem
608 : */
609 : void logAdd(const std::string & system,
610 : const std::string & name,
611 : const std::string & type,
612 : const InputParameters & params) const;
613 :
614 : // Function /////
615 : virtual void
616 : addFunction(const std::string & type, const std::string & name, InputParameters & parameters);
617 : virtual bool hasFunction(const std::string & name, const THREAD_ID tid = 0);
618 : virtual Function & getFunction(const std::string & name, const THREAD_ID tid = 0);
619 :
620 : /// Add a MeshDivision
621 : virtual void
622 : addMeshDivision(const std::string & type, const std::string & name, InputParameters & params);
623 : /// Get a MeshDivision
624 : MeshDivision & getMeshDivision(const std::string & name, const THREAD_ID tid = 0) const;
625 :
626 : /// Adds a Convergence object
627 : virtual void
628 : addConvergence(const std::string & type, const std::string & name, InputParameters & parameters);
629 : /// Gets a Convergence object
630 : virtual Convergence & getConvergence(const std::string & name, const THREAD_ID tid = 0) const;
631 : /// Gets the Convergence objects
632 : virtual const std::vector<std::shared_ptr<Convergence>> &
633 : getConvergenceObjects(const THREAD_ID tid = 0) const;
634 : /// Returns true if the problem has a Convergence object of the given name
635 : virtual bool hasConvergence(const std::string & name, const THREAD_ID tid = 0) const;
636 : /// Returns true if the problem needs to add the default nonlinear convergence
637 62073 : bool needToAddDefaultNonlinearConvergence() const
638 : {
639 62073 : return _need_to_add_default_nonlinear_convergence;
640 : }
641 : /// Returns true if the problem needs to add the default fixed point convergence
642 62061 : bool needToAddDefaultMultiAppFixedPointConvergence() const
643 : {
644 62061 : return _need_to_add_default_multiapp_fixed_point_convergence;
645 : }
646 : /// Returns true if the problem needs to add the default steady-state detection convergence
647 62049 : bool needToAddDefaultSteadyStateConvergence() const
648 : {
649 62049 : return _need_to_add_default_steady_state_convergence;
650 : }
651 : /// Sets _need_to_add_default_nonlinear_convergence to true
652 61582 : void setNeedToAddDefaultNonlinearConvergence()
653 : {
654 61582 : _need_to_add_default_nonlinear_convergence = true;
655 61582 : }
656 : /// Sets _need_to_add_default_multiapp_fixed_point_convergence to true
657 62076 : void setNeedToAddDefaultMultiAppFixedPointConvergence()
658 : {
659 62076 : _need_to_add_default_multiapp_fixed_point_convergence = true;
660 62076 : }
661 : /// Sets _need_to_add_default_steady_state_convergence to true
662 30578 : void setNeedToAddDefaultSteadyStateConvergence()
663 : {
664 30578 : _need_to_add_default_steady_state_convergence = true;
665 30578 : }
666 : /// Returns true if the problem has set the fixed point convergence name
667 62049 : bool hasSetMultiAppFixedPointConvergenceName() const
668 : {
669 62049 : return _multiapp_fixed_point_convergence_name.has_value();
670 : }
671 : /// Returns true if the problem has set the steady-state detection convergence name
672 : bool hasSetSteadyStateConvergenceName() const
673 : {
674 : return _steady_state_convergence_name.has_value();
675 : }
676 : /**
677 : * Adds the default nonlinear Convergence associated with the problem
678 : *
679 : * This is called if the user does not supply 'nonlinear_convergence'.
680 : *
681 : * @param[in] params Parameters to apply to Convergence parameters
682 : */
683 : virtual void addDefaultNonlinearConvergence(const InputParameters & params);
684 : /**
685 : * Returns true if an error will result if the user supplies 'nonlinear_convergence'
686 : *
687 : * Some problems are strongly tied to their convergence, and it does not make
688 : * sense to use any convergence other than their default and additionally
689 : * would be error-prone.
690 : */
691 331 : virtual bool onlyAllowDefaultNonlinearConvergence() const { return false; }
692 : /**
693 : * Adds the default fixed point Convergence associated with the problem
694 : *
695 : * This is called if the user does not supply 'multiapp_fixed_point_convergence'.
696 : *
697 : * @param[in] params Parameters to apply to Convergence parameters
698 : */
699 : void addDefaultMultiAppFixedPointConvergence(const InputParameters & params);
700 : /**
701 : * Adds the default steady-state detection Convergence
702 : *
703 : * This is called if the user does not supply 'steady_state_convergence'.
704 : *
705 : * @param[in] params Parameters to apply to Convergence parameters
706 : */
707 : void addDefaultSteadyStateConvergence(const InputParameters & params);
708 :
709 : /**
710 : * add a MOOSE line search
711 : */
712 0 : virtual void addLineSearch(const InputParameters & /*parameters*/)
713 : {
714 0 : mooseError("Line search not implemented for this problem type yet.");
715 : }
716 :
717 : /**
718 : * execute MOOSE line search
719 : */
720 : virtual void lineSearch();
721 :
722 : /**
723 : * getter for the MOOSE line search
724 : */
725 0 : LineSearch * getLineSearch() override { return _line_search.get(); }
726 :
727 : /**
728 : * The following functions will enable MOOSE to have the capability to import distributions
729 : */
730 : virtual void
731 : addDistribution(const std::string & type, const std::string & name, InputParameters & parameters);
732 : virtual Distribution & getDistribution(const std::string & name);
733 :
734 : /**
735 : * The following functions will enable MOOSE to have the capability to import Samplers
736 : */
737 : virtual void
738 : addSampler(const std::string & type, const std::string & name, InputParameters & parameters);
739 : virtual Sampler & getSampler(const std::string & name, const THREAD_ID tid = 0);
740 :
741 : // NL /////
742 : NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num);
743 : const NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num) const;
744 : void setCurrentNonlinearSystem(const unsigned int nl_sys_num);
745 : NonlinearSystemBase & currentNonlinearSystem();
746 : const NonlinearSystemBase & currentNonlinearSystem() const;
747 :
748 : virtual const SystemBase & systemBaseNonlinear(const unsigned int sys_num) const override;
749 : virtual SystemBase & systemBaseNonlinear(const unsigned int sys_num) override;
750 :
751 : virtual const SystemBase & systemBaseSolver(const unsigned int sys_num) const override;
752 : virtual SystemBase & systemBaseSolver(const unsigned int sys_num) override;
753 :
754 : virtual const SystemBase & systemBaseAuxiliary() const override;
755 : virtual SystemBase & systemBaseAuxiliary() override;
756 :
757 : virtual NonlinearSystem & getNonlinearSystem(const unsigned int sys_num);
758 :
759 : /**
760 : * Get constant reference to a system in this problem
761 : * @param sys_num The number of the system
762 : */
763 : virtual const SystemBase & getSystemBase(const unsigned int sys_num) const;
764 :
765 : /**
766 : * Get non-constant reference to a system in this problem
767 : * @param sys_num The number of the system
768 : */
769 : virtual SystemBase & getSystemBase(const unsigned int sys_num);
770 :
771 : /**
772 : * Get non-constant reference to a linear system
773 : * @param sys_num The number of the linear system
774 : */
775 : LinearSystem & getLinearSystem(unsigned int sys_num);
776 :
777 : /**
778 : * Get a constant reference to a linear system
779 : * @param sys_num The number of the linear system
780 : */
781 : const LinearSystem & getLinearSystem(unsigned int sys_num) const;
782 :
783 : /**
784 : * Get non-constant reference to a solver system
785 : * @param sys_num The number of the solver system
786 : */
787 : SolverSystem & getSolverSystem(unsigned int sys_num);
788 :
789 : /**
790 : * Get a constant reference to a solver system
791 : * @param sys_num The number of the solver system
792 : */
793 : const SolverSystem & getSolverSystem(unsigned int sys_num) const;
794 :
795 : /**
796 : * Set the current linear system pointer
797 : * @param sys_num The number of linear system
798 : */
799 : void setCurrentLinearSystem(unsigned int sys_num);
800 :
801 : /// Get a non-constant reference to the current linear system
802 : LinearSystem & currentLinearSystem();
803 : /// Get a constant reference to the current linear system
804 : const LinearSystem & currentLinearSystem() const;
805 :
806 : /**
807 : * Get a constant base class reference to a linear system
808 : * @param sys_num The number of the linear system
809 : */
810 : virtual const SystemBase & systemBaseLinear(unsigned int sys_num) const override;
811 :
812 : /**
813 : * Get a non-constant base class reference to a linear system
814 : * @param sys_num The number of the linear system
815 : */
816 : virtual SystemBase & systemBaseLinear(unsigned int sys_num) override;
817 :
818 : /**
819 : * Canonical method for adding a non-linear variable
820 : * @param var_type the type of the variable, e.g. MooseVariableScalar
821 : * @param var_name the variable name, e.g. 'u'
822 : * @param params the InputParameters from which to construct the variable
823 : */
824 : virtual void
825 : addVariable(const std::string & var_type, const std::string & var_name, InputParameters & params);
826 :
827 : virtual void addKernel(const std::string & kernel_name,
828 : const std::string & name,
829 : InputParameters & parameters);
830 : virtual void addHDGKernel(const std::string & kernel_name,
831 : const std::string & name,
832 : InputParameters & parameters);
833 : virtual void addNodalKernel(const std::string & kernel_name,
834 : const std::string & name,
835 : InputParameters & parameters);
836 : virtual void addScalarKernel(const std::string & kernel_name,
837 : const std::string & name,
838 : InputParameters & parameters);
839 : virtual void addBoundaryCondition(const std::string & bc_name,
840 : const std::string & name,
841 : InputParameters & parameters);
842 : virtual void
843 : addConstraint(const std::string & c_name, const std::string & name, InputParameters & parameters);
844 :
845 1732774 : virtual void setInputParametersFEProblem(InputParameters & parameters)
846 : {
847 1732774 : parameters.set<FEProblemBase *>("_fe_problem_base") = this;
848 1732774 : }
849 :
850 : // Aux /////
851 :
852 : /**
853 : * Canonical method for adding an auxiliary variable
854 : * @param var_type the type of the variable, e.g. MooseVariableScalar
855 : * @param var_name the variable name, e.g. 'u'
856 : * @param params the InputParameters from which to construct the variable
857 : */
858 : virtual void addAuxVariable(const std::string & var_type,
859 : const std::string & var_name,
860 : InputParameters & params);
861 :
862 : virtual void addAuxVariable(const std::string & var_name,
863 : const libMesh::FEType & type,
864 : const std::set<SubdomainID> * const active_subdomains = NULL);
865 : virtual void addAuxArrayVariable(const std::string & var_name,
866 : const libMesh::FEType & type,
867 : unsigned int components,
868 : const std::set<SubdomainID> * const active_subdomains = NULL);
869 : virtual void addAuxScalarVariable(const std::string & var_name,
870 : libMesh::Order order,
871 : Real scale_factor = 1.,
872 : const std::set<SubdomainID> * const active_subdomains = NULL);
873 : virtual void addAuxKernel(const std::string & kernel_name,
874 : const std::string & name,
875 : InputParameters & parameters);
876 : virtual void addAuxScalarKernel(const std::string & kernel_name,
877 : const std::string & name,
878 : InputParameters & parameters);
879 :
880 5240985 : AuxiliarySystem & getAuxiliarySystem() { return *_aux; }
881 :
882 : // Dirac /////
883 : virtual void addDiracKernel(const std::string & kernel_name,
884 : const std::string & name,
885 : InputParameters & parameters);
886 :
887 : // DG /////
888 : virtual void addDGKernel(const std::string & kernel_name,
889 : const std::string & name,
890 : InputParameters & parameters);
891 : // FV /////
892 : virtual void addFVKernel(const std::string & kernel_name,
893 : const std::string & name,
894 : InputParameters & parameters);
895 :
896 : virtual void addLinearFVKernel(const std::string & kernel_name,
897 : const std::string & name,
898 : InputParameters & parameters);
899 : virtual void
900 : addFVBC(const std::string & fv_bc_name, const std::string & name, InputParameters & parameters);
901 : virtual void addLinearFVBC(const std::string & fv_bc_name,
902 : const std::string & name,
903 : InputParameters & parameters);
904 :
905 : virtual void addFVInterfaceKernel(const std::string & fv_ik_name,
906 : const std::string & name,
907 : InputParameters & parameters);
908 :
909 : // Interface /////
910 : virtual void addInterfaceKernel(const std::string & kernel_name,
911 : const std::string & name,
912 : InputParameters & parameters);
913 :
914 : // IC /////
915 : virtual void addInitialCondition(const std::string & ic_name,
916 : const std::string & name,
917 : InputParameters & parameters);
918 : /**
919 : * Add an initial condition for a finite volume variables
920 : * @param ic_name The name of the boundary condition object
921 : * @param name The user-defined name from the input file
922 : * @param parameters The input parameters for construction
923 : */
924 : virtual void addFVInitialCondition(const std::string & ic_name,
925 : const std::string & name,
926 : InputParameters & parameters);
927 :
928 : void projectSolution();
929 :
930 : /**
931 : * Retrieves the current initial condition state.
932 : * @return current initial condition state
933 : */
934 : unsigned short getCurrentICState();
935 :
936 : /**
937 : * Project initial conditions for custom \p elem_range and \p bnd_node_range
938 : * This is needed when elements/boundary nodes are added to a specific subdomain
939 : * at an intermediate step
940 : */
941 : void projectInitialConditionOnCustomRange(libMesh::ConstElemRange & elem_range,
942 : ConstBndNodeRange & bnd_node_range);
943 :
944 : // Materials /////
945 : virtual void addMaterial(const std::string & material_name,
946 : const std::string & name,
947 : InputParameters & parameters);
948 : virtual void addMaterialHelper(std::vector<MaterialWarehouse *> warehouse,
949 : const std::string & material_name,
950 : const std::string & name,
951 : InputParameters & parameters);
952 : virtual void addInterfaceMaterial(const std::string & material_name,
953 : const std::string & name,
954 : InputParameters & parameters);
955 : virtual void addFunctorMaterial(const std::string & functor_material_name,
956 : const std::string & name,
957 : InputParameters & parameters);
958 :
959 : /**
960 : * Add the MooseVariables and the material properties that the current materials depend on to the
961 : * dependency list.
962 : * @param consumer_needed_mat_props The material properties needed by consumer objects (other than
963 : * the materials themselves)
964 : * @param blk_id The subdomain ID for which we are preparing our list of needed vars and props
965 : * @param tid The thread ID we are preparing the requirements for
966 : *
967 : * This MUST be done after the moose variable dependency list has been set for all the other
968 : * objects using the \p setActiveElementalMooseVariables API!
969 : */
970 : void prepareMaterials(const std::unordered_set<unsigned int> & consumer_needed_mat_props,
971 : const SubdomainID blk_id,
972 : const THREAD_ID tid);
973 :
974 : void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful = true);
975 :
976 : /**
977 : * reinit materials on element faces
978 : * @param blk_id The subdomain on which the element owning the face lives
979 : * @param tid The thread id
980 : * @param swap_stateful Whether to swap stateful material properties between \p MaterialData and
981 : * \p MaterialPropertyStorage
982 : * @param execute_stateful Whether to execute material objects that have stateful properties. This
983 : * should be \p false when for example executing material objects for mortar contexts in which
984 : * stateful properties don't make sense
985 : */
986 : void reinitMaterialsFace(SubdomainID blk_id,
987 : const THREAD_ID tid,
988 : bool swap_stateful = true,
989 : const std::deque<MaterialBase *> * reinit_mats = nullptr);
990 :
991 : /**
992 : * reinit materials on the neighboring element face
993 : * @param blk_id The subdomain on which the neighbor element lives
994 : * @param tid The thread id
995 : * @param swap_stateful Whether to swap stateful material properties between \p MaterialData and
996 : * \p MaterialPropertyStorage
997 : * @param execute_stateful Whether to execute material objects that have stateful properties. This
998 : * should be \p false when for example executing material objects for mortar contexts in which
999 : * stateful properties don't make sense
1000 : */
1001 : void reinitMaterialsNeighbor(SubdomainID blk_id,
1002 : const THREAD_ID tid,
1003 : bool swap_stateful = true,
1004 : const std::deque<MaterialBase *> * reinit_mats = nullptr);
1005 :
1006 : /**
1007 : * reinit materials on a boundary
1008 : * @param boundary_id The boundary on which to reinit corresponding materials
1009 : * @param tid The thread id
1010 : * @param swap_stateful Whether to swap stateful material properties between \p MaterialData and
1011 : * \p MaterialPropertyStorage
1012 : * @param execute_stateful Whether to execute material objects that have stateful properties.
1013 : * This should be \p false when for example executing material objects for mortar contexts in
1014 : * which stateful properties don't make sense
1015 : */
1016 : void reinitMaterialsBoundary(BoundaryID boundary_id,
1017 : const THREAD_ID tid,
1018 : bool swap_stateful = true,
1019 : const std::deque<MaterialBase *> * reinit_mats = nullptr);
1020 :
1021 : void
1022 : reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful = true);
1023 :
1024 : /*
1025 : * Swap back underlying data storing stateful material properties
1026 : */
1027 : virtual void swapBackMaterials(const THREAD_ID tid);
1028 : virtual void swapBackMaterialsFace(const THREAD_ID tid);
1029 : virtual void swapBackMaterialsNeighbor(const THREAD_ID tid);
1030 :
1031 : /**
1032 : * Record and set the material properties required by the current computing thread.
1033 : * @param mat_prop_ids The set of material properties required by the current computing thread.
1034 : *
1035 : * @param tid The thread id
1036 : */
1037 : void setActiveMaterialProperties(const std::unordered_set<unsigned int> & mat_prop_ids,
1038 : const THREAD_ID tid);
1039 :
1040 : /**
1041 : * Method to check whether or not a list of active material roperties has been set. This method
1042 : * is called by reinitMaterials to determine whether Material computeProperties methods need to be
1043 : * called. If the return is False, this check prevents unnecessary material property computation
1044 : * @param tid The thread id
1045 : *
1046 : * @return True if there has been a list of active material properties set, False otherwise
1047 : */
1048 : bool hasActiveMaterialProperties(const THREAD_ID tid) const;
1049 :
1050 : /**
1051 : * Clear the active material properties. Should be called at the end of every computing thread
1052 : *
1053 : * @param tid The thread id
1054 : */
1055 : void clearActiveMaterialProperties(const THREAD_ID tid);
1056 :
1057 : /**
1058 : * Method for creating and adding an object to the warehouse.
1059 : *
1060 : * @tparam T The base object type (registered in the Factory)
1061 : * @param type String type of the object (registered in the Factory)
1062 : * @param name Name for the object to be created
1063 : * @param parameters InputParameters for the object
1064 : * @param threaded Whether or not to create n_threads copies of the object
1065 : * @param var_param_name The name of the parameter on the object which holds the primary variable.
1066 : * @return A vector of shared_ptrs to the added objects
1067 : */
1068 : template <typename T>
1069 : std::vector<std::shared_ptr<T>> addObject(const std::string & type,
1070 : const std::string & name,
1071 : InputParameters & parameters,
1072 : const bool threaded = true,
1073 : const std::string & var_param_name = "variable");
1074 :
1075 : // Postprocessors /////
1076 : virtual void addPostprocessor(const std::string & pp_name,
1077 : const std::string & name,
1078 : InputParameters & parameters);
1079 :
1080 : // VectorPostprocessors /////
1081 : virtual void addVectorPostprocessor(const std::string & pp_name,
1082 : const std::string & name,
1083 : InputParameters & parameters);
1084 :
1085 : /**
1086 : * Add a Reporter object to the simulation.
1087 : * @param type C++ object type to construct
1088 : * @param name A uniquely identifying object name
1089 : * @param parameters Complete parameters for the object to be created.
1090 : *
1091 : * For an example use, refer to AddReporterAction.C/h
1092 : */
1093 : virtual void
1094 : addReporter(const std::string & type, const std::string & name, InputParameters & parameters);
1095 :
1096 : /**
1097 : * Provides const access the ReporterData object.
1098 : *
1099 : * NOTE: There is a private non-const version of this function that uses a key object only
1100 : * constructable by the correct interfaces. This was done by design to encourage the use of
1101 : * the Reporter and ReporterInterface classes.
1102 : */
1103 777136 : const ReporterData & getReporterData() const { return _reporter_data; }
1104 :
1105 : /**
1106 : * Provides non-const access the ReporterData object that is used to store reporter values.
1107 : *
1108 : * see ReporterData.h
1109 : */
1110 153631 : ReporterData & getReporterData(ReporterData::WriteKey /*key*/) { return _reporter_data; }
1111 :
1112 : // UserObjects /////
1113 : virtual std::vector<std::shared_ptr<UserObject>> addUserObject(
1114 : const std::string & user_object_name, const std::string & name, InputParameters & parameters);
1115 :
1116 : // TODO: delete this function after apps have been updated to not call it
1117 : const ExecuteMooseObjectWarehouse<UserObject> & getUserObjects() const
1118 : {
1119 : mooseDeprecated(
1120 : "This function is deprecated, use theWarehouse().query() to construct a query instead");
1121 : return _all_user_objects;
1122 : }
1123 :
1124 : /**
1125 : * Get the user object by its name
1126 : * @param name The name of the user object being retrieved
1127 : * @return Const reference to the user object
1128 : */
1129 : template <class T>
1130 12210 : T & getUserObject(const std::string & name, unsigned int tid = 0) const
1131 : {
1132 12210 : std::vector<T *> objs;
1133 12210 : theWarehouse()
1134 : .query()
1135 24420 : .condition<AttribSystem>("UserObject")
1136 12210 : .condition<AttribThread>(tid)
1137 12210 : .condition<AttribName>(name)
1138 12210 : .queryInto(objs);
1139 12210 : if (objs.empty())
1140 0 : mooseError("Unable to find user object with name '" + name + "'");
1141 24420 : return *(objs[0]);
1142 12210 : }
1143 : /**
1144 : * Get the user object by its name
1145 : * @param name The name of the user object being retrieved
1146 : * @param tid The thread of the user object (defaults to 0)
1147 : * @return Const reference to the user object
1148 : */
1149 : const UserObject & getUserObjectBase(const std::string & name, const THREAD_ID tid = 0) const;
1150 :
1151 : /**
1152 : * Get the Positions object by its name
1153 : * @param name The name of the Positions object being retrieved
1154 : * @return Const reference to the Positions object
1155 : */
1156 : const Positions & getPositionsObject(const std::string & name) const;
1157 :
1158 : /**
1159 : * Check if there if a user object of given name
1160 : * @param name The name of the user object being checked for
1161 : * @return true if the user object exists, false otherwise
1162 : */
1163 : bool hasUserObject(const std::string & name) const;
1164 :
1165 : /**
1166 : * Whether or not a Postprocessor value exists by a given name.
1167 : * @param name The name of the Postprocessor
1168 : * @return True if a Postprocessor value exists
1169 : *
1170 : * Note: You should prioritize the use of PostprocessorInterface::hasPostprocessor
1171 : * and PostprocessorInterface::hasPostprocessorByName over this method when possible.
1172 : */
1173 : bool hasPostprocessorValueByName(const PostprocessorName & name) const;
1174 :
1175 : /**
1176 : * Get a read-only reference to the value associated with a Postprocessor that exists.
1177 : * @param name The name of the post-processor
1178 : * @param t_index Flag for getting current (0), old (1), or older (2) values
1179 : * @return The reference to the value at the given time index
1180 : *
1181 : * Note: This method is only for retrieving values that already exist, the Postprocessor and
1182 : * PostprocessorInterface objects should be used rather than this method for creating
1183 : * and getting values within objects.
1184 : */
1185 : const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName & name,
1186 : std::size_t t_index = 0) const;
1187 :
1188 : /**
1189 : * Set the value of a PostprocessorValue.
1190 : * @param name The name of the post-processor
1191 : * @param t_index Flag for getting current (0), old (1), or older (2) values
1192 : * @return The reference to the value at the given time index
1193 : *
1194 : * Note: This method is only for setting values that already exist, the Postprocessor and
1195 : * PostprocessorInterface objects should be used rather than this method for creating
1196 : * and getting values within objects.
1197 : *
1198 : * WARNING!
1199 : * This method should be used with caution. It exists to allow Transfers and other
1200 : * similar objects to modify Postprocessor values. It is not intended for general use.
1201 : */
1202 : void setPostprocessorValueByName(const PostprocessorName & name,
1203 : const PostprocessorValue & value,
1204 : std::size_t t_index = 0);
1205 :
1206 : /**
1207 : * Deprecated. Use hasPostprocessorValueByName
1208 : */
1209 : bool hasPostprocessor(const std::string & name) const;
1210 :
1211 : /**
1212 : * Get a read-only reference to the vector value associated with the VectorPostprocessor.
1213 : * @param object_name The name of the VPP object.
1214 : * @param vector_name The namve of the decalred vector within the object.
1215 : * @return Referent to the vector of data.
1216 : *
1217 : * Note: This method is only for retrieving values that already exist, the VectorPostprocessor and
1218 : * VectorPostprocessorInterface objects should be used rather than this method for creating
1219 : * and getting values within objects.
1220 : */
1221 : const VectorPostprocessorValue &
1222 : getVectorPostprocessorValueByName(const std::string & object_name,
1223 : const std::string & vector_name,
1224 : std::size_t t_index = 0) const;
1225 :
1226 : /**
1227 : * Set the value of a VectorPostprocessor vector
1228 : * @param object_name The name of the VPP object
1229 : * @param vector_name The name of the declared vector
1230 : * @param value The data to apply to the vector
1231 : * @param t_index Flag for getting current (0), old (1), or older (2) values
1232 : */
1233 : void setVectorPostprocessorValueByName(const std::string & object_name,
1234 : const std::string & vector_name,
1235 : const VectorPostprocessorValue & value,
1236 : std::size_t t_index = 0);
1237 :
1238 : /**
1239 : * Return the VPP object given the name.
1240 : * @param object_name The name of the VPP object
1241 : * @return Desired VPP object
1242 : *
1243 : * This is used by various output objects as well as the scatter value handling.
1244 : * @see CSV.C, XMLOutput.C, VectorPostprocessorInterface.C
1245 : */
1246 : const VectorPostprocessor & getVectorPostprocessorObjectByName(const std::string & object_name,
1247 : const THREAD_ID tid = 0) const;
1248 :
1249 : ///@{
1250 : /**
1251 : * Returns whether or not the current simulation has any multiapps
1252 : */
1253 863 : bool hasMultiApps() const { return _multi_apps.hasActiveObjects(); }
1254 : bool hasMultiApps(ExecFlagType type) const;
1255 : bool hasMultiApp(const std::string & name) const;
1256 : ///@}
1257 :
1258 : // Dampers /////
1259 : virtual void addDamper(const std::string & damper_name,
1260 : const std::string & name,
1261 : InputParameters & parameters);
1262 : void setupDampers();
1263 :
1264 : /**
1265 : * Whether or not this system has dampers.
1266 : */
1267 370738 : bool hasDampers() { return _has_dampers; }
1268 :
1269 : // Indicators /////
1270 : virtual void addIndicator(const std::string & indicator_name,
1271 : const std::string & name,
1272 : InputParameters & parameters);
1273 :
1274 : // Markers //////
1275 : virtual void addMarker(const std::string & marker_name,
1276 : const std::string & name,
1277 : InputParameters & parameters);
1278 :
1279 : /**
1280 : * Add a MultiApp to the problem.
1281 : */
1282 : virtual void addMultiApp(const std::string & multi_app_name,
1283 : const std::string & name,
1284 : InputParameters & parameters);
1285 :
1286 : /**
1287 : * Get a MultiApp object by name.
1288 : */
1289 : std::shared_ptr<MultiApp> getMultiApp(const std::string & multi_app_name) const;
1290 :
1291 : /**
1292 : * Get Transfers by ExecFlagType and direction
1293 : */
1294 : std::vector<std::shared_ptr<Transfer>> getTransfers(ExecFlagType type,
1295 : Transfer::DIRECTION direction) const;
1296 : std::vector<std::shared_ptr<Transfer>> getTransfers(Transfer::DIRECTION direction) const;
1297 :
1298 : /**
1299 : * Return the complete warehouse for MultiAppTransfer object for the given direction
1300 : */
1301 : const ExecuteMooseObjectWarehouse<Transfer> &
1302 : getMultiAppTransferWarehouse(Transfer::DIRECTION direction) const;
1303 :
1304 : /**
1305 : * Execute MultiAppTransfers associated with execution flag and direction.
1306 : * @param type The execution flag to execute.
1307 : * @param direction The direction (to or from) to transfer.
1308 : */
1309 : void execMultiAppTransfers(ExecFlagType type, Transfer::DIRECTION direction);
1310 :
1311 : /**
1312 : * Execute the MultiApps associated with the ExecFlagType
1313 : */
1314 : bool execMultiApps(ExecFlagType type, bool auto_advance = true);
1315 :
1316 : void finalizeMultiApps();
1317 :
1318 : /**
1319 : * Advance the MultiApps t_step (incrementStepOrReject) associated with the ExecFlagType
1320 : */
1321 : void incrementMultiAppTStep(ExecFlagType type);
1322 :
1323 : /**
1324 : * Deprecated method; use finishMultiAppStep and/or incrementMultiAppTStep depending
1325 : * on your purpose
1326 : */
1327 : void advanceMultiApps(ExecFlagType type)
1328 : {
1329 : mooseDeprecated("Deprecated method; use finishMultiAppStep and/or incrementMultiAppTStep "
1330 : "depending on your purpose");
1331 : finishMultiAppStep(type);
1332 : }
1333 :
1334 : /**
1335 : * Finish the MultiApp time step (endStep, postStep) associated with the ExecFlagType. Optionally
1336 : * recurse through all multi-app levels
1337 : */
1338 : void finishMultiAppStep(ExecFlagType type, bool recurse_through_multiapp_levels = false);
1339 :
1340 : /**
1341 : * Backup the MultiApps associated with the ExecFlagType
1342 : */
1343 : void backupMultiApps(ExecFlagType type);
1344 :
1345 : /**
1346 : * Restore the MultiApps associated with the ExecFlagType
1347 : * @param force Force restoration because something went wrong with the solve
1348 : */
1349 : void restoreMultiApps(ExecFlagType type, bool force = false);
1350 :
1351 : /**
1352 : * Find the smallest timestep over all MultiApps
1353 : */
1354 : Real computeMultiAppsDT(ExecFlagType type);
1355 :
1356 : /**
1357 : * Add a Transfer to the problem.
1358 : */
1359 : virtual void addTransfer(const std::string & transfer_name,
1360 : const std::string & name,
1361 : InputParameters & parameters);
1362 :
1363 : /**
1364 : * Execute the Transfers associated with the ExecFlagType
1365 : *
1366 : * Note: This does _not_ execute MultiApp Transfers!
1367 : * Those are executed automatically when MultiApps are executed.
1368 : */
1369 : void execTransfers(ExecFlagType type);
1370 :
1371 : /**
1372 : * Computes the residual of a nonlinear system using whatever is sitting in the current
1373 : * solution vector then returns the L2 norm.
1374 : */
1375 : Real computeResidualL2Norm(NonlinearSystemBase & sys);
1376 :
1377 : /**
1378 : * Computes the residual of a linear system using whatever is sitting in the current
1379 : * solution vector then returns the L2 norm.
1380 : */
1381 : Real computeResidualL2Norm(LinearSystem & sys);
1382 :
1383 : /**
1384 : * Computes the residual using whatever is sitting in the current solution vector then returns the
1385 : * L2 norm.
1386 : *
1387 : * @return The L2 norm of the residual
1388 : */
1389 : virtual Real computeResidualL2Norm();
1390 :
1391 : /**
1392 : * This function is called by Libmesh to form a residual.
1393 : */
1394 : virtual void computeResidualSys(libMesh::NonlinearImplicitSystem & sys,
1395 : const NumericVector<libMesh::Number> & soln,
1396 : NumericVector<libMesh::Number> & residual);
1397 : /**
1398 : * This function is called by Libmesh to form a residual. This is deprecated.
1399 : * We should remove this as soon as RattleSnake is fixed.
1400 : */
1401 : void computeResidual(libMesh::NonlinearImplicitSystem & sys,
1402 : const NumericVector<libMesh::Number> & soln,
1403 : NumericVector<libMesh::Number> & residual);
1404 :
1405 : /**
1406 : * Form a residual with default tags (nontime, time, residual).
1407 : */
1408 : virtual void computeResidual(const NumericVector<libMesh::Number> & soln,
1409 : NumericVector<libMesh::Number> & residual,
1410 : const unsigned int nl_sys_num);
1411 :
1412 : /**
1413 : * Form a residual and Jacobian with default tags
1414 : */
1415 : void computeResidualAndJacobian(const NumericVector<libMesh::Number> & soln,
1416 : NumericVector<libMesh::Number> & residual,
1417 : libMesh::SparseMatrix<libMesh::Number> & jacobian);
1418 :
1419 : /**
1420 : * Form a residual vector for a given tag
1421 : */
1422 : virtual void computeResidualTag(const NumericVector<libMesh::Number> & soln,
1423 : NumericVector<libMesh::Number> & residual,
1424 : TagID tag);
1425 : /**
1426 : * Form a residual vector for a given tag and "residual" tag
1427 : */
1428 : virtual void computeResidualType(const NumericVector<libMesh::Number> & soln,
1429 : NumericVector<libMesh::Number> & residual,
1430 : TagID tag);
1431 :
1432 : /**
1433 : * Form a residual vector for a set of tags. It should not be called directly
1434 : * by users.
1435 : */
1436 : virtual void computeResidualInternal(const NumericVector<libMesh::Number> & soln,
1437 : NumericVector<libMesh::Number> & residual,
1438 : const std::set<TagID> & tags);
1439 : /**
1440 : * Form multiple residual vectors and each is associated with one tag
1441 : */
1442 : virtual void computeResidualTags(const std::set<TagID> & tags);
1443 :
1444 : /**
1445 : * Form a Jacobian matrix. It is called by Libmesh.
1446 : */
1447 : virtual void computeJacobianSys(libMesh::NonlinearImplicitSystem & sys,
1448 : const NumericVector<libMesh::Number> & soln,
1449 : libMesh::SparseMatrix<libMesh::Number> & jacobian);
1450 : /**
1451 : * Form a Jacobian matrix with the default tag (system).
1452 : */
1453 : virtual void computeJacobian(const NumericVector<libMesh::Number> & soln,
1454 : libMesh::SparseMatrix<libMesh::Number> & jacobian,
1455 : const unsigned int nl_sys_num);
1456 :
1457 : /**
1458 : * Form a Jacobian matrix for a given tag.
1459 : */
1460 : virtual void computeJacobianTag(const NumericVector<libMesh::Number> & soln,
1461 : libMesh::SparseMatrix<libMesh::Number> & jacobian,
1462 : TagID tag);
1463 :
1464 : /**
1465 : * Form a Jacobian matrix for multiple tags. It should not be called directly by users.
1466 : */
1467 : virtual void computeJacobianInternal(const NumericVector<libMesh::Number> & soln,
1468 : libMesh::SparseMatrix<libMesh::Number> & jacobian,
1469 : const std::set<TagID> & tags);
1470 :
1471 : /**
1472 : * Form multiple matrices, and each is associated with a tag.
1473 : */
1474 : virtual void computeJacobianTags(const std::set<TagID> & tags);
1475 :
1476 : /**
1477 : * Computes several Jacobian blocks simultaneously, summing their contributions into smaller
1478 : * preconditioning matrices.
1479 : *
1480 : * Used by Physics-based preconditioning
1481 : *
1482 : * @param blocks The blocks to fill in (JacobianBlock is defined in ComputeJacobianBlocksThread)
1483 : */
1484 : virtual void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks,
1485 : const unsigned int nl_sys_num);
1486 :
1487 : /**
1488 : * Really not a good idea to use this.
1489 : *
1490 : * It computes just one block of the Jacobian into a smaller matrix. Calling this in a loop is
1491 : * EXTREMELY ineffecient!
1492 : * Try to use computeJacobianBlocks() instead!
1493 : *
1494 : * @param jacobian The matrix you want to fill
1495 : * @param precond_system The libMesh::system of the preconditioning system
1496 : * @param ivar the block-row of the Jacobian
1497 : * @param jvar the block-column of the Jacobian
1498 : *
1499 : */
1500 : virtual void computeJacobianBlock(libMesh::SparseMatrix<libMesh::Number> & jacobian,
1501 : libMesh::System & precond_system,
1502 : unsigned int ivar,
1503 : unsigned int jvar);
1504 :
1505 : /**
1506 : * Assemble both the right hand side and the system matrix of a given linear
1507 : * system.
1508 : * @param sys The linear system which should be assembled
1509 : * @param system_matrix The sparse matrix which should hold the system matrix
1510 : * @param rhs The vector which should hold the right hand side
1511 : * @param compute_gradients A flag to disable the computation of new gradients during the
1512 : * assembly, can be used to lag gradients
1513 : */
1514 : virtual void computeLinearSystemSys(libMesh::LinearImplicitSystem & sys,
1515 : libMesh::SparseMatrix<libMesh::Number> & system_matrix,
1516 : NumericVector<libMesh::Number> & rhs,
1517 : const bool compute_gradients = true);
1518 :
1519 : /**
1520 : * Assemble the current linear system given a set of vector and matrix tags.
1521 : *
1522 : * @param soln The solution which should be used for the system assembly
1523 : * @param vector_tags The vector tags for the right hand side
1524 : * @param matrix_tags The matrix tags for the matrix
1525 : * @param compute_gradients A flag to disable the computation of new gradients during the
1526 : * assembly, can be used to lag gradients
1527 : */
1528 : void computeLinearSystemTags(const NumericVector<libMesh::Number> & soln,
1529 : const std::set<TagID> & vector_tags,
1530 : const std::set<TagID> & matrix_tags,
1531 : const bool compute_gradients = true);
1532 :
1533 : virtual Real computeDamping(const NumericVector<libMesh::Number> & soln,
1534 : const NumericVector<libMesh::Number> & update);
1535 :
1536 : /**
1537 : * Check to see whether the problem should update the solution
1538 : * @return true if the problem should update the solution, false otherwise
1539 : */
1540 : virtual bool shouldUpdateSolution();
1541 :
1542 : /**
1543 : * Update the solution
1544 : * @param vec_solution Local solution vector that gets modified by this method
1545 : * @param ghosted_solution Ghosted solution vector
1546 : * @return true if the solution was modified, false otherwise
1547 : */
1548 : virtual bool updateSolution(NumericVector<libMesh::Number> & vec_solution,
1549 : NumericVector<libMesh::Number> & ghosted_solution);
1550 :
1551 : /**
1552 : * Perform cleanup tasks after application of predictor to solution vector
1553 : * @param ghosted_solution Ghosted solution vector
1554 : */
1555 : virtual void predictorCleanup(NumericVector<libMesh::Number> & ghosted_solution);
1556 :
1557 : virtual void computeBounds(libMesh::NonlinearImplicitSystem & sys,
1558 : NumericVector<libMesh::Number> & lower,
1559 : NumericVector<libMesh::Number> & upper);
1560 : virtual void computeNearNullSpace(libMesh::NonlinearImplicitSystem & sys,
1561 : std::vector<NumericVector<libMesh::Number> *> & sp);
1562 : virtual void computeNullSpace(libMesh::NonlinearImplicitSystem & sys,
1563 : std::vector<NumericVector<libMesh::Number> *> & sp);
1564 : virtual void computeTransposeNullSpace(libMesh::NonlinearImplicitSystem & sys,
1565 : std::vector<NumericVector<libMesh::Number> *> & sp);
1566 : virtual void computePostCheck(libMesh::NonlinearImplicitSystem & sys,
1567 : const NumericVector<libMesh::Number> & old_soln,
1568 : NumericVector<libMesh::Number> & search_direction,
1569 : NumericVector<libMesh::Number> & new_soln,
1570 : bool & changed_search_direction,
1571 : bool & changed_new_soln);
1572 :
1573 : virtual void computeIndicatorsAndMarkers();
1574 : virtual void computeIndicators();
1575 : virtual void computeMarkers();
1576 :
1577 : virtual void addResidual(const THREAD_ID tid) override;
1578 : virtual void addResidualNeighbor(const THREAD_ID tid) override;
1579 : virtual void addResidualLower(const THREAD_ID tid) override;
1580 : virtual void addResidualScalar(const THREAD_ID tid = 0);
1581 :
1582 : virtual void cacheResidual(const THREAD_ID tid) override;
1583 : virtual void cacheResidualNeighbor(const THREAD_ID tid) override;
1584 : virtual void addCachedResidual(const THREAD_ID tid) override;
1585 :
1586 : /**
1587 : * Allows for all the residual contributions that are currently cached to be added directly into
1588 : * the vector passed in.
1589 : *
1590 : * @param residual The vector to add the cached contributions to.
1591 : * @param tid The thread id.
1592 : */
1593 : virtual void addCachedResidualDirectly(NumericVector<libMesh::Number> & residual,
1594 : const THREAD_ID tid);
1595 :
1596 : virtual void setResidual(NumericVector<libMesh::Number> & residual, const THREAD_ID tid) override;
1597 : virtual void setResidualNeighbor(NumericVector<libMesh::Number> & residual,
1598 : const THREAD_ID tid) override;
1599 :
1600 : virtual void addJacobian(const THREAD_ID tid) override;
1601 : virtual void addJacobianNeighbor(const THREAD_ID tid) override;
1602 : virtual void addJacobianNeighborLowerD(const THREAD_ID tid) override;
1603 : virtual void addJacobianLowerD(const THREAD_ID tid) override;
1604 : virtual void addJacobianBlockTags(libMesh::SparseMatrix<libMesh::Number> & jacobian,
1605 : unsigned int ivar,
1606 : unsigned int jvar,
1607 : const DofMap & dof_map,
1608 : std::vector<dof_id_type> & dof_indices,
1609 : const std::set<TagID> & tags,
1610 : const THREAD_ID tid);
1611 : virtual void addJacobianNeighbor(libMesh::SparseMatrix<libMesh::Number> & jacobian,
1612 : unsigned int ivar,
1613 : unsigned int jvar,
1614 : const DofMap & dof_map,
1615 : std::vector<dof_id_type> & dof_indices,
1616 : std::vector<dof_id_type> & neighbor_dof_indices,
1617 : const std::set<TagID> & tags,
1618 : const THREAD_ID tid) override;
1619 : virtual void addJacobianScalar(const THREAD_ID tid = 0);
1620 : virtual void addJacobianOffDiagScalar(unsigned int ivar, const THREAD_ID tid = 0);
1621 :
1622 : virtual void cacheJacobian(const THREAD_ID tid) override;
1623 : virtual void cacheJacobianNeighbor(const THREAD_ID tid) override;
1624 : virtual void addCachedJacobian(const THREAD_ID tid) override;
1625 :
1626 : virtual void prepareShapes(unsigned int var, const THREAD_ID tid) override;
1627 : virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) override;
1628 : virtual void prepareNeighborShapes(unsigned int var, const THREAD_ID tid) override;
1629 :
1630 : // Displaced problem /////
1631 : virtual void addDisplacedProblem(std::shared_ptr<DisplacedProblem> displaced_problem);
1632 0 : virtual std::shared_ptr<const DisplacedProblem> getDisplacedProblem() const
1633 : {
1634 0 : return _displaced_problem;
1635 : }
1636 4658327 : virtual std::shared_ptr<DisplacedProblem> getDisplacedProblem() { return _displaced_problem; }
1637 :
1638 : virtual void updateGeomSearch(
1639 : GeometricSearchData::GeometricSearchType type = GeometricSearchData::ALL) override;
1640 : virtual void updateMortarMesh();
1641 :
1642 : void createMortarInterface(
1643 : const std::pair<BoundaryID, BoundaryID> & primary_secondary_boundary_pair,
1644 : const std::pair<SubdomainID, SubdomainID> & primary_secondary_subdomain_pair,
1645 : bool on_displaced,
1646 : bool periodic,
1647 : const bool debug,
1648 : const bool correct_edge_dropping,
1649 : const Real minimum_projection_angle);
1650 :
1651 : /**
1652 : * Return the undisplaced or displaced mortar generation object associated with the provided
1653 : * boundaries and subdomains
1654 : */
1655 : ///@{
1656 : const AutomaticMortarGeneration &
1657 : getMortarInterface(const std::pair<BoundaryID, BoundaryID> & primary_secondary_boundary_pair,
1658 : const std::pair<SubdomainID, SubdomainID> & primary_secondary_subdomain_pair,
1659 : bool on_displaced) const;
1660 :
1661 : AutomaticMortarGeneration &
1662 : getMortarInterface(const std::pair<BoundaryID, BoundaryID> & primary_secondary_boundary_pair,
1663 : const std::pair<SubdomainID, SubdomainID> & primary_secondary_subdomain_pair,
1664 : bool on_displaced);
1665 : ///@}
1666 :
1667 : const std::unordered_map<std::pair<BoundaryID, BoundaryID>, AutomaticMortarGeneration> &
1668 : getMortarInterfaces(bool on_displaced) const;
1669 :
1670 : virtual void possiblyRebuildGeomSearchPatches();
1671 :
1672 654457 : virtual GeometricSearchData & geomSearchData() override { return _geometric_search_data; }
1673 :
1674 : /**
1675 : * Communicate to the Resurector the name of the restart filer
1676 : * @param file_name The file name for restarting from
1677 : */
1678 : void setRestartFile(const std::string & file_name);
1679 :
1680 : /**
1681 : * @return A reference to the material property registry
1682 : */
1683 0 : const MaterialPropertyRegistry & getMaterialPropertyRegistry() const
1684 : {
1685 0 : return _material_prop_registry;
1686 : }
1687 :
1688 : /**
1689 : * Return a reference to the material property storage
1690 : * @return A const reference to the material property storage
1691 : */
1692 : ///@{
1693 : const MaterialPropertyStorage & getMaterialPropertyStorage() { return _material_props; }
1694 : const MaterialPropertyStorage & getBndMaterialPropertyStorage() { return _bnd_material_props; }
1695 : const MaterialPropertyStorage & getNeighborMaterialPropertyStorage()
1696 : {
1697 : return _neighbor_material_props;
1698 : }
1699 : ///@}
1700 :
1701 : /**
1702 : * Return indicator/marker storage.
1703 : */
1704 : ///@{
1705 5128 : const MooseObjectWarehouse<Indicator> & getIndicatorWarehouse() { return _indicators; }
1706 5128 : const MooseObjectWarehouse<InternalSideIndicatorBase> & getInternalSideIndicatorWarehouse()
1707 : {
1708 5128 : return _internal_side_indicators;
1709 : }
1710 6996 : const MooseObjectWarehouse<Marker> & getMarkerWarehouse() { return _markers; }
1711 : ///@}
1712 :
1713 : /**
1714 : * Return InitialCondition storage
1715 : */
1716 4290887 : const InitialConditionWarehouse & getInitialConditionWarehouse() const { return _ics; }
1717 :
1718 : /**
1719 : * Return FVInitialCondition storage
1720 : */
1721 10748 : const FVInitialConditionWarehouse & getFVInitialConditionWarehouse() const { return _fv_ics; }
1722 :
1723 : /**
1724 : * Get the solver parameters
1725 : */
1726 : SolverParams & solverParams(unsigned int solver_sys_num = 0);
1727 :
1728 : /**
1729 : * const version
1730 : */
1731 : const SolverParams & solverParams(unsigned int solver_sys_num = 0) const;
1732 :
1733 : #ifdef LIBMESH_ENABLE_AMR
1734 : // Adaptivity /////
1735 157543 : Adaptivity & adaptivity() { return _adaptivity; }
1736 : virtual void initialAdaptMesh();
1737 :
1738 : /**
1739 : * @returns Whether or not the mesh was changed
1740 : */
1741 : virtual bool adaptMesh();
1742 :
1743 : /**
1744 : * @return The number of adaptivity cycles completed.
1745 : */
1746 183 : unsigned int getNumCyclesCompleted() { return _cycles_completed; }
1747 :
1748 : /**
1749 : * Return a Boolean indicating whether initial AMR is turned on.
1750 : */
1751 : bool hasInitialAdaptivity() const { return _adaptivity.getInitialSteps() > 0; }
1752 : #else
1753 : /**
1754 : * Return a Boolean indicating whether initial AMR is turned on.
1755 : */
1756 : bool hasInitialAdaptivity() const { return false; }
1757 : #endif // LIBMESH_ENABLE_AMR
1758 :
1759 : /// Create XFEM controller object
1760 : void initXFEM(std::shared_ptr<XFEMInterface> xfem);
1761 :
1762 : /// Get a pointer to the XFEM controller object
1763 : std::shared_ptr<XFEMInterface> getXFEM() { return _xfem; }
1764 :
1765 : /// Find out whether the current analysis is using XFEM
1766 1289759 : bool haveXFEM() { return _xfem != nullptr; }
1767 :
1768 : /// Update the mesh due to changing XFEM cuts
1769 : virtual bool updateMeshXFEM();
1770 :
1771 : /**
1772 : * Update data after a mesh change.
1773 : * Iff intermediate_change is true, only perform updates as
1774 : * necessary to prepare for another mesh change
1775 : * immediately-subsequent. An example of data that is not updated during an intermediate change is
1776 : * libMesh System matrix data. An example of data that \emph is updated during an intermediate
1777 : * change is libMesh System vectors. These vectors are projected or restricted based off of
1778 : * adaptive mesh refinement or the changing of element subdomain IDs. The flags \p contract_mesh
1779 : * and \p clean_refinement_flags should generally only be set to true when the mesh has changed
1780 : * due to mesh refinement. \p contract_mesh deletes children of coarsened elements and renumbers
1781 : * nodes and elements. \p clean_refinement_flags resets refinement flags such that any subsequent
1782 : * calls to \p System::restrict_vectors or \p System::prolong_vectors before another AMR step do
1783 : * not mistakenly attempt to re-do the restriction/prolongation which occurred in this method
1784 : */
1785 : virtual void
1786 : meshChanged(bool intermediate_change, bool contract_mesh, bool clean_refinement_flags);
1787 :
1788 : /**
1789 : * Register an object that derives from MeshChangedInterface
1790 : * to be notified when the mesh changes.
1791 : */
1792 : void notifyWhenMeshChanges(MeshChangedInterface * mci);
1793 :
1794 : /**
1795 : * Register an object that derives from MeshDisplacedInterface
1796 : * to be notified when the displaced mesh gets updated.
1797 : */
1798 : void notifyWhenMeshDisplaces(MeshDisplacedInterface * mdi);
1799 :
1800 : /**
1801 : * Initialize stateful properties for elements in a specific \p elem_range
1802 : * This is needed when elements/boundary nodes are added to a specific subdomain
1803 : * at an intermediate step
1804 : */
1805 : void initElementStatefulProps(const libMesh::ConstElemRange & elem_range, const bool threaded);
1806 :
1807 : /**
1808 : * Method called to perform a series of sanity checks before a simulation is run. This method
1809 : * doesn't return when errors are found, instead it generally calls mooseError() directly.
1810 : */
1811 : virtual void checkProblemIntegrity();
1812 :
1813 : void registerRandomInterface(RandomInterface & random_interface, const std::string & name);
1814 :
1815 : /**
1816 : * Set flag that Jacobian is constant (for optimization purposes)
1817 : * @param state True if the Jacobian is constant, false otherwise
1818 : */
1819 4621 : void setConstJacobian(bool state) { _const_jacobian = state; }
1820 :
1821 : /**
1822 : * Set flag to indicate whether kernel coverage checks should be performed. This check makes
1823 : * sure that at least one kernel is active on all subdomains in the domain (default: true).
1824 : */
1825 : void setKernelCoverageCheck(CoverageCheckMode mode) { _kernel_coverage_check = mode; }
1826 :
1827 : /**
1828 : * Set flag to indicate whether kernel coverage checks should be performed. This check makes
1829 : * sure that at least one kernel is active on all subdomains in the domain (default: true).
1830 : */
1831 : void setKernelCoverageCheck(bool flag)
1832 : {
1833 : _kernel_coverage_check = flag ? CoverageCheckMode::TRUE : CoverageCheckMode::FALSE;
1834 : }
1835 :
1836 : /**
1837 : * Set flag to indicate whether material coverage checks should be performed. This check makes
1838 : * sure that at least one material is active on all subdomains in the domain if any material is
1839 : * supplied. If no materials are supplied anywhere, a simulation is still considered OK as long as
1840 : * no properties are being requested anywhere.
1841 : */
1842 : void setMaterialCoverageCheck(CoverageCheckMode mode) { _material_coverage_check = mode; }
1843 :
1844 : /**
1845 : * Set flag to indicate whether material coverage checks should be performed. This check makes
1846 : * sure that at least one material is active on all subdomains in the domain if any material is
1847 : * supplied. If no materials are supplied anywhere, a simulation is still considered OK as long as
1848 : * no properties are being requested anywhere.
1849 : */
1850 : void setMaterialCoverageCheck(bool flag)
1851 : {
1852 : _material_coverage_check = flag ? CoverageCheckMode::TRUE : CoverageCheckMode::FALSE;
1853 : }
1854 :
1855 : /**
1856 : * Toggle parallel barrier messaging (defaults to on).
1857 : */
1858 : void setParallelBarrierMessaging(bool flag) { _parallel_barrier_messaging = flag; }
1859 :
1860 : /// Make the problem be verbose
1861 : void setVerboseProblem(bool verbose);
1862 :
1863 : /**
1864 : * Whether or not to use verbose printing for MultiApps.
1865 : */
1866 215814 : bool verboseMultiApps() const { return _verbose_multiapps; }
1867 :
1868 : /**
1869 : * Calls parentOutputPositionChanged() on all sub apps.
1870 : */
1871 : void parentOutputPositionChanged();
1872 :
1873 : ///@{
1874 : /**
1875 : * These methods are used to determine whether stateful material properties need to be stored on
1876 : * internal sides. There are five situations where this may be the case: 1) DGKernels
1877 : * 2) IntegratedBCs 3)InternalSideUserObjects 4)ElementalAuxBCs 5)InterfaceUserObjects
1878 : *
1879 : * Method 1:
1880 : * @param bnd_id the boundary id for which to see if stateful material properties need to be
1881 : * stored
1882 : * @param tid the THREAD_ID of the caller
1883 : * @return Boolean indicating whether material properties need to be stored
1884 : *
1885 : * Method 2:
1886 : * @param subdomain_id the subdomain id for which to see if stateful material properties need to
1887 : * be stored
1888 : * @param tid the THREAD_ID of the caller
1889 : * @return Boolean indicating whether material properties need to be stored
1890 : */
1891 : bool needBoundaryMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid);
1892 : bool needInterfaceMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid);
1893 : bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, const THREAD_ID tid);
1894 : ///@}
1895 :
1896 : /**
1897 : * Dimension of the subspace spanned by vectors with a given prefix.
1898 : * @param prefix Prefix of the vectors spanning the subspace.
1899 : */
1900 957392 : unsigned int subspaceDim(const std::string & prefix) const
1901 : {
1902 957392 : if (_subspace_dim.count(prefix))
1903 957392 : return _subspace_dim.find(prefix)->second;
1904 : else
1905 0 : return 0;
1906 : }
1907 :
1908 : /*
1909 : * Return a reference to the material warehouse of *all* Material objects.
1910 : */
1911 5557561 : const MaterialWarehouse & getMaterialWarehouse() const { return _all_materials; }
1912 :
1913 : /*
1914 : * Return a reference to the material warehouse of Material objects to be computed.
1915 : */
1916 10332 : const MaterialWarehouse & getRegularMaterialsWarehouse() const { return _materials; }
1917 9269 : const MaterialWarehouse & getDiscreteMaterialWarehouse() const { return _discrete_materials; }
1918 10659 : const MaterialWarehouse & getInterfaceMaterialsWarehouse() const { return _interface_materials; }
1919 :
1920 : /**
1921 : * Return a pointer to a MaterialBase object. If no_warn is true, suppress
1922 : * warning about retrieving a material reference potentially during the
1923 : * material's calculation.
1924 : *
1925 : * This will return enabled or disabled objects, the main purpose is for iterative materials.
1926 : */
1927 : std::shared_ptr<MaterialBase> getMaterial(std::string name,
1928 : Moose::MaterialDataType type,
1929 : const THREAD_ID tid = 0,
1930 : bool no_warn = false);
1931 :
1932 : /*
1933 : * @return The MaterialData for the type \p type for thread \p tid
1934 : */
1935 : MaterialData & getMaterialData(Moose::MaterialDataType type, const THREAD_ID tid = 0) const;
1936 :
1937 : /**
1938 : * @returns Whether the original matrix nonzero pattern is restored before each Jacobian assembly
1939 : */
1940 516619 : bool restoreOriginalNonzeroPattern() const { return _restore_original_nonzero_pattern; }
1941 :
1942 : /**
1943 : * Will return True if the user wants to get an error when
1944 : * a nonzero is reallocated in the Jacobian by PETSc
1945 : */
1946 532812 : bool errorOnJacobianNonzeroReallocation() const
1947 : {
1948 532812 : return _error_on_jacobian_nonzero_reallocation;
1949 : }
1950 :
1951 306 : void setErrorOnJacobianNonzeroReallocation(bool state)
1952 : {
1953 306 : _error_on_jacobian_nonzero_reallocation = state;
1954 306 : }
1955 :
1956 : /**
1957 : * Will return True if the executioner in use requires preserving the sparsity pattern of the
1958 : * matrices being formed during the solve. This is usually the Jacobian.
1959 : */
1960 : bool preserveMatrixSparsityPattern() const { return _preserve_matrix_sparsity_pattern; };
1961 :
1962 : /// Set whether the sparsity pattern of the matrices being formed during the solve (usually the Jacobian)
1963 : /// should be preserved. This global setting can be retrieved by kernels, notably those using AD, to decide
1964 : /// whether to take additional care to preserve the sparsity pattern
1965 : void setPreserveMatrixSparsityPattern(bool preserve);
1966 :
1967 : /**
1968 : * Will return true if zeros in the Jacobian are to be dropped from the sparsity pattern.
1969 : * Note that this can make preserving the matrix sparsity pattern impossible.
1970 : */
1971 525910 : bool ignoreZerosInJacobian() const { return _ignore_zeros_in_jacobian; }
1972 :
1973 : /// Set whether the zeros in the Jacobian should be dropped from the sparsity pattern
1974 : void setIgnoreZerosInJacobian(bool state) { _ignore_zeros_in_jacobian = state; }
1975 :
1976 : /**
1977 : * Whether or not to accept the solution based on its invalidity.
1978 : *
1979 : * If this returns false, it means that an invalid solution was encountered
1980 : * (an error) that was not allowed.
1981 : */
1982 : bool acceptInvalidSolution() const;
1983 : /**
1984 : * Whether to accept / allow an invalid solution
1985 : */
1986 334835 : bool allowInvalidSolution() const { return _allow_invalid_solution; }
1987 :
1988 : /**
1989 : * Whether or not to print out the invalid solutions summary table in console
1990 : */
1991 691 : bool showInvalidSolutionConsole() const { return _show_invalid_solution_console; }
1992 :
1993 : /**
1994 : * Whether or not the solution invalid warnings are printed out immediately
1995 : */
1996 97513 : bool immediatelyPrintInvalidSolution() const { return _immediately_print_invalid_solution; }
1997 :
1998 : /// Returns whether or not this Problem has a TimeIntegrator
1999 31225 : bool hasTimeIntegrator() const { return _has_time_integrator; }
2000 :
2001 : ///@{
2002 : /**
2003 : * Return/set the current execution flag.
2004 : *
2005 : * Returns EXEC_NONE when not being executed.
2006 : * @see FEProblemBase::execute
2007 : */
2008 : const ExecFlagType & getCurrentExecuteOnFlag() const;
2009 : void setCurrentExecuteOnFlag(const ExecFlagType &);
2010 : ///@}
2011 :
2012 : /**
2013 : * Convenience function for performing execution of MOOSE systems.
2014 : */
2015 : virtual void execute(const ExecFlagType & exec_type);
2016 : virtual void executeAllObjects(const ExecFlagType & exec_type);
2017 :
2018 0 : virtual Executor & getExecutor(const std::string & name) { return _app.getExecutor(name); }
2019 :
2020 : /**
2021 : * Call compute methods on UserObjects.
2022 : */
2023 : virtual void computeUserObjects(const ExecFlagType & type, const Moose::AuxGroup & group);
2024 :
2025 : /**
2026 : * Compute an user object with the given name
2027 : */
2028 : virtual void computeUserObjectByName(const ExecFlagType & type,
2029 : const Moose::AuxGroup & group,
2030 : const std::string & name);
2031 :
2032 : /**
2033 : * Set a flag that indicated that user required values for the previous Newton iterate
2034 : */
2035 : void needsPreviousNewtonIteration(bool state);
2036 :
2037 : /**
2038 : * Check to see whether we need to compute the variable values of the previous Newton iterate
2039 : * @return true if the user required values of the previous Newton iterate
2040 : */
2041 : bool needsPreviousNewtonIteration() const;
2042 :
2043 : ///@{
2044 : /**
2045 : * Convenience zeros
2046 : */
2047 : std::vector<Real> _real_zero;
2048 : std::vector<VariableValue> _scalar_zero;
2049 : std::vector<VariableValue> _zero;
2050 : std::vector<VariablePhiValue> _phi_zero;
2051 : std::vector<MooseArray<ADReal>> _ad_zero;
2052 : std::vector<VariableGradient> _grad_zero;
2053 : std::vector<MooseArray<ADRealVectorValue>> _ad_grad_zero;
2054 : std::vector<VariablePhiGradient> _grad_phi_zero;
2055 : std::vector<VariableSecond> _second_zero;
2056 : std::vector<MooseArray<ADRealTensorValue>> _ad_second_zero;
2057 : std::vector<VariablePhiSecond> _second_phi_zero;
2058 : std::vector<Point> _point_zero;
2059 : std::vector<VectorVariableValue> _vector_zero;
2060 : std::vector<VectorVariableCurl> _vector_curl_zero;
2061 : ///@}
2062 :
2063 : /**
2064 : * Reference to the control logic warehouse.
2065 : */
2066 61993 : ExecuteMooseObjectWarehouse<Control> & getControlWarehouse() { return _control_warehouse; }
2067 :
2068 : /**
2069 : * Performs setup and execute calls for Control objects.
2070 : */
2071 : void executeControls(const ExecFlagType & exec_type);
2072 :
2073 : /**
2074 : * Performs setup and execute calls for Sampler objects.
2075 : */
2076 : void executeSamplers(const ExecFlagType & exec_type);
2077 :
2078 : /**
2079 : * Update the active objects in the warehouses
2080 : */
2081 : virtual void updateActiveObjects();
2082 :
2083 : /**
2084 : * Register a MOOSE object dependency so we can either order
2085 : * operations properly or report when we cannot.
2086 : * a -> b (a depends on b)
2087 : */
2088 : void reportMooseObjectDependency(MooseObject * a, MooseObject * b);
2089 :
2090 95278 : ExecuteMooseObjectWarehouse<MultiApp> & getMultiAppWarehouse() { return _multi_apps; }
2091 :
2092 : /**
2093 : * Returns _has_jacobian
2094 : */
2095 : bool hasJacobian() const;
2096 :
2097 : /**
2098 : * Returns _const_jacobian (whether a MOOSE object has specified that
2099 : * the Jacobian is the same as the previous time it was computed)
2100 : */
2101 : bool constJacobian() const;
2102 :
2103 : /**
2104 : * Adds an Output object.
2105 : */
2106 : void addOutput(const std::string &, const std::string &, InputParameters &);
2107 :
2108 33087361 : inline TheWarehouse & theWarehouse() const { return _app.theWarehouse(); }
2109 :
2110 : /**
2111 : * If or not to reuse the base vector for matrix-free calculation
2112 : */
2113 61913 : void setSNESMFReuseBase(bool reuse, bool set_by_user)
2114 : {
2115 61913 : _snesmf_reuse_base = reuse, _snesmf_reuse_base_set_by_user = set_by_user;
2116 61913 : }
2117 :
2118 : /**
2119 : * Return a flag that indicates if we are reusing the vector base
2120 : */
2121 316785 : bool useSNESMFReuseBase() { return _snesmf_reuse_base; }
2122 :
2123 : /**
2124 : * Set a flag that indicates if we want to skip exception and stop solve
2125 : */
2126 61913 : void skipExceptionCheck(bool skip_exception_check)
2127 : {
2128 61913 : _skip_exception_check = skip_exception_check;
2129 61913 : }
2130 :
2131 : /**
2132 : * Return a flag to indicate if _snesmf_reuse_base is set by users
2133 : */
2134 : bool isSNESMFReuseBaseSetbyUser() { return _snesmf_reuse_base_set_by_user; }
2135 :
2136 : /**
2137 : * If PETSc options are already inserted
2138 : */
2139 1126 : bool & petscOptionsInserted() { return _is_petsc_options_inserted; }
2140 :
2141 : #if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
2142 26 : PetscOptions & petscOptionsDatabase() { return _petsc_option_data_base; }
2143 : #endif
2144 :
2145 : /// Set boolean flag to true to store solution time derivative
2146 61486 : virtual void setUDotRequested(const bool u_dot_requested) { _u_dot_requested = u_dot_requested; }
2147 :
2148 : /// Set boolean flag to true to store solution second time derivative
2149 328 : virtual void setUDotDotRequested(const bool u_dotdot_requested)
2150 : {
2151 328 : _u_dotdot_requested = u_dotdot_requested;
2152 328 : }
2153 :
2154 : /// Set boolean flag to true to store old solution time derivative
2155 328 : virtual void setUDotOldRequested(const bool u_dot_old_requested)
2156 : {
2157 328 : _u_dot_old_requested = u_dot_old_requested;
2158 328 : }
2159 :
2160 : /// Set boolean flag to true to store old solution second time derivative
2161 328 : virtual void setUDotDotOldRequested(const bool u_dotdot_old_requested)
2162 : {
2163 328 : _u_dotdot_old_requested = u_dotdot_old_requested;
2164 328 : }
2165 :
2166 : /// Get boolean flag to check whether solution time derivative needs to be stored
2167 61364 : virtual bool uDotRequested() { return _u_dot_requested; }
2168 :
2169 : /// Get boolean flag to check whether solution second time derivative needs to be stored
2170 92050 : virtual bool uDotDotRequested() { return _u_dotdot_requested; }
2171 :
2172 : /// Get boolean flag to check whether old solution time derivative needs to be stored
2173 61364 : virtual bool uDotOldRequested()
2174 : {
2175 61364 : if (_u_dot_old_requested && !_u_dot_requested)
2176 0 : mooseError("FEProblemBase: When requesting old time derivative of solution, current time "
2177 : "derivative of solution should also be stored. Please set `u_dot_requested` to "
2178 : "true using setUDotRequested.");
2179 :
2180 61364 : return _u_dot_old_requested;
2181 : }
2182 :
2183 : /// Get boolean flag to check whether old solution second time derivative needs to be stored
2184 61364 : virtual bool uDotDotOldRequested()
2185 : {
2186 61364 : if (_u_dotdot_old_requested && !_u_dotdot_requested)
2187 0 : mooseError("FEProblemBase: When requesting old second time derivative of solution, current "
2188 : "second time derivation of solution should also be stored. Please set "
2189 : "`u_dotdot_requested` to true using setUDotDotRequested.");
2190 61364 : return _u_dotdot_old_requested;
2191 : }
2192 :
2193 : using SubProblem::haveADObjects;
2194 : void haveADObjects(bool have_ad_objects) override;
2195 :
2196 : // Whether or not we should solve this system
2197 346682 : bool shouldSolve() const { return _solve; }
2198 :
2199 : /**
2200 : * Returns the mortar data object
2201 : */
2202 : const MortarData & mortarData() const { return _mortar_data; }
2203 1422 : MortarData & mortarData() { return _mortar_data; }
2204 :
2205 : /**
2206 : * Whether the simulation has neighbor coupling
2207 : */
2208 0 : virtual bool hasNeighborCoupling() const { return _has_internal_edge_residual_objects; }
2209 :
2210 : /**
2211 : * Whether the simulation has mortar coupling
2212 : */
2213 0 : virtual bool hasMortarCoupling() const { return _has_mortar; }
2214 :
2215 : using SubProblem::computingNonlinearResid;
2216 : void computingNonlinearResid(bool computing_nonlinear_residual) final;
2217 :
2218 : using SubProblem::currentlyComputingResidual;
2219 : void setCurrentlyComputingResidual(bool currently_computing_residual) final;
2220 :
2221 : /**
2222 : * Set the number of steps in a grid sequences
2223 : */
2224 61893 : void numGridSteps(unsigned int num_grid_steps) { _num_grid_steps = num_grid_steps; }
2225 :
2226 : /**
2227 : * uniformly refine the problem mesh(es). This will also prolong the the solution, and in order
2228 : * for that to be safe, we can only perform one refinement at a time
2229 : */
2230 : void uniformRefine();
2231 :
2232 : using SubProblem::automaticScaling;
2233 : void automaticScaling(bool automatic_scaling) override;
2234 :
2235 : ///@{
2236 : /**
2237 : * Helpers for calling the necessary setup/execute functions for the supplied objects
2238 : */
2239 : template <typename T>
2240 : static void objectSetupHelper(const std::vector<T *> & objects, const ExecFlagType & exec_flag);
2241 : template <typename T>
2242 : static void objectExecuteHelper(const std::vector<T *> & objects);
2243 : ///@}
2244 :
2245 : /**
2246 : * reinitialize FE objects on a given element on a given side at a given set of reference
2247 : * points and then compute variable data. Note that this method makes no assumptions about what's
2248 : * been called beforehand, e.g. you don't have to call some prepare method before this one. This
2249 : * is an all-in-one reinit
2250 : */
2251 : virtual void reinitElemFaceRef(const Elem * elem,
2252 : unsigned int side,
2253 : Real tolerance,
2254 : const std::vector<Point> * const pts,
2255 : const std::vector<Real> * const weights = nullptr,
2256 : const THREAD_ID tid = 0) override;
2257 :
2258 : /**
2259 : * reinitialize FE objects on a given neighbor element on a given side at a given set of reference
2260 : * points and then compute variable data. Note that this method makes no assumptions about what's
2261 : * been called beforehand, e.g. you don't have to call some prepare method before this one. This
2262 : * is an all-in-one reinit
2263 : */
2264 : virtual void reinitNeighborFaceRef(const Elem * neighbor_elem,
2265 : unsigned int neighbor_side,
2266 : Real tolerance,
2267 : const std::vector<Point> * const pts,
2268 : const std::vector<Real> * const weights = nullptr,
2269 : const THREAD_ID tid = 0) override;
2270 :
2271 : /**
2272 : * @return whether to perform a boundary condition integrity check for finite volume
2273 : */
2274 3414 : bool fvBCsIntegrityCheck() const { return _fv_bcs_integrity_check; }
2275 :
2276 : /**
2277 : * @param fv_bcs_integrity_check Whether to perform a boundary condition integrity check for
2278 : * finite volume
2279 : */
2280 : void fvBCsIntegrityCheck(bool fv_bcs_integrity_check);
2281 :
2282 : /**
2283 : * Get the materials and variables potentially needed for FV
2284 : * @param block_id SubdomainID The subdomain id that we want to retrieve materials for
2285 : * @param face_materials The face materials container that we will fill
2286 : * @param neighbor_materials The neighbor materials container that we will fill
2287 : * @param variables The variables container that we will fill that our materials depend on
2288 : * @param tid The thread id
2289 : */
2290 : void getFVMatsAndDependencies(SubdomainID block_id,
2291 : std::vector<std::shared_ptr<MaterialBase>> & face_materials,
2292 : std::vector<std::shared_ptr<MaterialBase>> & neighbor_materials,
2293 : std::set<MooseVariableFieldBase *> & variables,
2294 : const THREAD_ID tid);
2295 :
2296 : /**
2297 : * Resize material data
2298 : * @param data_type The type of material data to resize
2299 : * @param nqp The number of quadrature points to resize for
2300 : * @param tid The thread ID
2301 : */
2302 : void resizeMaterialData(Moose::MaterialDataType data_type, unsigned int nqp, const THREAD_ID tid);
2303 :
2304 0 : bool haveDisplaced() const override final { return _displaced_problem.get(); }
2305 :
2306 : /// Whether we have linear convergence objects
2307 : bool hasLinearConvergenceObjects() const;
2308 : /**
2309 : * Sets the nonlinear convergence object name(s) if there is one
2310 : */
2311 : void setNonlinearConvergenceNames(const std::vector<ConvergenceName> & convergence_names);
2312 : /**
2313 : * Sets the linear convergence object name(s) if there is one
2314 : */
2315 : void setLinearConvergenceNames(const std::vector<ConvergenceName> & convergence_names);
2316 : /**
2317 : * Sets the MultiApp fixed point convergence object name if there is one
2318 : */
2319 : void setMultiAppFixedPointConvergenceName(const ConvergenceName & convergence_name);
2320 : /**
2321 : * Sets the steady-state detection convergence object name if there is one
2322 : */
2323 : void setSteadyStateConvergenceName(const ConvergenceName & convergence_name);
2324 :
2325 : /**
2326 : * Gets the nonlinear system convergence object name(s).
2327 : */
2328 : const std::vector<ConvergenceName> & getNonlinearConvergenceNames() const;
2329 : /**
2330 : * Gets the linear convergence object name(s).
2331 : */
2332 : const std::vector<ConvergenceName> & getLinearConvergenceNames() const;
2333 : /**
2334 : * Gets the MultiApp fixed point convergence object name.
2335 : */
2336 : const ConvergenceName & getMultiAppFixedPointConvergenceName() const;
2337 : /**
2338 : * Gets the steady-state detection convergence object name.
2339 : */
2340 : const ConvergenceName & getSteadyStateConvergenceName() const;
2341 :
2342 : /**
2343 : * Setter for whether we're computing the scaling jacobian
2344 : */
2345 1204 : void computingScalingJacobian(bool computing_scaling_jacobian)
2346 : {
2347 1204 : _computing_scaling_jacobian = computing_scaling_jacobian;
2348 1204 : }
2349 :
2350 79849594 : bool computingScalingJacobian() const override final { return _computing_scaling_jacobian; }
2351 :
2352 : /**
2353 : * Setter for whether we're computing the scaling residual
2354 : */
2355 100 : void computingScalingResidual(bool computing_scaling_residual)
2356 : {
2357 100 : _computing_scaling_residual = computing_scaling_residual;
2358 100 : }
2359 :
2360 : /**
2361 : * @return whether we are currently computing a residual for automatic scaling purposes
2362 : */
2363 6744053 : bool computingScalingResidual() const override final { return _computing_scaling_residual; }
2364 :
2365 : /**
2366 : * @return the coordinate transformation object that describes how to transform this problem's
2367 : * coordinate system into the canonical/reference coordinate system
2368 : */
2369 : MooseAppCoordTransform & coordTransform();
2370 :
2371 184296892 : virtual std::size_t numNonlinearSystems() const override { return _num_nl_sys; }
2372 :
2373 432602 : virtual std::size_t numLinearSystems() const override { return _num_linear_sys; }
2374 :
2375 11905269 : virtual std::size_t numSolverSystems() const override { return _num_nl_sys + _num_linear_sys; }
2376 :
2377 : /// Check if the solver system is nonlinear
2378 225700 : bool isSolverSystemNonlinear(const unsigned int sys_num) { return sys_num < _num_nl_sys; }
2379 :
2380 : virtual unsigned int currentNlSysNum() const override;
2381 :
2382 : virtual unsigned int currentLinearSysNum() const override;
2383 :
2384 : /**
2385 : * @return the nonlinear system number corresponding to the provided \p nl_sys_name
2386 : */
2387 : virtual unsigned int nlSysNum(const NonlinearSystemName & nl_sys_name) const override;
2388 :
2389 : /**
2390 : * @return the linear system number corresponding to the provided \p linear_sys_name
2391 : */
2392 : unsigned int linearSysNum(const LinearSystemName & linear_sys_name) const override;
2393 :
2394 : /**
2395 : * @return the solver system number corresponding to the provided \p solver_sys_name
2396 : */
2397 : unsigned int solverSysNum(const SolverSystemName & solver_sys_name) const override;
2398 :
2399 : /**
2400 : * @return the system number for the provided \p variable_name
2401 : * Can be nonlinear or auxiliary
2402 : */
2403 : unsigned int systemNumForVariable(const VariableName & variable_name) const;
2404 :
2405 : /// Whether it will skip further residual evaluations and fail the next nonlinear convergence check(s)
2406 2212490 : bool getFailNextNonlinearConvergenceCheck() const { return getFailNextSystemConvergenceCheck(); }
2407 : /// Whether it will fail the next system convergence check(s), triggering failed step behavior
2408 2215124 : bool getFailNextSystemConvergenceCheck() const { return _fail_next_system_convergence_check; }
2409 :
2410 : /// Skip further residual evaluations and fail the next nonlinear convergence check(s)
2411 98 : void setFailNextNonlinearConvergenceCheck() { setFailNextSystemConvergenceCheck(); }
2412 : /// Tell the problem that the system(s) cannot be considered converged next time convergence is checked
2413 98 : void setFailNextSystemConvergenceCheck() { _fail_next_system_convergence_check = true; }
2414 :
2415 : /// Tell the problem that the nonlinear convergence check(s) may proceed as normal
2416 212 : void resetFailNextNonlinearConvergenceCheck() { resetFailNextSystemConvergenceCheck(); }
2417 : /// Tell the problem that the system convergence check(s) may proceed as normal
2418 212 : void resetFailNextSystemConvergenceCheck() { _fail_next_system_convergence_check = false; }
2419 :
2420 : /*
2421 : * Set the status of loop order of execution printing
2422 : * @param print_exec set of execution flags to print on
2423 : */
2424 272 : void setExecutionPrinting(const ExecFlagEnum & print_exec) { _print_execution_on = print_exec; }
2425 :
2426 : /**
2427 : * Check whether the problem should output execution orders at this time
2428 : */
2429 : bool shouldPrintExecution(const THREAD_ID tid) const;
2430 : /**
2431 : * Call \p reinit on mortar user objects with matching primary boundary ID, secondary boundary ID,
2432 : * and displacement characteristics
2433 : */
2434 : void reinitMortarUserObjects(BoundaryID primary_boundary_id,
2435 : BoundaryID secondary_boundary_id,
2436 : bool displaced);
2437 :
2438 : virtual const std::vector<VectorTag> & currentResidualVectorTags() const override;
2439 :
2440 : /**
2441 : * Class that is used as a parameter to set/clearCurrentResidualVectorTags that allows only
2442 : * blessed classes to call said methods
2443 : */
2444 : class CurrentResidualVectorTagsKey
2445 : {
2446 : friend class CrankNicolson;
2447 : friend class FEProblemBase;
2448 : CurrentResidualVectorTagsKey() {}
2449 : CurrentResidualVectorTagsKey(const CurrentResidualVectorTagsKey &) {}
2450 : };
2451 :
2452 : /**
2453 : * Set the current residual vector tag data structure based on the passed in tag IDs
2454 : */
2455 : void setCurrentResidualVectorTags(const std::set<TagID> & vector_tags);
2456 :
2457 : /**
2458 : * Clear the current residual vector tag data structure
2459 : */
2460 : void clearCurrentResidualVectorTags();
2461 :
2462 : /**
2463 : * Clear the current Jacobian matrix tag data structure ... if someone creates it
2464 : */
2465 3805684 : void clearCurrentJacobianMatrixTags() {}
2466 :
2467 7817 : virtual void needFV() override { _have_fv = true; }
2468 398355561 : virtual bool haveFV() const override { return _have_fv; }
2469 :
2470 56920459 : virtual bool hasNonlocalCoupling() const override { return _has_nonlocal_coupling; }
2471 :
2472 : /**
2473 : * Whether to identify variable groups in nonlinear systems. This affects dof ordering
2474 : */
2475 61453 : bool identifyVariableGroupsInNL() const { return _identify_variable_groups_in_nl; }
2476 :
2477 : virtual void setCurrentLowerDElem(const Elem * const lower_d_elem, const THREAD_ID tid) override;
2478 : virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid) override;
2479 :
2480 : /**
2481 : * @returns the nolinear system names in the problem
2482 : */
2483 135884 : const std::vector<NonlinearSystemName> & getNonlinearSystemNames() const { return _nl_sys_names; }
2484 : /**
2485 : * @returns the linear system names in the problem
2486 : */
2487 62187 : const std::vector<LinearSystemName> & getLinearSystemNames() const { return _linear_sys_names; }
2488 : /**
2489 : * @returns the solver system names in the problem
2490 : */
2491 498 : const std::vector<SolverSystemName> & getSolverSystemNames() const { return _solver_sys_names; }
2492 :
2493 : virtual const libMesh::CouplingMatrix & nonlocalCouplingMatrix(const unsigned i) const override;
2494 :
2495 : virtual bool checkNonlocalCouplingRequirement() const override;
2496 :
2497 109331 : virtual Moose::FEBackend feBackend() const { return Moose::FEBackend::LibMesh; }
2498 :
2499 : protected:
2500 : /**
2501 : * Deprecated. Users should switch to overriding the meshChanged which takes arguments
2502 : */
2503 6821 : virtual void meshChanged() {}
2504 :
2505 : /// Create extra tagged vectors and matrices
2506 : void createTagVectors();
2507 :
2508 : /// Create extra tagged solution vectors
2509 : void createTagSolutions();
2510 :
2511 : /**
2512 : * Update data after a mesh displaced.
2513 : */
2514 : virtual void meshDisplaced();
2515 :
2516 : /**
2517 : * Do generic system computations
2518 : */
2519 : void computeSystems(const ExecFlagType & type);
2520 :
2521 : MooseMesh & _mesh;
2522 :
2523 : private:
2524 : /// The EquationSystems object, wrapped for restart
2525 : Restartable::ManagedValue<RestartableEquationSystems> _req;
2526 :
2527 : /**
2528 : * Set the subproblem and system parameters for residual objects and log their addition
2529 : * @param ro_name The type of the residual object
2530 : * @param name The name of the residual object
2531 : * @param parameters The residual object parameters
2532 : * @param nl_sys_num The nonlinear system that the residual object belongs to
2533 : * @param base_name The base type of the residual object, e.g. Kernel, BoundaryCondition, etc.
2534 : * @param reinit_displaced A data member indicating whether a geometric concept should be reinit'd
2535 : * for the displaced problem. Examples of valid data members to pass in are \p
2536 : * _reinit_displaced_elem and \p _reinit_displaced_face
2537 : */
2538 : void setResidualObjectParamsAndLog(const std::string & ro_name,
2539 : const std::string & name,
2540 : InputParameters & params,
2541 : const unsigned int nl_sys_num,
2542 : const std::string & base_name,
2543 : bool & reinit_displaced);
2544 :
2545 : /**
2546 : * Make basic solver params for linear solves
2547 : */
2548 : static SolverParams makeLinearSolverParams();
2549 :
2550 : protected:
2551 : bool _initialized;
2552 :
2553 : /// Nonlinear system(s) convergence name(s)
2554 : std::optional<std::vector<ConvergenceName>> _nonlinear_convergence_names;
2555 : /// Linear system(s) convergence name(s) (if any)
2556 : std::optional<std::vector<ConvergenceName>> _linear_convergence_names;
2557 : /// MultiApp fixed point convergence name
2558 : std::optional<ConvergenceName> _multiapp_fixed_point_convergence_name;
2559 : /// Steady-state detection convergence name
2560 : std::optional<ConvergenceName> _steady_state_convergence_name;
2561 :
2562 : std::set<TagID> _fe_vector_tags;
2563 :
2564 : std::set<TagID> _fe_matrix_tags;
2565 :
2566 : /// Temporary storage for filtered vector tags for linear systems
2567 : std::set<TagID> _linear_vector_tags;
2568 :
2569 : /// Temporary storage for filtered matrix tags for linear systems
2570 : std::set<TagID> _linear_matrix_tags;
2571 :
2572 : /// Whether or not to actually solve the nonlinear system
2573 : const bool & _solve;
2574 :
2575 : bool _transient;
2576 : Real & _time;
2577 : Real & _time_old;
2578 : int & _t_step;
2579 : Real & _dt;
2580 : Real & _dt_old;
2581 :
2582 : /// Flag that the problem needs to add the default nonlinear convergence
2583 : bool _need_to_add_default_nonlinear_convergence;
2584 : /// Flag that the problem needs to add the default fixed point convergence
2585 : bool _need_to_add_default_multiapp_fixed_point_convergence;
2586 : /// Flag that the problem needs to add the default steady convergence
2587 : bool _need_to_add_default_steady_state_convergence;
2588 :
2589 : /// The linear system names
2590 : const std::vector<LinearSystemName> _linear_sys_names;
2591 :
2592 : /// The number of linear systems
2593 : const std::size_t _num_linear_sys;
2594 :
2595 : /// The vector of linear systems
2596 : std::vector<std::shared_ptr<LinearSystem>> _linear_systems;
2597 :
2598 : /// Map from linear system name to number
2599 : std::map<LinearSystemName, unsigned int> _linear_sys_name_to_num;
2600 :
2601 : /// The current linear system that we are solving
2602 : LinearSystem * _current_linear_sys;
2603 :
2604 : /// Boolean to check if we have the default nonlinear system
2605 : const bool _using_default_nl;
2606 :
2607 : /// The nonlinear system names
2608 : const std::vector<NonlinearSystemName> _nl_sys_names;
2609 :
2610 : /// The number of nonlinear systems
2611 : const std::size_t _num_nl_sys;
2612 :
2613 : /// The nonlinear systems
2614 : std::vector<std::shared_ptr<NonlinearSystemBase>> _nl;
2615 :
2616 : /// Map from nonlinear system name to number
2617 : std::map<NonlinearSystemName, unsigned int> _nl_sys_name_to_num;
2618 :
2619 : /// The current nonlinear system that we are solving
2620 : NonlinearSystemBase * _current_nl_sys;
2621 :
2622 : /// The current solver system
2623 : SolverSystem * _current_solver_sys;
2624 :
2625 : /// Combined container to base pointer of every solver system
2626 : std::vector<std::shared_ptr<SolverSystem>> _solver_systems;
2627 :
2628 : /// Map connecting variable names with their respective solver systems
2629 : std::map<SolverVariableName, unsigned int> _solver_var_to_sys_num;
2630 :
2631 : /// Map connecting solver system names with their respective systems
2632 : std::map<SolverSystemName, unsigned int> _solver_sys_name_to_num;
2633 :
2634 : /// The union of nonlinear and linear system names
2635 : std::vector<SolverSystemName> _solver_sys_names;
2636 :
2637 : /// The auxiliary system
2638 : std::shared_ptr<AuxiliarySystem> _aux;
2639 :
2640 : Moose::CouplingType _coupling; ///< Type of variable coupling
2641 : std::vector<std::unique_ptr<libMesh::CouplingMatrix>> _cm; ///< Coupling matrix for variables.
2642 :
2643 : /// Dimension of the subspace spanned by the vectors with a given prefix
2644 : std::map<std::string, unsigned int> _subspace_dim;
2645 :
2646 : /// The Assembly objects. The first index corresponds to the thread ID and the second index
2647 : /// corresponds to the nonlinear system number
2648 : std::vector<std::vector<std::unique_ptr<Assembly>>> _assembly;
2649 :
2650 : /// Warehouse to store mesh divisions
2651 : /// NOTE: this could probably be moved to the MooseMesh instead of the Problem
2652 : /// Time (and people's uses) will tell where this fits best
2653 : MooseObjectWarehouse<MeshDivision> _mesh_divisions;
2654 :
2655 : /// functions
2656 : MooseObjectWarehouse<Function> _functions;
2657 :
2658 : /// convergence warehouse
2659 : MooseObjectWarehouse<Convergence> _convergences;
2660 :
2661 : /// nonlocal kernels
2662 : MooseObjectWarehouse<KernelBase> _nonlocal_kernels;
2663 :
2664 : /// nonlocal integrated_bcs
2665 : MooseObjectWarehouse<IntegratedBCBase> _nonlocal_integrated_bcs;
2666 :
2667 : ///@{
2668 : /// Initial condition storage
2669 : InitialConditionWarehouse _ics;
2670 : FVInitialConditionWarehouse _fv_ics;
2671 : ScalarInitialConditionWarehouse _scalar_ics; // use base b/c of setup methods
2672 : ///@}
2673 :
2674 : // material properties
2675 : MaterialPropertyRegistry _material_prop_registry;
2676 : MaterialPropertyStorage & _material_props;
2677 : MaterialPropertyStorage & _bnd_material_props;
2678 : MaterialPropertyStorage & _neighbor_material_props;
2679 :
2680 : ///@{
2681 : // Material Warehouses
2682 : MaterialWarehouse _materials; // regular materials
2683 : MaterialWarehouse _interface_materials; // interface materials
2684 : MaterialWarehouse _discrete_materials; // Materials that the user must compute
2685 : MaterialWarehouse _all_materials; // All materials for error checking and MaterialData storage
2686 : ///@}
2687 :
2688 : ///@{
2689 : // Indicator Warehouses
2690 : MooseObjectWarehouse<Indicator> _indicators;
2691 : MooseObjectWarehouse<InternalSideIndicatorBase> _internal_side_indicators;
2692 : ///@}
2693 :
2694 : // Marker Warehouse
2695 : MooseObjectWarehouse<Marker> _markers;
2696 :
2697 : // Helper class to access Reporter object values
2698 : ReporterData _reporter_data;
2699 :
2700 : // TODO: delete this after apps have been updated to not call getUserObjects
2701 : ExecuteMooseObjectWarehouse<UserObject> _all_user_objects;
2702 :
2703 : /// MultiApp Warehouse
2704 : ExecuteMooseObjectWarehouse<MultiApp> _multi_apps;
2705 :
2706 : /// Storage for TransientMultiApps (only needed for calling 'computeDT')
2707 : ExecuteMooseObjectWarehouse<TransientMultiApp> _transient_multi_apps;
2708 :
2709 : /// Normal Transfers
2710 : ExecuteMooseObjectWarehouse<Transfer> _transfers;
2711 :
2712 : /// Transfers executed just before MultiApps to transfer data to them
2713 : ExecuteMooseObjectWarehouse<Transfer> _to_multi_app_transfers;
2714 :
2715 : /// Transfers executed just after MultiApps to transfer data from them
2716 : ExecuteMooseObjectWarehouse<Transfer> _from_multi_app_transfers;
2717 :
2718 : /// Transfers executed just before MultiApps to transfer data between them
2719 : ExecuteMooseObjectWarehouse<Transfer> _between_multi_app_transfers;
2720 :
2721 : /// A map of objects that consume random numbers
2722 : std::map<std::string, std::unique_ptr<RandomData>> _random_data_objects;
2723 :
2724 : /// Cache for calculating materials on side
2725 : std::vector<std::unordered_map<SubdomainID, bool>> _block_mat_side_cache;
2726 :
2727 : /// Cache for calculating materials on side
2728 : std::vector<std::unordered_map<BoundaryID, bool>> _bnd_mat_side_cache;
2729 :
2730 : /// Cache for calculating materials on interface
2731 : std::vector<std::unordered_map<BoundaryID, bool>> _interface_mat_side_cache;
2732 :
2733 : /// Objects to be notified when the mesh changes
2734 : std::vector<MeshChangedInterface *> _notify_when_mesh_changes;
2735 :
2736 : /// Objects to be notified when the mesh displaces
2737 : std::vector<MeshDisplacedInterface *> _notify_when_mesh_displaces;
2738 :
2739 : /// Helper to check for duplicate variable names across systems or within a single system
2740 : bool duplicateVariableCheck(const std::string & var_name,
2741 : const libMesh::FEType & type,
2742 : bool is_aux,
2743 : const std::set<SubdomainID> * const active_subdomains);
2744 :
2745 : void computeUserObjectsInternal(const ExecFlagType & type,
2746 : const Moose::AuxGroup & group,
2747 : TheWarehouse::Query & query);
2748 :
2749 : /// Verify that SECOND order mesh uses SECOND order displacements.
2750 : void checkDisplacementOrders();
2751 :
2752 : void checkUserObjects();
2753 :
2754 : /**
2755 : * Helper method for checking Material object dependency.
2756 : *
2757 : * @see checkProblemIntegrity
2758 : */
2759 : void checkDependMaterialsHelper(
2760 : const std::map<SubdomainID, std::vector<std::shared_ptr<MaterialBase>>> & materials_map);
2761 :
2762 : /// Verify that there are no element type/coordinate type conflicts
2763 : void checkCoordinateSystems();
2764 :
2765 : /**
2766 : * Call when it is possible that the needs for ghosted elements has changed.
2767 : * @param mortar_changed Whether an update of mortar data has been requested since the last
2768 : * EquationSystems (re)initialization
2769 : */
2770 : void reinitBecauseOfGhostingOrNewGeomObjects(bool mortar_changed = false);
2771 :
2772 : /**
2773 : * Helper for setting the "_subproblem" and "_sys" parameters in addObject() and
2774 : * in addUserObject().
2775 : *
2776 : * This is needed due to header includes/forward declaration issues
2777 : */
2778 : void addObjectParamsHelper(InputParameters & params,
2779 : const std::string & object_name,
2780 : const std::string & var_param_name = "variable");
2781 :
2782 : #ifdef LIBMESH_ENABLE_AMR
2783 : Adaptivity _adaptivity;
2784 : unsigned int _cycles_completed;
2785 : #endif
2786 :
2787 : /// Pointer to XFEM controller
2788 : std::shared_ptr<XFEMInterface> _xfem;
2789 :
2790 : // Displaced mesh /////
2791 : MooseMesh * _displaced_mesh;
2792 : std::shared_ptr<DisplacedProblem> _displaced_problem;
2793 : GeometricSearchData _geometric_search_data;
2794 : MortarData _mortar_data;
2795 :
2796 : /// Whether to call DisplacedProblem::reinitElem when this->reinitElem is called
2797 : bool _reinit_displaced_elem;
2798 : /// Whether to call DisplacedProblem::reinitElemFace when this->reinitElemFace is called
2799 : bool _reinit_displaced_face;
2800 : /// Whether to call DisplacedProblem::reinitNeighbor when this->reinitNeighbor is called
2801 : bool _reinit_displaced_neighbor;
2802 :
2803 : /// whether input file has been written
2804 : bool _input_file_saved;
2805 :
2806 : /// Whether or not this system has any Dampers associated with it.
2807 : bool _has_dampers;
2808 :
2809 : /// Whether or not this system has any Constraints.
2810 : bool _has_constraints;
2811 :
2812 : /// If or not to resuse the base vector for matrix-free calculation
2813 : bool _snesmf_reuse_base;
2814 :
2815 : /// If or not skip 'exception and stop solve'
2816 : bool _skip_exception_check;
2817 :
2818 : /// If or not _snesmf_reuse_base is set by user
2819 : bool _snesmf_reuse_base_set_by_user;
2820 :
2821 : /// Whether nor not stateful materials have been initialized
2822 : bool _has_initialized_stateful;
2823 :
2824 : /// true if the Jacobian is constant
2825 : bool _const_jacobian;
2826 :
2827 : /// Indicates if the Jacobian was computed
2828 : bool _has_jacobian;
2829 :
2830 : /// Indicates that we need to compute variable values for previous Newton iteration
2831 : bool _needs_old_newton_iter;
2832 :
2833 : /// Indicates we need to save the previous NL iteration variable values
2834 : bool _previous_nl_solution_required;
2835 :
2836 : /// Indicates if nonlocal coupling is required/exists
2837 : bool _has_nonlocal_coupling;
2838 : bool _calculate_jacobian_in_uo;
2839 :
2840 : std::vector<std::vector<const MooseVariableFEBase *>> _uo_jacobian_moose_vars;
2841 :
2842 : /// Whether there are active material properties on each thread
2843 : std::vector<unsigned char> _has_active_material_properties;
2844 :
2845 : std::vector<SolverParams> _solver_params;
2846 :
2847 : /// Determines whether and which subdomains are to be checked to ensure that they have an active kernel
2848 : CoverageCheckMode _kernel_coverage_check;
2849 : std::vector<SubdomainName> _kernel_coverage_blocks;
2850 :
2851 : /// whether to perform checking of boundary restricted nodal object variable dependencies,
2852 : /// e.g. whether the variable dependencies are defined on the selected boundaries
2853 : const bool _boundary_restricted_node_integrity_check;
2854 :
2855 : /// whether to perform checking of boundary restricted elemental object variable dependencies,
2856 : /// e.g. whether the variable dependencies are defined on the selected boundaries
2857 : const bool _boundary_restricted_elem_integrity_check;
2858 :
2859 : /// Determines whether and which subdomains are to be checked to ensure that they have an active material
2860 : CoverageCheckMode _material_coverage_check;
2861 : std::vector<SubdomainName> _material_coverage_blocks;
2862 :
2863 : /// Whether to check overlapping Dirichlet and Flux BCs and/or multiple DirichletBCs per sideset
2864 : bool _fv_bcs_integrity_check;
2865 :
2866 : /// Determines whether a check to verify material dependencies on every subdomain
2867 : const bool _material_dependency_check;
2868 :
2869 : /// Whether or not checking the state of uo/aux evaluation
2870 : const bool _uo_aux_state_check;
2871 :
2872 : /// Maximum number of quadrature points used in the problem
2873 : unsigned int _max_qps;
2874 :
2875 : /// Maximum scalar variable order
2876 : libMesh::Order _max_scalar_order;
2877 :
2878 : /// Indicates whether or not this executioner has a time integrator (during setup)
2879 : bool _has_time_integrator;
2880 :
2881 : /// Whether or not an exception has occurred
2882 : bool _has_exception;
2883 :
2884 : /// Whether or not information about how many transfers have completed is printed
2885 : bool _parallel_barrier_messaging;
2886 :
2887 : /// Whether or not to be verbose during setup
2888 : MooseEnum _verbose_setup;
2889 :
2890 : /// Whether or not to be verbose with multiapps
2891 : bool _verbose_multiapps;
2892 :
2893 : /// Whether or not to be verbose on solution restoration post a failed time step
2894 : bool _verbose_restore;
2895 :
2896 : /// The error message to go with an exception
2897 : std::string _exception_message;
2898 :
2899 : /// Current execute_on flag
2900 : ExecFlagType _current_execute_on_flag;
2901 :
2902 : /// The control logic warehouse
2903 : ExecuteMooseObjectWarehouse<Control> _control_warehouse;
2904 :
2905 : /// PETSc option storage
2906 : Moose::PetscSupport::PetscOptions _petsc_options;
2907 : #if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
2908 : PetscOptions _petsc_option_data_base;
2909 : #endif
2910 :
2911 : /// If or not PETSc options have been added to database
2912 : bool _is_petsc_options_inserted;
2913 :
2914 : std::shared_ptr<LineSearch> _line_search;
2915 :
2916 : std::unique_ptr<libMesh::ConstElemRange> _evaluable_local_elem_range;
2917 : std::unique_ptr<libMesh::ConstElemRange> _nl_evaluable_local_elem_range;
2918 : std::unique_ptr<libMesh::ConstElemRange> _aux_evaluable_local_elem_range;
2919 :
2920 : std::unique_ptr<libMesh::ConstElemRange> _current_algebraic_elem_range;
2921 : std::unique_ptr<libMesh::ConstNodeRange> _current_algebraic_node_range;
2922 : std::unique_ptr<ConstBndNodeRange> _current_algebraic_bnd_node_range;
2923 :
2924 : /// Automatic differentiaion (AD) flag which indicates whether any consumer has
2925 : /// requested an AD material property or whether any suppier has declared an AD material property
2926 : bool _using_ad_mat_props;
2927 :
2928 : // loop state during projection of initial conditions
2929 : unsigned short _current_ic_state;
2930 :
2931 : /// Whether to assemble matrices using hash tables instead of preallocating matrix memory. This
2932 : /// can be a good option if the sparsity pattern changes throughout the course of the simulation
2933 : const bool _use_hash_table_matrix_assembly;
2934 :
2935 : private:
2936 : /**
2937 : * Handle exceptions. Note that the result of this call will be a thrown MooseException. The
2938 : * caller of this method must determine how to handle the thrown exception
2939 : */
2940 : void handleException(const std::string & calling_method);
2941 :
2942 : /**
2943 : * Helper for getting mortar objects corresponding to primary boundary ID, secondary boundary ID,
2944 : * and displaced parameters, given some initial set
2945 : */
2946 : std::vector<MortarUserObject *>
2947 : getMortarUserObjects(BoundaryID primary_boundary_id,
2948 : BoundaryID secondary_boundary_id,
2949 : bool displaced,
2950 : const std::vector<MortarUserObject *> & mortar_uo_superset);
2951 :
2952 : /**
2953 : * Helper for getting mortar objects corresponding to primary boundary ID, secondary boundary ID,
2954 : * and displaced parameters from the entire active mortar user object set
2955 : */
2956 : std::vector<MortarUserObject *> getMortarUserObjects(BoundaryID primary_boundary_id,
2957 : BoundaryID secondary_boundary_id,
2958 : bool displaced);
2959 :
2960 : /**
2961 : * Determine what solver system the provided variable name lies in
2962 : * @param var_name The name of the variable we are doing solver system lookups for
2963 : * @param error_if_not_found Whether to error if the variable name isn't found in any of the
2964 : * solver systems
2965 : * @return A pair in which the first member indicates whether the variable was found in the
2966 : * solver systems and the second member indicates the solver system number in which the
2967 : * variable was found (or an invalid unsigned integer if not found)
2968 : */
2969 : virtual std::pair<bool, unsigned int>
2970 : determineSolverSystem(const std::string & var_name,
2971 : bool error_if_not_found = false) const override;
2972 :
2973 : /**
2974 : * Checks if the variable of the initial condition is getting restarted and errors for specific
2975 : * cases
2976 : * @param ic_name The name of the initial condition
2977 : * @param var_name The name of the variable
2978 : */
2979 : void checkICRestartError(const std::string & ic_name,
2980 : const std::string & name,
2981 : const VariableName & var_name);
2982 :
2983 : /*
2984 : * Test if stateful property redistribution is expected to be
2985 : * necessary, and set it up if so.
2986 : */
2987 : void addAnyRedistributers();
2988 :
2989 : void updateMaxQps();
2990 :
2991 : void joinAndFinalize(TheWarehouse::Query query, bool isgen = false);
2992 :
2993 : /**
2994 : * Reset state of this object in preparation for the next evaluation.
2995 : */
2996 : virtual void resetState();
2997 :
2998 : // Parameters handling Jacobian sparsity pattern behavior
2999 : /// Whether to error when the Jacobian is re-allocated, usually because the sparsity pattern changed
3000 : bool _error_on_jacobian_nonzero_reallocation;
3001 : /// Whether we should restore the original nonzero pattern for every Jacobian evaluation. This
3002 : /// option is useful if the sparsity pattern is constantly changing and you are using hash table
3003 : /// assembly or if you wish to continually restore the matrix to the originally preallocated
3004 : /// sparsity pattern computed by relationship managers.
3005 : const bool _restore_original_nonzero_pattern;
3006 : /// Whether to ignore zeros in the Jacobian, thereby leading to a reduced sparsity pattern
3007 : bool _ignore_zeros_in_jacobian;
3008 : /// Whether to preserve the system matrix / Jacobian sparsity pattern, using 0-valued entries usually
3009 : bool _preserve_matrix_sparsity_pattern;
3010 :
3011 : const bool _force_restart;
3012 : const bool _allow_ics_during_restart;
3013 : const bool _skip_nl_system_check;
3014 : bool _fail_next_system_convergence_check;
3015 : const bool _allow_invalid_solution;
3016 : const bool _show_invalid_solution_console;
3017 : const bool & _immediately_print_invalid_solution;
3018 :
3019 : /// At or beyond initialSteup stage
3020 : bool _started_initial_setup;
3021 :
3022 : /// Whether the problem has dgkernels or interface kernels
3023 : bool _has_internal_edge_residual_objects;
3024 :
3025 : /// Whether solution time derivative needs to be stored
3026 : bool _u_dot_requested;
3027 :
3028 : /// Whether solution second time derivative needs to be stored
3029 : bool _u_dotdot_requested;
3030 :
3031 : /// Whether old solution time derivative needs to be stored
3032 : bool _u_dot_old_requested;
3033 :
3034 : /// Whether old solution second time derivative needs to be stored
3035 : bool _u_dotdot_old_requested;
3036 :
3037 : friend class AuxiliarySystem;
3038 : friend class NonlinearSystemBase;
3039 : friend class MooseEigenSystem;
3040 : friend class Resurrector;
3041 : friend class Restartable;
3042 : friend class DisplacedProblem;
3043 :
3044 : /// Whether the simulation requires mortar coupling
3045 : bool _has_mortar;
3046 :
3047 : /// Number of steps in a grid sequence
3048 : unsigned int _num_grid_steps;
3049 :
3050 : /// Whether to trust the user coupling matrix no matter what. See
3051 : /// https://github.com/idaholab/moose/issues/16395 for detailed background
3052 : bool _trust_user_coupling_matrix = false;
3053 :
3054 : /// Flag used to indicate whether we are computing the scaling Jacobian
3055 : bool _computing_scaling_jacobian = false;
3056 :
3057 : /// Flag used to indicate whether we are computing the scaling Residual
3058 : bool _computing_scaling_residual = false;
3059 :
3060 : /// Flag used to indicate whether we are doing the uo/aux state check in execute
3061 : bool _checking_uo_aux_state = false;
3062 :
3063 : /// When to print the execution of loops
3064 : ExecFlagEnum _print_execution_on;
3065 :
3066 : /// Whether to identify variable groups in nonlinear systems. This affects dof ordering
3067 : const bool _identify_variable_groups_in_nl;
3068 :
3069 : /// A data member to store the residual vector tag(s) passed into \p computeResidualTag(s). This
3070 : /// data member will be used when APIs like \p cacheResidual, \p addCachedResiduals, etc. are
3071 : /// called
3072 : std::vector<VectorTag> _current_residual_vector_tags;
3073 :
3074 : /// Whether we are performing some calculations with finite volume discretizations
3075 : bool _have_fv = false;
3076 :
3077 : /// If we catch an exception during residual/Jacobian evaluaton for which we don't have specific
3078 : /// handling, immediately error instead of allowing the time step to be cut
3079 : const bool _regard_general_exceptions_as_errors;
3080 :
3081 : /// nonlocal coupling matrix
3082 : std::vector<libMesh::CouplingMatrix> _nonlocal_cm;
3083 :
3084 : /// nonlocal coupling requirement flag
3085 : bool _requires_nonlocal_coupling;
3086 :
3087 : friend void Moose::PetscSupport::setSinglePetscOption(const std::string & name,
3088 : const std::string & value,
3089 : FEProblemBase * const problem);
3090 : };
3091 :
3092 : using FVProblemBase = FEProblemBase;
3093 :
3094 : template <typename T>
3095 : void
3096 1734 : FEProblemBase::allowOutput(bool state)
3097 : {
3098 1734 : _app.getOutputWarehouse().allowOutput<T>(state);
3099 1734 : }
3100 :
3101 : template <typename T>
3102 : void
3103 55 : FEProblemBase::objectSetupHelper(const std::vector<T *> & objects, const ExecFlagType & exec_flag)
3104 : {
3105 55 : if (exec_flag == EXEC_INITIAL)
3106 : {
3107 0 : for (T * obj_ptr : objects)
3108 0 : obj_ptr->initialSetup();
3109 : }
3110 :
3111 55 : else if (exec_flag == EXEC_TIMESTEP_BEGIN)
3112 : {
3113 0 : for (const auto obj_ptr : objects)
3114 0 : obj_ptr->timestepSetup();
3115 : }
3116 55 : else if (exec_flag == EXEC_SUBDOMAIN)
3117 : {
3118 0 : for (const auto obj_ptr : objects)
3119 0 : obj_ptr->subdomainSetup();
3120 : }
3121 :
3122 55 : else if (exec_flag == EXEC_NONLINEAR)
3123 : {
3124 0 : for (const auto obj_ptr : objects)
3125 0 : obj_ptr->jacobianSetup();
3126 : }
3127 :
3128 55 : else if (exec_flag == EXEC_LINEAR)
3129 : {
3130 0 : for (const auto obj_ptr : objects)
3131 0 : obj_ptr->residualSetup();
3132 : }
3133 55 : }
3134 :
3135 : template <typename T>
3136 : void
3137 55 : FEProblemBase::objectExecuteHelper(const std::vector<T *> & objects)
3138 : {
3139 78 : for (T * obj_ptr : objects)
3140 55 : obj_ptr->execute();
3141 23 : }
3142 :
3143 : template <typename T>
3144 : std::vector<std::shared_ptr<T>>
3145 53935 : FEProblemBase::addObject(const std::string & type,
3146 : const std::string & name,
3147 : InputParameters & parameters,
3148 : const bool threaded,
3149 : const std::string & var_param_name)
3150 : {
3151 : parallel_object_only();
3152 :
3153 53935 : logAdd(MooseUtils::prettyCppType<T>(), name, type, parameters);
3154 : // Add the _subproblem and _sys parameters depending on use_displaced_mesh
3155 53935 : addObjectParamsHelper(parameters, name, var_param_name);
3156 :
3157 53935 : const auto n_threads = threaded ? libMesh::n_threads() : 1;
3158 53935 : std::vector<std::shared_ptr<T>> objects(n_threads);
3159 108718 : for (THREAD_ID tid = 0; tid < n_threads; ++tid)
3160 : {
3161 54827 : std::shared_ptr<T> obj = _factory.create<T>(type, name, parameters, tid);
3162 54783 : theWarehouse().add(obj);
3163 54783 : objects[tid] = std::move(obj);
3164 : }
3165 :
3166 53891 : return objects;
3167 0 : }
3168 :
3169 : inline NonlinearSystemBase &
3170 6534461 : FEProblemBase::getNonlinearSystemBase(const unsigned int sys_num)
3171 : {
3172 : mooseAssert(sys_num < _nl.size(), "System number greater than the number of nonlinear systems");
3173 6534461 : return *_nl[sys_num];
3174 : }
3175 :
3176 : inline const NonlinearSystemBase &
3177 581 : FEProblemBase::getNonlinearSystemBase(const unsigned int sys_num) const
3178 : {
3179 : mooseAssert(sys_num < _nl.size(), "System number greater than the number of nonlinear systems");
3180 581 : return *_nl[sys_num];
3181 : }
3182 :
3183 : inline SolverSystem &
3184 4472779 : FEProblemBase::getSolverSystem(const unsigned int sys_num)
3185 : {
3186 : mooseAssert(sys_num < _solver_systems.size(),
3187 : "System number greater than the number of solver systems");
3188 4472779 : return *_solver_systems[sys_num];
3189 : }
3190 :
3191 : inline const SolverSystem &
3192 : FEProblemBase::getSolverSystem(const unsigned int sys_num) const
3193 : {
3194 : mooseAssert(sys_num < _solver_systems.size(),
3195 : "System number greater than the number of solver systems");
3196 : return *_solver_systems[sys_num];
3197 : }
3198 :
3199 : inline NonlinearSystemBase &
3200 9766653 : FEProblemBase::currentNonlinearSystem()
3201 : {
3202 : mooseAssert(_current_nl_sys, "The nonlinear system is not currently set");
3203 9766653 : return *_current_nl_sys;
3204 : }
3205 :
3206 : inline const NonlinearSystemBase &
3207 591367551 : FEProblemBase::currentNonlinearSystem() const
3208 : {
3209 : mooseAssert(_current_nl_sys, "The nonlinear system is not currently set");
3210 591367551 : return *_current_nl_sys;
3211 : }
3212 :
3213 : inline LinearSystem &
3214 72173 : FEProblemBase::getLinearSystem(const unsigned int sys_num)
3215 : {
3216 : mooseAssert(sys_num < _linear_systems.size(),
3217 : "System number greater than the number of linear systems");
3218 72173 : return *_linear_systems[sys_num];
3219 : }
3220 :
3221 : inline const LinearSystem &
3222 : FEProblemBase::getLinearSystem(const unsigned int sys_num) const
3223 : {
3224 : mooseAssert(sys_num < _linear_systems.size(),
3225 : "System number greater than the number of linear systems");
3226 : return *_linear_systems[sys_num];
3227 : }
3228 :
3229 : inline LinearSystem &
3230 2634 : FEProblemBase::currentLinearSystem()
3231 : {
3232 : mooseAssert(_current_linear_sys, "The linear system is not currently set");
3233 2634 : return *_current_linear_sys;
3234 : }
3235 :
3236 : inline const LinearSystem &
3237 0 : FEProblemBase::currentLinearSystem() const
3238 : {
3239 : mooseAssert(_current_linear_sys, "The linear system is not currently set");
3240 0 : return *_current_linear_sys;
3241 : }
3242 :
3243 : inline Assembly &
3244 753531456 : FEProblemBase::assembly(const THREAD_ID tid, const unsigned int sys_num)
3245 : {
3246 : mooseAssert(tid < _assembly.size(), "Assembly objects not initialized");
3247 : mooseAssert(sys_num < _assembly[tid].size(),
3248 : "System number larger than the assembly container size");
3249 753531456 : return *_assembly[tid][sys_num];
3250 : }
3251 :
3252 : inline const Assembly &
3253 541098 : FEProblemBase::assembly(const THREAD_ID tid, const unsigned int sys_num) const
3254 : {
3255 : mooseAssert(tid < _assembly.size(), "Assembly objects not initialized");
3256 : mooseAssert(sys_num < _assembly[tid].size(),
3257 : "System number larger than the assembly container size");
3258 541098 : return *_assembly[tid][sys_num];
3259 : }
3260 :
3261 : inline const libMesh::CouplingMatrix *
3262 2952 : FEProblemBase::couplingMatrix(const unsigned int i) const
3263 : {
3264 2952 : return _cm[i].get();
3265 : }
3266 :
3267 : inline void
3268 : FEProblemBase::fvBCsIntegrityCheck(const bool fv_bcs_integrity_check)
3269 : {
3270 : if (!_fv_bcs_integrity_check)
3271 : // the user has requested that we don't check integrity so we will honor that
3272 : return;
3273 :
3274 : _fv_bcs_integrity_check = fv_bcs_integrity_check;
3275 : }
3276 :
3277 : inline const std::vector<VectorTag> &
3278 475086132 : FEProblemBase::currentResidualVectorTags() const
3279 : {
3280 475086132 : return _current_residual_vector_tags;
3281 : }
3282 :
3283 : inline void
3284 3281482 : FEProblemBase::setCurrentResidualVectorTags(const std::set<TagID> & vector_tags)
3285 : {
3286 3281482 : _current_residual_vector_tags = getVectorTags(vector_tags);
3287 3281482 : }
3288 :
3289 : inline void
3290 3805815 : FEProblemBase::clearCurrentResidualVectorTags()
3291 : {
3292 3805815 : _current_residual_vector_tags.clear();
3293 3805815 : }
|