23 #include "libmesh/enum_convergence_flags.h" 32 MooseEnum solve_type(
"consistent lumped lump_preconditioned",
"consistent");
37 "The way to solve the system. A 'consistent' solve uses the full mass matrix and actually " 38 "needs to use a linear solver to solve the problem. 'lumped' uses a lumped mass matrix with " 39 "a simple inversion - incredibly fast but may be less accurate. 'lump_preconditioned' uses " 40 "the lumped mass matrix as a preconditioner for the 'consistent' solve");
49 _solve_type(getParam<
MooseEnum>(
"solve_type")),
50 _explicit_residual(addVector(
"explicit_residual", false,
PARALLEL)),
51 _solution_update(addVector(
"solution_update", true,
PARALLEL)),
52 _mass_matrix_diag_inverted(addVector(
"mass_matrix_diag_inverted", true,
GHOSTED))
74 std::unordered_set<unsigned int> vars_to_check;
76 vars_to_check =
_vars;
79 vars_to_check.insert(i);
82 std::set<TagID> matrix_tags = {mass_matrix_tag_id};
85 .template condition<AttribMatrixTags>(matrix_tags)
86 .
template condition<AttribSysNum>(
_nl->
number());
88 for (
const auto var_id : vars_to_check)
94 var_name <<
" should be either a field or scalar variable");
100 std::vector<FVElementalKernel *> fv_elemental_kernels;
101 auto var_query = fv_object_starting_query.clone().template condition<AttribVar>(var_id);
102 auto var_query_clone = var_query.clone();
103 var_query.template condition<AttribSystem>(
"FVElementalKernel")
104 .queryInto(fv_elemental_kernels);
105 if (fv_elemental_kernels.size())
108 std::vector<FVFluxKernel *> fv_flux_kernels;
109 var_query_clone.template condition<AttribSystem>(
"FVFluxKernel")
110 .queryInto(fv_flux_kernels);
111 if (fv_flux_kernels.size())
136 mooseError(
"No objects contributing to the mass matrix were found for variable '",
138 "'. Did you, e.g., forget a time derivative term?");
148 "The chosen time integrator requires 'solve_type = LINEAR' in the Executioner block.");
168 _preconditioner = std::make_unique<LumpedPreconditioner>(*_mass_matrix_diag_inverted);
180 bool converged =
false;
205 converged = std::isfinite(sum);
222 mooseError(
"Unknown solve_type in ExplicitTimeIntegrator.");
233 const auto num_its_and_final_tol =
237 es.parameters.get<
Real>(
"linear solver tolerance"),
238 es.parameters.get<
unsigned int>(
"linear solver maximum iterations"));
277 mooseError(
"Unknown convergence reason in ExplicitTimeIntegrator.");
bool checkLinearConvergence()
Check for the linear solver convergence.
NumericVector< Real > * _solution_update
Solution vector for the linear solve.
void setLinearSolverDefaults(FEProblemBase &problem, libMesh::LinearSolver< T > &linear_solver)
Set the defaults for a libMesh LinearSolver.
NumericVector< Real > * _ones
Vector of 1's to help with creating the lumped mass matrix.
virtual void initialSetup() override
Called to setup datastructures.
void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
std::unordered_set< unsigned int > & _vars
The variables that this time integrator integrates.
FEProblemBase & _fe_problem
Reference to the problem.
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse()
Access functions to Warehouses from outside NonlinearSystemBase.
NonlinearSystemBase * _nl
Pointer to the nonlinear system, can happen that we dont have any.
TagID _Ke_time_tag
For computing the mass matrix.
const Parallel::Communicator & comm() const
Solving a linear problem.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
MooseEnum _solve_type
Solve type for how mass matrix is handled.
const MooseObjectTagWarehouse< ScalarKernelBase > & getScalarKernelWarehouse() const
static InputParameters validParams()
virtual unsigned int nVariables() const
Get the number of variables in this system.
const std::string _type
The type of this class.
CONVERGED_HAPPY_BREAKDOWN
Interface for notifications that the mesh has changed.
std::unique_ptr< libMesh::LinearSolver< Number > > _linear_solver
For solving with the consistent matrix.
TheWarehouse & theWarehouse() const
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
NumericVector< Real > * _explicit_residual
Residual used for the RHS.
virtual void preSolve() override
virtual libMesh::EquationSystems & es() override
unsigned int _n_linear_iterations
Total number of linear iterations over all stages of the time step.
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
const std::string & variable_name(const unsigned int i) const
virtual bool performExplicitSolve(SparseMatrix< Number > &mass_matrix)
Solves a linear system using the chosen solve type.
unsigned int number() const
Gets the number of this system.
std::unique_ptr< LumpedPreconditioner > _preconditioner
For solving with lumped preconditioning.
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
void dontAddCommonSNESOptions(FEProblemBase &fe_problem)
Function to ensure that common SNES options are not added to the PetscOptions storage object to be la...
NumericVector< Real > * _mass_matrix_diag_inverted
Diagonal of the lumped mass matrix (and its inversion)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for time integrators.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
virtual void init() override
Called only before the very first timestep (t_step = 0) Never called again (not even during recover/r...
IntRange< T > make_range(T beg, T end)
virtual TagID massMatrixTagID() const
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.
bool hasVariableObjects(unsigned int variable_id, THREAD_ID tid=0) const
Checks for whether this warehouse has objects for a given variable.
virtual void meshChanged() override
Called on this object when the mesh changes.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
const MooseObjectTagWarehouse< NodalKernelBase > & getNodalKernelWarehouse() const
MooseObjectTagWarehouse< DGKernelBase > & getDGKernelWarehouse()
NumericVector< Number > * addVector(const std::string &name, const bool project, const libMesh::ParallelType type)
Wrapper around vector addition for nonlinear time integrators.
virtual bool hasScalarVariable(const std::string &var_name) const
bool solveLinearSystem(SparseMatrix< Number > &mass_matrix)
Solves a linear system.
static InputParameters validParams()
ExplicitTimeIntegrator(const InputParameters ¶meters)
virtual libMesh::System & system() override
Get the reference to the libMesh system.