https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
24public:
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
39protected:
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
48 NumericVector<Number> * _residual_old;
49};
50
51template <typename T, typename T2>
52void
53CrankNicolson::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const
54{
55 u_dot -= u_old;
56 u_dot *= 2. / _dt;
57}
DualNumber< Real, DNDerivativeType, true > ADReal
Crank-Nicolson time integrator.
virtual void computeTimeDerivatives() override
Computes the time derivative and the Jacobian of the time derivative.
virtual Real duDotDuCoeff() const override
virtual void postStep() override
Callback to the TimeIntegrator called at the very end of time step.
virtual bool overridesSolve() const override
virtual void init() override
Called only before the very first timestep (t_step = 0) Never called again (not even during recover/r...
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
virtual int order() override
void computeTimeDerivativeHelper(T &u_dot, const T2 &u_old) const
Helper function that actually does the math for computing the time derivative.
NumericVector< Number > * _residual_old
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the NonLinearTimeIntegratorInterface called immediately after the residuals are computed ...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Base class for time integrators.
Real & _dt
The current time step size.