Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
reconstruction Namespace Reference

Namespace to contain various utilities for the interface reconstruction kernels. More...

Classes

struct  Characteristic
 A struct for the characteristic variables. We use the same notation as Stone et al. 2008 where the variable. More...
 
struct  EigenVecs
 
struct  InterfaceState
 

Enumerations

enum  Kind {
  pcm , plmp , plmc , ppmp ,
  ppmc
}
 This enum is used to select which reconstructor to use. The idea is that either one of its implicitly defined members (i.e. not chosen) can be used to tell a kernel which reconstruction to perform and the member chosen can be used to indicate which reconstruction method was chosen at compile time. I.e. in a Van Leer integrator the pcm member would be passed to the first riemann solve to tell it to use PCM reconstruction and chosen would be passed to the second riemann solve to indicate which higher order reconstruction it should use.
 

Functions

template<uint direction>
reconstruction::InterfaceState __device__ __host__ PCM_Reconstruction (Real const *dev_conserved, size_t const xid, size_t const yid, size_t const zid, size_t const nx, size_t const ny, size_t const n_cells, Real const gamma)
 Perform PCM reconstruction for a given cell.
 
void __device__ __host__ PLM_Characteristic_Evolution (hydro_utilities::Primitive const &cell_i, hydro_utilities::Primitive const &del_m, Real const dt, Real const dx, Real const gamma, hydro_utilities::Primitive &interface_R_imh, hydro_utilities::Primitive &interface_L_iph)
 Perform characteristic tracing/evolution on an interface.
 
template<uint direction>
auto __device__ PLM_Reconstruction (Real *dev_conserved, int const xid, int const yid, int const zid, int const nx, int const ny, int const nz, Real const dx, Real const dt, Real const gamma)
 This is the device function that actually does the piecewise linear reconstruction.
 
template<int reconstruction_order, uint direction>
void __device__ __host__ Reconstruct_Interface_States (Real const *dev_conserved, size_t const xid, size_t const yid, size_t const zid, size_t const nx, size_t const ny, size_t const n_cells, Real const gamma, reconstruction::InterfaceState &left_interface, reconstruction::InterfaceState &right_interface)
 
template<int order>
bool __device__ __host__ Thread_Guard (int const &nx, int const &ny, int const &nz, int const &xid, int const &yid, int const &zid)
 Determine if a thread is within the allowed range.
 
hydro_utilities::Primitive __device__ __host__ Load_Data (Real const *dev_conserved, size_t const &xid, size_t const &yid, size_t const &zid, size_t const &nx, size_t const &ny, size_t const &n_cells, size_t const &o1, size_t const &o2, size_t const &o3, Real const &gamma)
 Load the data for reconstruction.
 
template<int reconstruction>
bool __device__ __host__ Riemann_Thread_Guard (size_t const nx, size_t const ny, size_t const nz, size_t const xid, size_t const yid, size_t const zid)
 Determine if a thread is within the allowed range.
 
hydro_utilities::Primitive __device__ __host__ Compute_Slope (hydro_utilities::Primitive const &left, hydro_utilities::Primitive const &right, Real const &coef=1.0)
 Compute a simple slope. Equation is coef * (right - left).
 
hydro_utilities::Primitive __device__ __host__ Compute_Van_Leer_Slope (hydro_utilities::Primitive const &left_slope, hydro_utilities::Primitive const &right_slope)
 Compute the Van Lear slope from the left and right slopes.
 
EigenVecs __device__ Compute_Eigenvectors (hydro_utilities::Primitive const &primitive, Real const &gamma)
 Compute the eigenvectors in the given cell.
 
Characteristic __device__ Primitive_To_Characteristic (hydro_utilities::Primitive const &primitive, hydro_utilities::Primitive const &primitive_slope, EigenVecs const &eigen, Real const &gamma)
 Project from the primitive variables slopes to the characteristic variables slopes. Stone Eqn 37. Use the eigenvectors given in Stone 2008, Appendix A.
 
hydro_utilities::Primitive __device__ __host__ Characteristic_To_Primitive (hydro_utilities::Primitive const &primitive, Characteristic const &characteristic_slope, EigenVecs const &eigen, Real const &gamma)
 Project from the characteristic variables slopes to the primitive variables slopes. Stone Eqn 39. Use the eigenvectors given in Stone 2008, Appendix A.
 
