SpECTRE  v2022.05.05
fd::reconstruction Namespace Reference

Variable and flux vector splitting reconstruction schemes for finite difference methods. More...

Functions

template<size_t NonlinearWeightExponent, size_t Dim>
void aoweno_53 (const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_upper_side_of_face_vars, const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_lower_side_of_face_vars, const gsl::span< const double > &volume_vars, const DirectionMap< Dim, gsl::span< const double > > &ghost_cell_vars, const Index< Dim > &volume_extents, const size_t number_of_variables, const double gamma_hi, const double gamma_lo, const double epsilon)
 Performs an adaptive order (AO) WENO reconstruction using a single 5th order stencil and a 3rd-order CWENO scheme. More...
 
template<size_t Dim>
std::tuple< void(*)(gsl::not_null< std::array< gsl::span< double >, Dim > * >, gsl::not_null< std::array< gsl::span< double >, Dim > * >, const gsl::span< const double > &, const DirectionMap< Dim, gsl::span< const double > > &, const Index< Dim > &, size_t, double, double, double), void(*)(gsl::not_null< DataVector * >, const DataVector &, const DataVector &, const Index< Dim > &, const Index< Dim > &, const Direction< Dim > &, const double &, const double &, const double &), void(*)(gsl::not_null< DataVector * >, const DataVector &, const DataVector &, const Index< Dim > &, const Index< Dim > &, const Direction< Dim > &, const double &, const double &, const double &)> aoweno_53_function_pointers (size_t nonlinear_weight_exponent)
 Returns function pointers to the aoweno_53 function, lower neighbor reconstruction, and upper neighbor reconstruction. More...
 
template<size_t Dim>
void minmod (const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_upper_side_of_face_vars, const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_lower_side_of_face_vars, const gsl::span< const double > &volume_vars, const DirectionMap< Dim, gsl::span< const double > > &ghost_cell_vars, const Index< Dim > &volume_extents, const size_t number_of_variables)
 Performs minmod reconstruction on the volume_vars in each direction. More...
 
template<size_t Dim>
void monotised_central (const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_upper_side_of_face_vars, const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_lower_side_of_face_vars, const gsl::span< const double > &volume_vars, const DirectionMap< Dim, gsl::span< const double > > &ghost_cell_vars, const Index< Dim > &volume_extents, const size_t number_of_variables)
 Performs monotised central-difference reconstruction on the vars in each direction. More...
 
template<Side LowerOrUpperSide, typename Reconstructor , size_t Dim, typename... ArgsForReconstructor>
void reconstruct_neighbor (gsl::not_null< DataVector * > face_data, const DataVector &volume_data, const DataVector &neighbor_data, const Index< Dim > &volume_extents, const Index< Dim > &ghost_data_extents, const Direction< Dim > &direction_to_reconstruct, const ArgsForReconstructor &... args_for_reconstructor)
 In a given direction, reconstruct the cells in the neighboring Element (or cluster of cells) nearest to the shared boundary between the current and neighboring Element (or cluster of cells). More...
 
template<size_t Degree, size_t Dim>
void unlimited (const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_upper_side_of_face_vars, const gsl::not_null< std::array< gsl::span< double >, Dim > * > reconstructed_lower_side_of_face_vars, const gsl::span< const double > &volume_vars, const DirectionMap< Dim, gsl::span< const double > > &ghost_cell_vars, const Index< Dim > &volume_extents, const size_t number_of_variables)
 Performs unlimited reconstruction on the vars in each direction. More...
 

Detailed Description

Variable and flux vector splitting reconstruction schemes for finite difference methods.

Implementations of reconstruction methods must call the function fd::reconstruction::detail::reconstruct to perform the reconstruction. This function performs the actual loops taking into account strides and ghost zones for the reconstruction method. The reconstruct function has the following signature:

