www.mooseframework.org
CrankNicolson.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 #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(DualReal & ad_u_dot,
33  const dof_id_type & dof,
34  DualReal & ad_u_dotdot) const override;
35  virtual void postResidual(NumericVector<Number> & residual) override;
36  virtual void postStep() override;
37 
38 protected:
42  template <typename T, typename T2>
43  void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const;
44 
46 };
47 
48 template <typename T, typename T2>
49 void
50 CrankNicolson::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const
51 {
52  u_dot -= u_old;
53  u_dot *= 2. / _dt;
54 }
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the TimeIntegrator called immediately after the residuals are computed in NonlinearSystem...
Definition: CrankNicolson.C:77
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:50
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:53
DualNumber< Real, DNDerivativeType, true > DualReal
Definition: DualReal.h:49
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void postStep() override
Callback to the TimeIntegrator called at the very end of time step.
virtual int order() override
Definition: CrankNicolson.h:30
NumericVector< Number > & _residual_old
Definition: CrankNicolson.h:45
void computeADTimeDerivatives(DualReal &ad_u_dot, const dof_id_type &dof, DualReal &ad_u_dotdot) const override
method for computing local automatic differentiation time derivatives
Definition: CrankNicolson.C:45
CrankNicolson(const InputParameters &parameters)
Definition: CrankNicolson.C:24
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
uint8_t dof_id_type