Real __device__ __host__ Van_Leer_Limiter (Real const &left, Real const &right, Real const &centered, Real const &van_leer)
 Compute the limited slope using the Van Leer limiter.
 
Characteristic __device__ __host__ Van_Leer_Limiter (Characteristic const &del_a_L, Characteristic const &del_a_R, Characteristic const &del_a_C, Characteristic const &del_a_G)
 Limit the charactistic slopes. This is an overload that take reconstruction::Characteristic variables instead of Reals as arguments. Note that it does not limit the gas energy or scalars.
 
hydro_utilities::Primitive __device__ __host__ Van_Leer_Limiter (hydro_utilities::Primitive const &del_L, hydro_utilities::Primitive const &del_R, hydro_utilities::Primitive const &del_C, hydro_utilities::Primitive const &del_G)
 Limit the primitive slopes. This is an overload that take reconstruction::Primitive variables instead of Reals as arguments.
 
void __device__ __host__ Monotonize_Parabolic_Interface (hydro_utilities::Primitive const &cell_i, hydro_utilities::Primitive const &cell_im1, hydro_utilities::Primitive const &cell_ip1, hydro_utilities::Primitive &interface_L_iph, hydro_utilities::Primitive &interface_R_imh)
 Monotonize the parabolic interface states.
 
hydro_utilities::Primitive __device__ __host__ Calc_Interface_Linear (hydro_utilities::Primitive const &primitive, hydro_utilities::Primitive const &slopes, Real const &sign)
 Compute the interface state from the slope and cell centered state using linear interpolation.
 
hydro_utilities::Primitive __device__ __host__ Calc_Interface_Parabolic (hydro_utilities::Primitive const &cell_i, hydro_utilities::Primitive const &cell_im1, hydro_utilities::Primitive const &slopes_i, hydro_utilities::Primitive const &slopes_im1)
 Compute the interface state for the CTU version fo the reconstructor from the slope and cell centered state using parabolic interpolation.
 
void __device__ __host__ PPM_Single_Variable (Real const &cell_im2, Real const &cell_im1, Real const &cell_i, Real const &cell_ip1, Real const &cell_ip2, Real &interface_L_iph, Real &interface_R_imh)
 Compute the PPM interface state for a given field/stencil.
 
void __device__ __host__ Write_Data (hydro_utilities::Primitive const &interface_state, Real *dev_interface, Real const *dev_conserved, size_t const &id, size_t const &n_cells, size_t const &o1, size_t const &o2, size_t const &o3, Real const &gamma)
 Write the interface data to the appropriate arrays.
 

Detailed Description

Namespace to contain various utilities for the interface reconstruction kernels.

Function Documentation

◆ Calc_Interface_Linear()

hydro_utilities::Primitive __device__ __host__ reconstruction::Calc_Interface_Linear ( hydro_utilities::Primitive const &  primitive,
hydro_utilities::Primitive const &  slopes,
Real const &  sign 
)
inline

Compute the interface state from the slope and cell centered state using linear interpolation.

Parameters
[in]primitiveThe cell centered state
[in]slopesThe slopes
[in]signWhether to add or subtract the slope. +1 to add it and -1 to subtract it
Returns
hydro_utilities::Primitive The interface state

◆ Calc_Interface_Parabolic()

hydro_utilities::Primitive __device__ __host__ reconstruction::Calc_Interface_Parabolic ( hydro_utilities::Primitive const &  cell_i,
hydro_utilities::Primitive const &  cell_im1,
hydro_utilities::Primitive const &  slopes_i,
hydro_utilities::Primitive const &  slopes_im1 
)
inline

Compute the interface state for the CTU version fo the reconstructor from the slope and cell centered state using parabolic interpolation.

Parameters
[in]cell_iThe state in cell i
[in]cell_im1The state in cell i-1
[in]slopes_iThe slopes in cell i
[in]slopes_im1The slopes in cell i-1
Returns
hydro_utilities::Primitive The interface state

◆ Characteristic_To_Primitive()

hydro_utilities::Primitive __device__ __host__ reconstruction::Characteristic_To_Primitive ( hydro_utilities::Primitive const &  primitive,
Characteristic const &  characteristic_slope,
EigenVecs const &  eigen,
Real const &  gamma 
)
inline

Project from the characteristic variables slopes to the primitive variables slopes. Stone Eqn 39. Use the eigenvectors given in Stone 2008, Appendix A.

