InterpolateFromBoundary.hpp
1 // 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"
15 #include "Utilities/Gsl.hpp"
16 
17 namespace evolution::dg {
18 namespace detail {
19 template <size_t Dim>
20 void interpolate_dt_terms_gauss_points_impl(
21  gsl::not_null<double*> volume_dt_vars, size_t num_independent_components,
22  const Mesh<Dim>& volume_mesh, size_t dimension, size_t num_boundary_pts,
23  const gsl::span<const double>& dt_corrections,
24  const DataVector& boundary_interpolation_term) noexcept;
25 } // namespace detail
26 
27 /*!
28  * \brief Interpolate the Bjorhus/time derivative corrections to the volume time
29  * derivatives in the specified direction.
30  *
31  * The general interpolation term (for the \f$+\xi\f$-dimension) is:
32  *
33  * \f{align*}{
34  * \partial_t u_{\alpha\breve{\imath}\breve{\jmath}\breve{k}}=\cdots
35  * +\ell^{\mathrm{Gauss-Lobatto}}_{N}
36  * \left(\xi_{\breve{\imath}}^{\mathrm{Gauss}}\right)
37  * \partial_t u^{\mathrm{BC}}_{\alpha\breve{\jmath}\breve{k}},
38  * \f}
39  *
40  * where \f$\breve{\imath}\f$, \f$\breve{\jmath}\f$, and \f$\breve{k}\f$ are
41  * indices in the logical \f$\xi\f$, \f$\eta\f$, and \f$\zeta\f$ dimensions.
42  * \f$\partial_t u^{\mathrm{BC}}\f$ is the time derivative correction, and
43  * the function Spectral::boundary_interpolation_term() is used to compute and
44  * cache the terms from the lifting terms.
45  */
46 template <size_t Dim, typename DtTagsList>
48  const gsl::not_null<Variables<DtTagsList>*> dt_vars,
49  const Mesh<Dim>& volume_mesh, const Direction<Dim>& direction,
50  const Variables<DtTagsList>& dt_corrections) noexcept {
51  ASSERT(std::all_of(volume_mesh.quadrature().begin(),
52  volume_mesh.quadrature().end(),
53  [](const Spectral::Quadrature quadrature) noexcept {
54  return quadrature == Spectral::Quadrature::Gauss;
55  }),
56  "Must use Gauss points in all directions but got the mesh: "
57  << volume_mesh);
58  const Mesh<Dim - 1> boundary_mesh =
59  volume_mesh.slice_away(direction.dimension());
60  const Mesh<1> volume_stripe_mesh =
61  volume_mesh.slice_through(direction.dimension());
62  const size_t num_boundary_grid_points = boundary_mesh.number_of_grid_points();
63  detail::interpolate_dt_terms_gauss_points_impl(
64  make_not_null(dt_vars->data()), dt_vars->number_of_independent_components,
65  volume_mesh, direction.dimension(), num_boundary_grid_points,
66  gsl::make_span(dt_corrections.data(), dt_corrections.size()),
67  direction.side() == Side::Upper
68  ? Spectral::boundary_interpolation_term(volume_stripe_mesh).second
69  : Spectral::boundary_interpolation_term(volume_stripe_mesh).first);
70 }
71 } // namespace evolution::dg
utility
evolution::dg
Functionality for evolving hyperbolic partial differential equations using the discontinuous Galerkin...
Definition: ConservativeDuDt.hpp:22
Side.hpp
Spectral.hpp
Direction< Dim >
Spectral::boundary_interpolation_term
const std::pair< DataVector, DataVector > & boundary_interpolation_term(const Mesh< 1 > &mesh) noexcept
Interpolates values from the boundary into the volume, which is needed when applying time derivative ...
cstddef
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
Spectral::Quadrature
Quadrature
The choice of quadrature method to compute integration weights.
Definition: Spectral.hpp:90
Mesh::slice_through
Mesh< sizeof...(D)> slice_through(D... d) const noexcept
Returns a Mesh with the dimensions d, ... present (zero-indexed).
Definition: Mesh.hpp:218
ASSERT
#define ASSERT(a, m)
Assert that an expression should be true.
Definition: Assert.hpp:49
Variables.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:48
gsl::span
Create a span/view on a range, which is cheap to copy (one pointer).
Definition: Gsl.hpp:292
gsl::make_span
constexpr span< ElementType > make_span(ElementType *ptr, typename span< ElementType >::index_type count)
Definition: Gsl.hpp:801
Gsl.hpp
make_not_null
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion,...
Definition: Gsl.hpp:880
Direction.hpp
Mesh::slice_away
Mesh< Dim - 1 > slice_away(size_t d) const noexcept
Returns a Mesh with dimension d removed (zero-indexed).
evolution::dg::interpolate_dt_terms_gauss_points
void interpolate_dt_terms_gauss_points(const gsl::not_null< Variables< DtTagsList > * > dt_vars, const Mesh< Dim > &volume_mesh, const Direction< Dim > &direction, const Variables< DtTagsList > &dt_corrections) noexcept
Interpolate the Bjorhus/time derivative corrections to the volume time derivatives in the specified d...
Definition: InterpolateFromBoundary.hpp:47
Mesh.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13