VolumeTermsImpl.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <optional>
8 #include <ostream>
9 
11 #include "DataStructures/DataVector.hpp"
14 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
17 #include "Utilities/Gsl.hpp"
18 #include "Utilities/TMPL.hpp"
19 
20 namespace evolution::dg::Actions::detail {
21 /*
22  * Computes the volume terms for a discontinuous Galerkin scheme.
23  *
24  * The function does the following (in order):
25  *
26  * 1. Compute the partial derivatives of the `System::gradient_variables`.
27  *
28  * The partial derivatives are needed in the nonconservative product terms
29  * of the evolution equations. Any variable whose evolution equation does
30  * not contain a flux must contain a nonconservative product and the
31  * variable must be listed in the `System::gradient_variables` type alias.
32  * The partial derivatives are also needed for adding the moving mesh terms
33  * to the equations that do not have a flux term.
34  *
35  * 2. The volume time derivatives are calculated from
36  * `System::compute_volume_time_derivative_terms`
37  *
38  * The source terms and nonconservative products are contributed directly
39  * to the `dt_vars` arguments passed to the time derivative function, while
40  * the volume fluxes are computed into the `volume_fluxes` arguments. The
41  * divergence of the volume fluxes will be computed and added to the time
42  * derivatives later in the function.
43  *
44  * 3. If the mesh is moving the appropriate mesh velocity terms are added to
45  * the equations.
46  *
47  * For equations with fluxes this means that \f$-v^i_g u_\alpha\f$ is
48  * added to the fluxes and \f$-u_\alpha \partial_i v^i_g\f$ is added
49  * to the time derivatives. For equations without fluxes
50  * \f$v^i\partial_i u_\alpha\f$ is added to the time derivatives.
51  *
52  * 4. Compute flux divergence contribution and add it to the time derivatives.
53  *
54  * Either the weak or strong form can be used. Currently only the strong
55  * form is coded, but adding the weak form is quite easy.
56  *
57  * Note that the computation of the flux divergence and adding that to the
58  * time derivative must be done *after* the mesh velocity is subtracted
59  * from the fluxes.
60  */
61 template <typename ComputeVolumeTimeDerivativeTerms, size_t Dim,
62  typename... TimeDerivativeArguments, typename... VariablesTags,
63  typename... PartialDerivTags, typename... FluxVariablesTags,
64  typename... TemporaryTags>
65 void volume_terms(
66  const gsl::not_null<Variables<tmpl::list<::Tags::dt<VariablesTags>...>>*>
67  dt_vars_ptr,
68  [[maybe_unused]] const gsl::not_null<Variables<tmpl::list<::Tags::Flux<
69  FluxVariablesTags, tmpl::size_t<Dim>, Frame::Inertial>...>>*>
70  volume_fluxes,
71  [[maybe_unused]] const gsl::not_null<Variables<tmpl::list<::Tags::deriv<
72  PartialDerivTags, tmpl::size_t<Dim>, Frame::Inertial>...>>*>
73  partial_derivs,
74  [[maybe_unused]] const gsl::not_null<
75  Variables<tmpl::list<TemporaryTags...>>*>
76  temporaries,
77  const Variables<tmpl::list<VariablesTags...>>& evolved_vars,
78  const ::dg::Formulation dg_formulation, const Mesh<Dim>& mesh,
79  [[maybe_unused]] const tnsr::I<DataVector, Dim, Frame::Inertial>&
80  inertial_coordinates,
81  const InverseJacobian<DataVector, Dim, Frame::Logical, Frame::Inertial>&
82  logical_to_inertial_inverse_jacobian,
83  [[maybe_unused]] const Scalar<DataVector>* const det_inverse_jacobian,
84  const std::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>&
85  mesh_velocity,
86  const std::optional<Scalar<DataVector>>& div_mesh_velocity,
87  const TimeDerivativeArguments&... time_derivative_args) noexcept;
88 } // namespace evolution::dg::Actions::detail
Frame::Inertial
Definition: IndexType.hpp:44
Tags::Flux
Prefix indicating a flux.
Definition: Prefixes.hpp:40
cstddef
Variables.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:48
Tags::dt
Prefix indicating a time derivative.
Definition: Prefixes.hpp:29
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
TypeAliases.hpp
Tags::deriv
Prefix indicating spatial derivatives.
Definition: PartialDerivatives.hpp:52
optional
Mesh.hpp
PartialDerivatives.hpp
ostream
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
Prefixes.hpp
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13