Parameters
[in]primitiveThe primitive variables
[in]characteristic_slopeThe characteristic slopes
[in]eigenThe eigenvectors
[in]gammaThe adiabatic index
Returns
hydro_utilities::Primitive The state in primitive variables

◆ Compute_Eigenvectors()

EigenVecs __device__ reconstruction::Compute_Eigenvectors ( hydro_utilities::Primitive const &  primitive,
Real const &  gamma 
)
inline

Compute the eigenvectors in the given cell.

Parameters
[in]primitiveThe primitive variables in a particular cell
[in]gammaThe adiabatic index
Returns
EigenVecs

◆ Compute_Slope()

hydro_utilities::Primitive __device__ __host__ reconstruction::Compute_Slope ( hydro_utilities::Primitive const &  left,
hydro_utilities::Primitive const &  right,
Real const &  coef = 1.0 
)
inline

Compute a simple slope. Equation is coef * (right - left).

Parameters
[in]leftThe data with the lower index (on the "left" side)
[in]rightThe data with the higher index (on the "right" side)
[in]coefThe coefficient to multiply the slope by. Defaults to 1.0
Returns
hydro_utilities::Primitive The slopes

◆ Compute_Van_Leer_Slope()

hydro_utilities::Primitive __device__ __host__ reconstruction::Compute_Van_Leer_Slope ( hydro_utilities::Primitive const &  left_slope,
hydro_utilities::Primitive const &  right_slope 
)
inline

Compute the Van Lear slope from the left and right slopes.

Parameters
[in]left_slopeThe left slope
[in]right_slopeThe right slope
Returns
hydro_utilities::Primitive The Van Leer slope

◆ Load_Data()

hydro_utilities::Primitive __device__ __host__ reconstruction::Load_Data ( Real const *  dev_conserved,
size_t const &  xid,
size_t const &  yid,
size_t const &  zid,
size_t const &  nx,
size_t const &  ny,
size_t const &  n_cells,
size_t const &  o1,
size_t const &  o2,
size_t const &  o3,
Real const &  gamma 
)
inline

Load the data for reconstruction.

Parameters
[in]dev_conservedThe conserved array
[in]xidThe xid of the cell to load data from
[in]yidThe yid of the cell to load data from
[in]zidThe zid of the cell to load data from
[in]nxSize in the X direction
[in]nySize in the Y direction
[in]n_cellsThe total number of cells
[in]o1Directional parameter
[in]o2Directional parameter
[in]o3Directional parameter
[in]gammaThe adiabatic index
Returns
hydro_utilities::Primitive The loaded cell data

◆ Monotonize_Parabolic_Interface()

void __device__ __host__ reconstruction::Monotonize_Parabolic_Interface ( hydro_utilities::Primitive const &  cell_i,
hydro_utilities::Primitive const &  cell_im1,
hydro_utilities::Primitive const &  cell_ip1,
hydro_utilities::Primitive interface_L_iph,
hydro_utilities::Primitive interface_R_imh 
)
inline

Monotonize the parabolic interface states.

Parameters
[in]cell_iThe state in cell i
[in]cell_im1The state in cell i-1
[in]cell_ip1The state in cell i+1
[in,out]interface_L_iphThe left interface state at i+1/2
[in,out]interface_R_imhThe right interface state at i-1/2
Returns
hydro_utilities::Primitive

◆ PCM_Reconstruction()

template<uint direction>
reconstruction::InterfaceState __device__ __host__ reconstruction::PCM_Reconstruction ( Real const *  dev_conserved,
size_t const  xid,
size_t const  yid,
size_t const  zid,
size_t const  nx,
size_t const  ny,
size_t const  n_cells,
Real const  gamma 
)
inline

Perform PCM reconstruction for a given cell.

Template Parameters
directionThe direction that the solve is taking place in. 0=X, 1=Y, 2=Z
Parameters
[in]dev_conservedThe converved variable array
[in]xidThe x-direction cell id
[in]yidThe y-direction cell id
[in]zidThe z-direction cell id
[in]nxThe number of cells in the x-direction
[in]nyThe number of cells in the y-direction
[in]n_cellsThe total number of cells
[in]gammaThe adiabatic index
Returns
reconstruction::InterfaceState The interface state at xid, yid, zid

◆ PLM_Characteristic_Evolution()

