https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
47public:
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
63protected:
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
73 NumericVector<Number> * _residual_old;
74
76 const NumericVector<Number> & _solution_older;
77};
78
79template <typename T, typename T2, typename T3>
80void
81ExplicitTVDRK2::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}
DualNumber< Real, DNDerivativeType, true > ADReal
Explicit TVD (total-variation-diminishing) second-order Runge-Kutta time integration methods:
virtual void preSolve() override
NumericVector< Number > * _residual_old
Buffer to store non-time residual from the first stage.
unsigned int _stage
virtual void computeTimeDerivatives() override
Computes the time derivative and the Jacobian of the time derivative.
virtual void solve() override
Solves the time step and sets the number of nonlinear and linear iterations.
static InputParameters validParams()
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.
virtual bool overridesSolve() const override
virtual int order() override
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 postResidual(NumericVector< Number > &residual) override
Callback to the NonLinearTimeIntegratorInterface called immediately after the residuals are computed ...
const NumericVector< Number > & _solution_older
The older solution.
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.