Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <utility>
8 :
9 : #include "DataStructures/DataVector.hpp"
10 : #include "DataStructures/Variables.hpp"
11 : #include "Domain/Structure/Direction.hpp"
12 : #include "Domain/Structure/Side.hpp"
13 : #include "NumericalAlgorithms/Spectral/BoundaryInterpolationTerm.hpp"
14 : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
15 : #include "NumericalAlgorithms/Spectral/Quadrature.hpp"
16 : #include "Utilities/Algorithm.hpp"
17 : #include "Utilities/Gsl.hpp"
18 :
19 : namespace dg {
20 : namespace detail {
21 : template <size_t Dim>
22 : void interpolate_dt_terms_gauss_points_impl(
23 : gsl::not_null<double*> volume_dt_vars, size_t num_independent_components,
24 : const Mesh<Dim>& volume_mesh, size_t dimension, size_t num_boundary_pts,
25 : const gsl::span<const double>& dt_corrections,
26 : const DataVector& boundary_interpolation_term);
27 : } // namespace detail
28 :
29 : /*!
30 : * \brief Interpolate the Bjorhus/time derivative corrections to the volume time
31 : * derivatives in the specified direction.
32 : *
33 : * The general interpolation term (for the \f$+\xi\f$-dimension) is:
34 : *
35 : * \f{align*}{
36 : * \partial_t u_{\alpha\breve{\imath}\breve{\jmath}\breve{k}}=\cdots
37 : * +\ell^{\mathrm{Gauss-Lobatto}}_{N}
38 : * \left(\xi_{\breve{\imath}}^{\mathrm{Gauss}}\right)
39 : * \partial_t u^{\mathrm{BC}}_{\alpha\breve{\jmath}\breve{k}},
40 : * \f}
41 : *
42 : * where \f$\breve{\imath}\f$, \f$\breve{\jmath}\f$, and \f$\breve{k}\f$ are
43 : * indices in the logical \f$\xi\f$, \f$\eta\f$, and \f$\zeta\f$ dimensions.
44 : * \f$\partial_t u^{\mathrm{BC}}\f$ is the time derivative correction, and
45 : * the function Spectral::boundary_interpolation_term() is used to compute and
46 : * cache the terms from the lifting terms.
47 : */
48 : template <size_t Dim, typename DtTagsList>
49 1 : void interpolate_dt_terms_gauss_points(
50 : const gsl::not_null<Variables<DtTagsList>*> dt_vars,
51 : const Mesh<Dim>& volume_mesh, const Direction<Dim>& direction,
52 : const Variables<DtTagsList>& dt_corrections) {
53 : ASSERT(alg::all_of(volume_mesh.quadrature(),
54 : [](const Spectral::Quadrature quadrature) {
55 : return quadrature == Spectral::Quadrature::Gauss;
56 : }),
57 : "Must use Gauss points in all directions but got the mesh: "
58 : << volume_mesh);
59 : const Mesh<Dim - 1> boundary_mesh =
60 : volume_mesh.slice_away(direction.dimension());
61 : const Mesh<1> volume_stripe_mesh =
62 : volume_mesh.slice_through(direction.dimension());
63 : const size_t num_boundary_grid_points = boundary_mesh.number_of_grid_points();
64 : detail::interpolate_dt_terms_gauss_points_impl(
65 : make_not_null(dt_vars->data()), dt_vars->number_of_independent_components,
66 : volume_mesh, direction.dimension(), num_boundary_grid_points,
67 : gsl::make_span(dt_corrections.data(), dt_corrections.size()),
68 : direction.side() == Side::Upper
69 : ? Spectral::boundary_interpolation_term(volume_stripe_mesh).second
70 : : Spectral::boundary_interpolation_term(volume_stripe_mesh).first);
71 : }
72 : } // namespace dg
|