void __device__ __host__ reconstruction::PLM_Characteristic_Evolution ( hydro_utilities::Primitive const &  cell_i,
hydro_utilities::Primitive const &  del_m,
Real const  dt,
Real const  dx,
Real const  gamma,
hydro_utilities::Primitive interface_R_imh,
hydro_utilities::Primitive interface_L_iph 
)
inline

Perform characteristic tracing/evolution on an interface.

Parameters
[in]cell_iThe cell state at cell i
[in]del_mThe limited slopes
[in]dtThe time step
[in]dxThe cell size in the direction of solve
[in]gammaThe adiabatic index
interface_R_imhThe R interface at i-1/2
interface_L_iphThe L interface at i+1/2

◆ PLM_Reconstruction()

template<uint direction>
auto __device__ reconstruction::PLM_Reconstruction ( Real *  dev_conserved,
int const  xid,
int const  yid,
int const  zid,
int const  nx,
int const  ny,
int const  nz,
Real const  dx,
Real const  dt,
Real const  gamma 
)
inline

This is the device function that actually does the piecewise linear reconstruction.

Template Parameters
directionThe direction that the solve is taking place in. 0=X, 1=Y, 2=Z
Parameters
dev_conservedThe conserved variable array
xidThe x index of the cell in the center of the stencil
yidThe y index of the cell in the center of the stencil
zidThe z index of the cell in the center of the stencil
nxThe number of cells in the x-direction
nyThe number of cells in the y-direction
nzThe number of cells in the z-direction
dxThe width of the cells in the direction of the solve
dtThe time step
gammaThe adiabatic index
Returns
auto A local struct which returns the left primitive interface at i+1/2 and the right primitive interface at i-1/2 in that order.

◆ PPM_Single_Variable()

void __device__ __host__ reconstruction::PPM_Single_Variable ( Real const &  cell_im2,
Real const &  cell_im1,
Real const &  cell_i,
Real const &  cell_ip1,
Real const &  cell_ip2,
Real &  interface_L_iph,
Real &  interface_R_imh 
)
inline

Compute the PPM interface state for a given field/stencil.

This method is heavily based on the implementation in Athena++. See the following papers for details

  • K. Felker & J. Stone, "A fourth-order accurate finite volume method for ideal MHD via upwind constrained transport", JCP, 375, (2018)
  • P. Colella & P. Woodward, "The Piecewise Parabolic Method (PPM) for Gas-Dynamical Simulations", JCP, 54, 174 (1984)
  • P. Colella & M. Sekora, "A limiter for PPM that preserves accuracy at smooth extrema", JCP, 227, 7069 (2008)
  • P. McCorquodale & P. Colella, "A high-order finite-volume method for conservation laws on locally refined grids", CAMCoS, 6, 1 (2011)
  • P. Colella, M.R. Dorr, J. Hittinger, D. Martin, "High-order, finite-volume methods in mapped coordinates", JCP, 230, 2952 (2011)
Parameters
[in]cell_im2The value of the field/stencil at i-2
[in]cell_im1The value of the field/stencil at i-1
[in]cell_iThe value of the field/stencil at i
[in]cell_ip1The value of the field/stencil at i+1
[in]cell_ip2The value of the field/stencil at i+2
[out]interface_L_iphThe left interface at the i+1/2 face
[out]interface_R_imhThe right interface at the i-1/2 face

◆ Primitive_To_Characteristic()

Characteristic __device__ reconstruction::Primitive_To_Characteristic ( hydro_utilities::Primitive const &  primitive,
hydro_utilities::Primitive const &  primitive_slope,
EigenVecs const &  eigen,
Real const &  gamma 
)
inline

Project from the primitive variables slopes to the characteristic variables slopes. Stone Eqn 37. Use the eigenvectors given in Stone 2008, Appendix A.

Parameters
[in]primitiveThe primitive variables
[in]primitive_slopeThe primitive variables slopes
[in]EigenVecsThe eigenvectors
[in]gammaThe adiabatic index
Returns
Characteristic

◆ Reconstruct_Interface_States()

template<int reconstruction_order, uint direction>
void __device__ __host__ reconstruction::Reconstruct_Interface_States ( Real const *  dev_conserved,
size_t const  xid,
size_t const  yid,
size_t const  zid,
size_t const  nx,
size_t const  ny,
size_t const  n_cells,
Real const  gamma,
reconstruction::InterfaceState left_interface,
reconstruction::InterfaceState right_interface 
)
inline
Template Parameters
reconstruction_orderWhat kind of reconstruction to use, PCM, PLMC, etc. This argument should always be a member of the reconstruction::Kind enum, behaviour is undefined otherwise.
directionThe direction that the solve is taking place in. 0=X, 1=Y, 2=Z
Parameters
[in]dev_conserved
[in]xid
[in]yid
[in]zid
[in]nx
[in]ny
[in]n_cells
[in]gamma
[out]left_interface
[out]right_interface

