SpECTRE  v2024.04.12
fd::reconstruction Namespace Reference

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

Enumerations

enum class  FallbackReconstructorType { Minmod , MonotonisedCentral , None }
 Possible types of reconstruction routines to fall back to from higher-order reconstruction when using adaptive method. 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>
auto aoweno_53_function_pointers (size_t nonlinear_weight_exponent) -> 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 &)>
 Returns function pointers to the aoweno_53 function, lower neighbor reconstruction, and upper neighbor reconstruction. More...
 
std::ostreamoperator<< (std::ostream &os, fd::reconstruction::FallbackReconstructorType recons_type)
 
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 monotonicity_preserving_5 (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 alpha, const double epsilon)
 Performs the fifth order monotonicity-preserving (MP5) reconstruction [174]. More...
 
template<size_t Dim>
void monotonised_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 monotonised central-difference reconstruction on the vars in each direction. More...
 
template<size_t Dim, bool ReturnReconstructionOrder>
auto positivity_preserving_adaptive_order_function_pointers (bool positivity_preserving, bool use_9th_order, bool use_7th_order, FallbackReconstructorType fallback_recons) -> std::tuple< detail::ppao_recons_type< Dim, ReturnReconstructionOrder >, 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 &)>
 Returns function pointers to the positivity_preserving_adaptive_order function, lower neighbor reconstruction, and upper neighbor reconstruction.
 
template<Side LowerOrUpperSide, typename Reconstructor , bool UseExteriorCell = true, size_t NumberOfGhostPoints = (Reconstructor::stencil_width() / 2 + 1), 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...
 
template<size_t NonlinearWeightExponent, class FallbackReconstructor , size_t Dim>
void wcns5z (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 epsilon, const size_t max_number_of_extrema)
 Performs fifth order weighted compact nonlinear scheme reconstruction based on the WENO-Z method (WCNS-5Z). Adaptive fallback combined with an auxiliary reconstruction method (e.g. monotonised central) is also supported. More...
 
template<size_t Dim>
auto wcns5z_function_pointers (size_t nonlinear_weight_exponent, FallbackReconstructorType fallback_recons) -> 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, size_t), void(*)(gsl::not_null< DataVector * >, const DataVector &, const DataVector &, const Index< Dim > &, const Index< Dim > &, const Direction< Dim > &, const double &, const size_t &), void(*)(gsl::not_null< DataVector * >, const DataVector &, const DataVector &, const Index< Dim > &, const Index< Dim > &, const Direction< Dim > &, const double &, const size_t &)>
 Returns function pointers to the wcns5z function, lower neighbor reconstruction, and upper neighbor reconstruction.
 
template<typename LowOrderReconstructor , bool PositivityPreserving, bool Use9thOrder, bool Use7thOrder, size_t Dim>
void positivity_preserving_adaptive_order (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 four_to_the_alpha_5, const double six_to_the_alpha_7, const double eight_to_the_alpha_9)
 Performs positivity-preserving adaptive-order FD reconstruction. More...
 
template<typename LowOrderReconstructor , bool PositivityPreserving, bool Use9thOrder, bool Use7thOrder, size_t Dim>
void positivity_preserving_adaptive_order (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::not_null< std::optional< std::array< gsl::span< std::uint8_t >, Dim > > * > reconstruction_order, 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 four_to_the_alpha_5, const double six_to_the_alpha_7, const double eight_to_the_alpha_9)
 Performs positivity-preserving adaptive-order FD reconstruction. 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>
auto fd::reconstruction::aoweno_53_function_pointers ( size_t  nonlinear_weight_exponent) -> 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 &)>

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.