www.mooseframework.org
TimeIntegrator.C
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 #include "libmesh/nonlinear_implicit_system.h"
11 #include "libmesh/petsc_nonlinear_solver.h"
12 
13 #include "TimeIntegrator.h"
14 #include "FEProblem.h"
15 #include "SystemBase.h"
16 #include "NonlinearSystem.h"
17 
18 template <>
21 {
23  params.registerBase("TimeIntegrator");
24  return params;
25 }
26 
28  : MooseObject(parameters),
29  Restartable(this, "TimeIntegrators"),
30  _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
31  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
32  _nl(_fe_problem.getNonlinearSystemBase()),
33  _nonlinear_implicit_system(dynamic_cast<const NonlinearImplicitSystem *>(&_sys.system())),
34  _du_dot_du(_sys.duDotDu()),
35  _solution(_sys.currentSolution()),
36  _solution_old(_sys.solutionOld()),
37  _solution_older(_sys.solutionOlder()),
38  _t_step(_fe_problem.timeStep()),
39  _dt(_fe_problem.dt()),
40  _dt_old(_fe_problem.dtOld()),
41  _Re_time(_nl.getResidualTimeVector()),
42  _Re_non_time(_nl.getResidualNonTimeVector()),
43  _n_nonlinear_iterations(0),
44  _n_linear_iterations(0)
45 {
47 }
48 
49 void
51 {
52  _nl.system().solve();
53 
56 }
57 
58 unsigned int
60 {
61  return _nonlinear_implicit_system->n_nonlinear_iterations();
62 }
63 
64 unsigned int
66 {
67  NonlinearSolver<Real> & nonlinear_solver =
68  static_cast<NonlinearSolver<Real> &>(*_nonlinear_implicit_system->nonlinear_solver);
69 
70  return nonlinear_solver.get_total_linear_iterations();
71 }
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
InputParameters validParams< TimeIntegrator >()
FEProblemBase & _fe_problem
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for a system (of equations)
Definition: SystemBase.h:92
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
nl system()
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
virtual void setUDotRequested(const bool u_dot_requested)
Set boolean flag to true to store solution time derivative.
unsigned int _n_linear_iterations
Total number of linear iterations over all stages of the time step.
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:25
unsigned int getNumLinearIterationsLastSolve() const
Gets the number of linear iterations in the most recent solve.
virtual System & system() override
Get the reference to the libMesh system.
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)
const NonlinearImplicitSystem * _nonlinear_implicit_system
Nonlinear implicit system, if applicable; otherwise, nullptr.