◆ Riemann_Thread_Guard()

template<int reconstruction>
bool __device__ __host__ reconstruction::Riemann_Thread_Guard ( size_t const  nx,
size_t const  ny,
size_t const  nz,
size_t const  xid,
size_t const  yid,
size_t const  zid 
)
inline

Determine if a thread is within the allowed range.

Template Parameters
reconstructionA member of reconstruction::Kind used to determine the order of reconstruction
Parameters
nxThe number of cells in the X-direction
nyThe number of cells in the Y-direction
nzThe number of cells in the Z-direction
xidThe X thread index
yidThe Y thread index
zidThe Z thread index
Returns
true The thread is NOT in the allowed range
false The thread is in the allowed range

◆ Thread_Guard()

template<int order>
bool __device__ __host__ reconstruction::Thread_Guard ( int const &  nx,
int const &  ny,
int const &  nz,
int const &  xid,
int const &  yid,
int const &  zid 
)
inline

Determine if a thread is within the allowed range.

Template Parameters
orderThe order of the reconstruction. 2 for PLM, 3 for PPM
Parameters
nxThe number of cells in the X-direction
nyThe number of cells in the Y-direction
nzThe number of cells in the Z-direction
xidThe X thread index
yidThe Y thread index
zidThe Z thread index
Returns
true The thread is NOT in the allowed range
false The thread is in the allowed range

◆ Van_Leer_Limiter() [1/3]

Characteristic __device__ __host__ reconstruction::Van_Leer_Limiter ( Characteristic const &  del_a_L,
Characteristic const &  del_a_R,
Characteristic const &  del_a_C,
Characteristic const &  del_a_G 
)
inline

Limit the charactistic slopes. This is an overload that take reconstruction::Characteristic variables instead of Reals as arguments. Note that it does not limit the gas energy or scalars.

Parameters
[in]del_a_LThe left characteristic slopes
[in]del_a_RThe right characteristic slopes
[in]del_a_CThe centered characteristic slopes
[in]del_a_GThe Van Leer characteristic slopes
Returns
Characteristic The limited characteristic slopes

◆ Van_Leer_Limiter() [2/3]

hydro_utilities::Primitive __device__ __host__ reconstruction::Van_Leer_Limiter ( hydro_utilities::Primitive const &  del_L,
hydro_utilities::Primitive const &  del_R,
hydro_utilities::Primitive const &  del_C,
hydro_utilities::Primitive const &  del_G 
)
inline

Limit the primitive slopes. This is an overload that take reconstruction::Primitive variables instead of Reals as arguments.

Parameters
[in]del_LThe left primitive slopes
[in]del_RThe right primitive slopes
[in]del_CThe centered primitive slopes
[in]del_GThe Van Leer primitive slopes
Returns
hydro_utilities::Primitive The limited primitive slopes

◆ Van_Leer_Limiter() [3/3]

Real __device__ __host__ reconstruction::Van_Leer_Limiter ( Real const &  left,
Real const &  right,
Real const &  centered,
Real const &  van_leer 
)
inline

Compute the limited slope using the Van Leer limiter.

Parameters
[in]leftThe left slope
[in]rightThe right slope
[in]centeredThe centered slope
[in]van_leerThe Van Leer slope
Returns
Real The limited slope

◆ Write_Data()

void __device__ __host__ reconstruction::Write_Data ( hydro_utilities::Primitive const &  interface_state,
Real *  dev_interface,
Real const *  dev_conserved,
size_t const &  id,
size_t const &  n_cells,
size_t const &  o1,
size_t const &  o2,
size_t const &  o3,
Real const &  gamma 
)
inline

Write the interface data to the appropriate arrays.

Parameters
[in]interface_stateThe interface state to write
[out]dev_interfaceThe interface array
[in]dev_conservedThe conserved variables
[in]idThe cell id to write to
[in]n_cellsThe total number of cells
[in]o1Directional parameter
[in]o2Directional parameter
[in]o3Directional parameter
[in]gammaThe adiabatic index