https://mooseframework.inl.gov
ExplicitTVDRK2.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 
46 {
47 public:
49 
51 
52  virtual void preSolve() override;
53  virtual int order() override { return 2; }
54 
55  virtual void computeTimeDerivatives() override;
56  void computeADTimeDerivatives(ADReal & ad_u_dot,
57  const dof_id_type & dof,
58  ADReal & ad_u_dotdot) const override;
59  virtual void solve() override;
60  virtual void postResidual(NumericVector<Number> & residual) override;
61  virtual bool overridesSolve() const override { return true; }
62 
63 protected:
67  template <typename T, typename T2, typename T3>
68  void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old, const T3 & u_older) const;
69 
70  unsigned int _stage;
71 
74 
77 };
78 
79 template <typename T, typename T2, typename T3>
80 void
81 ExplicitTVDRK2::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old, const T3 & u_older) const
82 {
83  if (_stage < 3)
84  {
85  u_dot -= u_old;
86  u_dot *= 1. / _dt;
87  }
88  else
89  {
90  u_dot *= 2.;
91  u_dot -= u_old;
92  u_dot -= u_older;
93  u_dot *= 0.5 / _dt;
94  }
95 }
virtual void computeTimeDerivatives() override
Computes the time derivative and the Jacobian of the time derivative.
virtual bool overridesSolve() const override
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.
unsigned int _stage
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual int order() override
virtual void preSolve() override
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:46
Real & _dt
The current time step size.
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
const NumericVector< Number > & _solution_older
The older solution.
Base class for time integrators.
ExplicitTVDRK2(const InputParameters &parameters)
virtual void postResidual(NumericVector< Number > &residual) override
Callback to the NonLinearTimeIntegratorInterface called immediately after the residuals are computed ...
const InputParameters & parameters() const
Get the parameters of the object.
NumericVector< Number > * _residual_old
Buffer to store non-time residual from the first stage.
Explicit TVD (total-variation-diminishing) second-order Runge-Kutta time integration methods: ...
virtual void solve() override
Solves the time step and sets the number of nonlinear and linear iterations.
static InputParameters validParams()
uint8_t dof_id_type