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 
14 class CrankNicolson;
15 
16 template <>
18 
28 {
29 public:
31 
32  virtual void init() override;
33  virtual int order() override { return 2; }
34  virtual void computeTimeDerivatives() override;
35  void computeADTimeDerivatives(DualReal & ad_u_dot, const dof_id_type & dof) const override;
36  virtual void postResidual(NumericVector<Number> & residual) override;
37  virtual void postStep() override;
38 
39 protected:
43  template <typename T, typename T2>
44  void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const;
45 
46  NumericVector<Number> & _residual_old;
47 };
48 
49 template <typename T, typename T2>
50 void
51 CrankNicolson::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const
52 {
53  u_dot -= u_old;
54  u_dot *= 2. / _dt;
55 }
56 
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the TimeIntegrator called immediately after the residuals are computed in NonlinearSystem...
Definition: CrankNicolson.C:74
InputParameters validParams< CrankNicolson >()
Definition: CrankNicolson.C:18
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:51
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:52
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
virtual void postStep() override
Callback to the TimeIntegrator called at the very end of time step.
Definition: CrankNicolson.C:82
virtual int order() override
Definition: CrankNicolson.h:33
NumericVector< Number > & _residual_old
Definition: CrankNicolson.h:46
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
void computeADTimeDerivatives(DualReal &ad_u_dot, const dof_id_type &dof) const override
method for computing local automatic differentiation time derivatives
Definition: CrankNicolson.C:46
CrankNicolson(const InputParameters &parameters)
Definition: CrankNicolson.C:25
Base class for time integrators.
virtual void computeTimeDerivatives() override
Definition: CrankNicolson.C:31
Crank-Nicolson time integrator.
Definition: CrankNicolson.h:27