www.mooseframework.org
TimeIntegrator.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "MooseObject.h"
14 #include "Restartable.h"
15 
16 // Forward declarations
17 class TimeIntegrator;
18 class FEProblemBase;
19 class SystemBase;
21 
22 namespace libMesh
23 {
24 template <typename T>
25 class NumericVector;
26 class NonlinearImplicitSystem;
27 } // namespace libMesh
28 
29 template <>
31 
43 class TimeIntegrator : public MooseObject, public Restartable
44 {
45 public:
47 
60  virtual void initialSetup() {}
61 
66  virtual void init() {}
67  virtual void preSolve() {}
68  virtual void preStep() {}
69 
73  virtual void solve();
74 
83  virtual void postResidual(NumericVector<Number> & /*residual*/) {}
84 
92  virtual void postSolve() {}
93 
97  virtual void postStep() {}
98 
99  virtual int order() = 0;
100  virtual void computeTimeDerivatives() = 0;
101 
105  virtual void computeADTimeDerivatives(DualReal & ad_u_dot, const dof_id_type & dof) const = 0;
106 
110  virtual unsigned int getNumNonlinearIterations() const { return _n_nonlinear_iterations; }
111 
115  virtual unsigned int getNumLinearIterations() const { return _n_linear_iterations; }
116 
117 protected:
121  unsigned int getNumNonlinearIterationsLastSolve() const;
122 
126  unsigned int getNumLinearIterationsLastSolve() const;
127 
131 
133  const NonlinearImplicitSystem * _nonlinear_implicit_system;
134 
136  Real & _du_dot_du;
138  const NumericVector<Number> * const & _solution;
139  const NumericVector<Number> & _solution_old;
140  const NumericVector<Number> & _solution_older;
141  //
142  int & _t_step;
143  //
144  Real & _dt;
145  Real & _dt_old;
146 
148  NumericVector<Number> & _Re_time;
150  NumericVector<Number> & _Re_non_time;
151 
155  unsigned int _n_linear_iterations;
156 };
157 
NonlinearSystemBase & _nl
virtual void solve()
Solves the time step and sets the number of nonlinear and linear iterations.
A class for creating restricted objects.
Definition: Restartable.h:29
virtual void preSolve()
virtual void postStep()
Callback to the TimeIntegrator called at the very end of time step.
FEProblemBase & _fe_problem
virtual void computeADTimeDerivatives(DualReal &ad_u_dot, const dof_id_type &dof) const =0
method for computing local automatic differentiation time derivatives
NumericVector< Number > & _Re_non_time
residual vector for non-time contributions
SystemBase & _sys
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DualNumber< Real, NumberArray< AD_MAX_DOFS_PER_ELEM, Real > > DualReal
Definition: DualReal.h:29
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
Definition: SystemBase.h:92
virtual void init()
Called only before the very first timestep (t_step = 0) Never called again (not even during recover/r...
virtual unsigned int getNumNonlinearIterations() const
Gets the total number of nonlinear iterations over all stages of the time step.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Nonlinear system to be solved.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
virtual unsigned int getNumLinearIterations() const
Gets the total number of linear iterations over all stages of the time step.
InputParameters validParams< TimeIntegrator >()
virtual void postResidual(NumericVector< Number > &)
Callback to the TimeIntegrator called immediately after the residuals are computed in NonlinearSystem...
unsigned int _n_linear_iterations
Total number of linear iterations over all stages of the time step.
virtual int order()=0
virtual void preStep()
virtual void initialSetup()
Called to setup datastructures.
const NumericVector< Number > & _solution_older
Real & _du_dot_du
solution vector for
const NumericVector< Number > *const & _solution
solution vectors
Base class for time integrators.
unsigned int getNumLinearIterationsLastSolve() const
Gets the number of linear iterations in the most recent solve.
virtual void postSolve()
Callback to the TimeIntegrator called immediately after TimeIntegrator::solve() (so the name does mak...
NumericVector< Number > & _Re_time
residual vector for time contributions
const NumericVector< Number > & _solution_old
unsigned int _n_nonlinear_iterations
Total number of nonlinear iterations over all stages of the time step.
unsigned int getNumNonlinearIterationsLastSolve() const
Gets the number of nonlinear iterations in the most recent solve.
TimeIntegrator(const InputParameters &parameters)
virtual void computeTimeDerivatives()=0
const NonlinearImplicitSystem * _nonlinear_implicit_system
Nonlinear implicit system, if applicable; otherwise, nullptr.