https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AStableDirk4.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
14class LStableDirk4;
15
52{
53public:
55
57
58 virtual int order() override { return 4; }
59 virtual void computeTimeDerivatives() override;
60 void computeADTimeDerivatives(ADReal & ad_u_dot,
61 const dof_id_type & dof,
62 ADReal & ad_u_dotdot) const override;
63 virtual void solve() override;
64 virtual void postResidual(NumericVector<Number> & residual) override;
65 virtual void postJacobian(libMesh::SparseMatrix<Number> & jacobian) override;
66 virtual bool overridesSolve() const override { return true; }
67
68protected:
72 template <typename T, typename T2>
73 void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const;
74
75 // Indicates the current stage.
76 unsigned int _stage;
77
78 // Store pointers to the various stage residuals
79 NumericVector<Number> * _stage_residuals[3];
80
81 // The parameter of the method, set at construction time and cannot be changed.
82 const Real _gamma; // 1.06857902130162881
83
84 // Butcher tableau "C" parameters derived from _gamma
85 // 1.06857902130162881, 0.5, -.06857902130162881
86 Real _c[3];
87
88 // Butcher tableau "A" values derived from _gamma. We only use the
89 // lower triangle of this.
90 // 1.06857902130162881
91 // -.56857902130162881, 1.06857902130162881
92 // 2.13715804260325762, -3.27431608520651524, 1.06857902130162881
93 Real _a[3][3];
94
95 // The Butcher tableau "b" parameters derived from _gamma;
96 // 1.2888640051572051e-01, 7.4222719896855893e-01, 1.2888640051572051e-01
97 Real _b[3];
98
99 // If true, we use a more expensive method (LStableDirk4) to
100 // "bootstrap" the first timestep of this method and avoid
101 // evaluating residuals before the initial time.
103
104 // A pointer to the "bootstrapping" method to use if _safe_start==true.
105 std::shared_ptr<LStableDirk4> _bootstrap_method;
106};
107
108template <typename T, typename T2>
109void
110AStableDirk4::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const
111{
112 u_dot -= u_old;
113 u_dot *= 1. / _dt;
114}
DualNumber< Real, DNDerivativeType, true > ADReal
Fourth-order diagonally implicit Runge Kutta method (Dirk) with three stages plus an update.
Real _a[3][3]
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the NonLinearTimeIntegratorInterface called immediately after the residuals are computed ...
unsigned int _stage
std::shared_ptr< LStableDirk4 > _bootstrap_method
void computeTimeDerivativeHelper(T &u_dot, const T2 &u_old) const
Helper function that actually does the math for computing the time derivative.
virtual int order() override
const Real _gamma
static InputParameters validParams()
virtual void postJacobian(libMesh::SparseMatrix< Number > &jacobian) override
Callback to the NonLinearTimeIntegratorInterface called after the element, face, Dirac and constraint...
NumericVector< Number > * _stage_residuals[3]
virtual void solve() override
Solves the time step and sets the number of nonlinear and linear iterations.
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 void computeTimeDerivatives() override
Computes the time derivative and the Jacobian of the time derivative.
virtual bool overridesSolve() const override
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Fourth-order diagonally implicit Runge Kutta method (Dirk) with five stages.
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.