template <typename Reconstructor, typename... ArgsForReconstructor, size_t
Dim>
reconstructed_upper_side_of_face_vars,
reconstructed_lower_side_of_face_vars,
const gsl::span<const double>& volume_vars,
const DirectionMap<Dim, gsl::span<const double>>& ghost_cell_vars,
const Index<Dim>& volume_extents, const size_t number_of_variables,
const ArgsForReconstructor&... args_for_reconstructor);
An optimized map with Direction keys.
Definition: DirectionMap.hpp:16
An integer multi-index.
Definition: Index.hpp:31
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
Create a span/view on a range, which is cheap to copy (one pointer).
Definition: Gsl.hpp:499
DataVector reconstruct(const DataVector &subcell_u_times_projected_det_jac, const Mesh< Dim > &dg_mesh, const Index< Dim > &subcell_extents, ReconstructionMethod reconstruction_method)
reconstruct the variable subcell_u_times_projected_det_jac onto the DG grid dg_mesh.

The type of reconstruction done is specified with the Reconstructor explicit template parameter. Parameters for the reconstruction scheme, such as the linear weights and the epsilon tolerance in a CWENO reconstruction scheme, are forwarded along using the args_for_reconstruction parameter pack.

Reconstructor classes must define:

  • a static constexpr size_t stencil_width() function that returns the size of the stencil, e.g. 3 for minmod, and 5 for 5-point reconstruction.
  • a
    const double* const u, const int stride)
    #define SPECTRE_ALWAYS_INLINE
    Always inline a function. Only use this if you benchmarked the code.
    Definition: ForceInline.hpp:16
    function that optionally takes the additional arguments. The u are the cell-centered values to reconstruct. The value \(u_i\) in the current FD cell is located at u[0], the value at neighbor cell \(u_{i+1}\) is at u[stride], and the value at neighbor cell \(u_{i-1}\) is at u[-stride]. The returned values are the reconstructed solution on the lower and upper side of the cell.
Note
Currently the stride is always one because we transpose the data before reconstruction. However, it may be faster to have a non-unit stride without the transpose. We have the stride parameter in the reconstruction schemes to make testing performance easier in the future.

Here is an ASCII illustration of the names of various quantities and where in the cells they are:

reconstructed_upper_side_of_face_vars v
reconstructed_lower_side_of_face_vars v
volume_vars (at the cell-center) v
| x |
^ reconstructed_upper_side_of_face_vars
^ reconstructed_lower_side_of_face_vars
constexpr T & at(std::array< T, N > &arr, Size index)
Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid.
Definition: Gsl.hpp:125

Notice that the reconstructed_upper_side_of_face_vars are actually on the lower side of the cells, while the reconstructed_lower_side_of_face_vars are on the upper side of the cells. The upper and lower here refers to which side of the interface the quantity is on, not from the perspective of each cells.

Function Documentation

◆ aoweno_53_function_pointers()

template<size_t Dim>
std::tuple< void(*)(gsl::not_null< std::array< gsl::span< double >, Dim > * >, gsl::not_null< std::array< gsl::span< double >, Dim > * >, const gsl::span< const double > &, const DirectionMap< Dim, gsl::span< const double > > &, const Index< Dim > &, size_t, double, double, double), void(*)(gsl::not_null< DataVector * >, const DataVector &, const DataVector &, const Index< Dim > &, const Index< Dim > &, const Direction< Dim > &, const double &, const double &, const double &), void(*)(gsl::not_null< DataVector * >, const DataVector &, const DataVector &, const Index< Dim > &, const Index< Dim > &, const Direction< Dim > &, const double &, const double &, const double &)> fd::reconstruction::aoweno_53_function_pointers ( size_t  nonlinear_weight_exponent)

Returns function pointers to the aoweno_53 function, lower neighbor reconstruction, and upper neighbor reconstruction.

This is useful for controlling template parameters like the NonlinearWeightExponent from an input file by setting a function pointer. Note that the reason the reconstruction functions instead of say the pointwise member function is returned is to avoid function pointers inside tight loops.