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