www.mooseframework.org
ExplicitRK2.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 ExplicitRK2;
15 
16 template <>
18 
60 {
61 public:
63 
64  virtual void preSolve() override;
65  virtual int order() override { return 2; }
66 
67  virtual void computeTimeDerivatives() override;
68  void computeADTimeDerivatives(DualReal & ad_u_dot, const dof_id_type & dof) const override;
69  virtual void solve() override;
70  virtual void postResidual(NumericVector<Number> & residual) override;
71 
72 protected:
76  template <typename T, typename T2, typename T3>
77  void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old, const T3 & u_older) const;
78 
79  unsigned int _stage;
80 
82  NumericVector<Number> & _residual_old;
83 
87  virtual Real a() const = 0;
88  virtual Real b1() const = 0;
89  virtual Real b2() const = 0;
90 };
91 
92 template <typename T, typename T2, typename T3>
93 void
94 ExplicitRK2::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old, const T3 & u_older) const
95 {
96  if (_stage < 3)
97  u_dot -= u_old;
98  else
99  u_dot -= u_older;
100 
101  u_dot *= 1. / _dt;
102 }
103 
InputParameters validParams< ExplicitRK2 >()
Definition: ExplicitRK2.C:17
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
Base class for three different explicit second-order Runge-Kutta time integration methods: ...
Definition: ExplicitRK2.h:59
virtual void solve() override
Solves the time step and sets the number of nonlinear and linear iterations.
Definition: ExplicitRK2.C:68
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
virtual Real a() const =0
The method coefficients.
unsigned int _stage
Definition: ExplicitRK2.h:79
virtual int order() override
Definition: ExplicitRK2.h:65
NumericVector< Number > & _residual_old
Buffer to store non-time residual from the first stage.
Definition: ExplicitRK2.h:82
Base class for time integrators.
virtual Real b1() const =0
virtual void preSolve() override
Definition: ExplicitRK2.C:35
ExplicitRK2(const InputParameters &parameters)
Definition: ExplicitRK2.C:24
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the TimeIntegrator called immediately after the residuals are computed in NonlinearSystem...
Definition: ExplicitRK2.C:115
virtual void computeTimeDerivatives() override
Definition: ExplicitRK2.C:44
void computeTimeDerivativeHelper(T &u_dot, const T2 &u_old, const T3 &u_older) const
Helper function that actually does the math for computing the time derivative.
Definition: ExplicitRK2.h:94
virtual Real b2() const =0
void computeADTimeDerivatives(DualReal &ad_u_dot, const dof_id_type &dof) const override
method for computing local automatic differentiation time derivatives
Definition: ExplicitRK2.C:62