https://mooseframework.inl.gov
CrankNicolson.h
Go to the documentation of this file.
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 #include "TimeIntegrator.h"
13 
23 {
24 public:
26 
28 
29  virtual void init() override;
30  virtual int order() override { return 2; }
31  virtual void computeTimeDerivatives() override;
32  void computeADTimeDerivatives(ADReal & ad_u_dot,
33  const dof_id_type & dof,
34  ADReal & ad_u_dotdot) const override;
35  virtual void postResidual(NumericVector<Number> & residual) override;
36  virtual void postStep() override;
37  virtual bool overridesSolve() const override { return false; }
38 
39 protected:
43  template <typename T, typename T2>
44  void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const;
45 
46  virtual Real duDotDuCoeff() const override;
47 
49 };
50 
51 template <typename T, typename T2>
52 void
53 CrankNicolson::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const
54 {
55  u_dot -= u_old;
56  u_dot *= 2. / _dt;
57 }
NumericVector< Number > * _residual_old
Definition: CrankNicolson.h:48
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the NonLinearTimeIntegratorInterface called immediately after the residuals are computed ...
Definition: CrankNicolson.C:98
void computeTimeDerivativeHelper(T &u_dot, const T2 &u_old) const
Helper function that actually does the math for computing the time derivative.
Definition: CrankNicolson.h:53
virtual void init() override
Called only before the very first timestep (t_step = 0) Never called again (not even during recover/r...
Definition: CrankNicolson.C:68
virtual Real duDotDuCoeff() const override
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual bool overridesSolve() const override
Definition: CrankNicolson.h:37
virtual void postStep() override
Callback to the TimeIntegrator called at the very end of time step.
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
Real & _dt
The current time step size.
virtual int order() override
Definition: CrankNicolson.h:30
CrankNicolson(const InputParameters &parameters)
Definition: CrankNicolson.C:24
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for time integrators.
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
Definition: CrankNicolson.C:17
virtual void computeTimeDerivatives() override
Computes the time derivative and the Jacobian of the time derivative.
Definition: CrankNicolson.C:30
Crank-Nicolson time integrator.
Definition: CrankNicolson.h:22
void computeADTimeDerivatives(ADReal &ad_u_dot, const dof_id_type &dof, ADReal &ad_u_dotdot) const override
method for computing local automatic differentiation time derivatives
Definition: CrankNicolson.C:60
uint8_t dof_id_type