https://mooseframework.inl.gov
CentralDifference.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 "ActuallyExplicitEuler.h"
13 
19 {
20 public:
22 
24 
25  virtual void initialSetup() override;
26 
27  virtual int order() override { return 2; }
28  virtual void computeTimeDerivatives() override;
29  void computeADTimeDerivatives(ADReal & ad_u_dot,
30  const dof_id_type & dof,
31  ADReal & ad_u_dotdot) const override;
32 
33 protected:
34  virtual Real duDotDuCoeff() const override;
35 
38 
41 
45  template <typename T, typename T2, typename T3, typename T4>
46  void
47  computeTimeDerivativeHelper(T & u_dot, T2 & u_dotdot, const T3 & u_old, const T4 & u_older) const;
48 };
49 
50 template <typename T, typename T2, typename T3, typename T4>
51 void
53  T2 & u_dotdot,
54  const T3 & u_old,
55  const T4 & u_older) const
56 {
57  // computing first derivative
58  // using the Central Difference method
59  // u_dot_old = (first_term - second_term) / 2 / dt
60  // first_term = u
61  // second_term = u_older
62  u_dot -= u_older; // 'older than older' solution
63  u_dot *= 1.0 / (2.0 * _dt);
64 
65  // computing second derivative
66  // using the Central Difference method
67  // u_dotdot_old = (first_term - second_term + third_term) / dt / dt
68  // first_term = u
69  // second_term = 2 * u_old
70  // third_term = u_older
71  u_dotdot -= u_old;
72  u_dotdot -= u_old;
73  u_dotdot += u_older;
74  u_dotdot *= 1.0 / (_dt * _dt);
75 }
Real & _du_dotdot_du
solution vector for
void computeTimeDerivativeHelper(T &u_dot, T2 &u_dotdot, const T3 &u_old, const T4 &u_older) const
Helper function that actually does the math for computing the time derivative.
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.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
Implements a truly explicit (no nonlinear solve) Central Difference time integration scheme...
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
Real & _dt
The current time step size.
virtual Real duDotDuCoeff() const override
const NumericVector< Number > & _solution_older
The older solution.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const InputParameters & parameters() const
Get the parameters of the object.
Implements a truly explicit (no nonlinear solve) first-order, forward Euler time integration scheme...
CentralDifference(const InputParameters &parameters)
virtual int order() override
virtual void initialSetup() override
Called to setup datastructures.
uint8_t dof_id_type