ORB5X 1.0.0
Performance-portable global electromagnetic gyrokinetic PIC code
orb5x::MathUtil Class Reference

Provides solver quadrature, indexing, RNG, and radial-boundary transforms. More...

#include "math_util.hpp"

+ Collaboration diagram for orb5x::MathUtil:

Public Types

using HostRealView = Kokkos::View< Real *, Kokkos::LayoutStride, Kokkos::HostSpace >
 Strided host vector accepted by quadrature helpers.
 

Static Public Member Functions

static int computeMapping2to1 (int i, int j, int nj)
 Flatten a one-based two-dimensional index.
 
static int computeMapping2to1_0 (int i, int j, int nj)
 Flatten a zero-based two-dimensional index.
 
template<typename PointsView , typename WeightsView >
static void computeQuadraturePoints (Real x1, Real x2, PointsView points, WeightsView weights, int nbq, int method)
 Fill quadrature abscissae and weights on interval \([x_1,x_2]\).
 
static void computeVelocitySpaceDiscretization (Real dx, int nqw, int nqa, Real lw, int &nw, int &na)
 Choose velocity-magnitude and pitch grid counts consistent with spatial spacing.
 
static Real gaussian_number ()
 Draw a standard-normal variate via Box–Muller.
 
static Real plusminus ()
 Draw a random sign.
 
static void seed (unsigned int s)
 Reset the utility random stream.
 
static Real uniform ()
 Draw a unit-uniform variate.
 

Static Public Attributes

static constexpr Real coeffsc [3] = {5.0, -4.0, -1.0}
 Cubic endpoint constraint coefficients.
 
static constexpr Real coeffsq [2] = {1.0, -1.0}
 Quadratic endpoint constraint coefficients.
 
static constexpr Complex CPONE = Complex(1.0, 0.0)
 Complex multiplicative identity.
 
static constexpr Complex CPZERO = Complex(0.0, 0.0)
 Complex additive identity.
 
static constexpr int QUAD_EQUID = 2
 Equidistant Newton–Cotes-like selector.
 
static constexpr int QUAD_GAUSS = 1
 Gauss–Legendre quadrature selector.
 
static constexpr Real Tlc [3][3]
 Left cubic boundary transform.
 
static constexpr Real Tlc_deboor [3][3]
 Left cubic de Boor endpoint conversion.
 
static constexpr Real Tlc_inv [3][3]
 Inverse left cubic transform.
 
static constexpr Real Tlc_tr [3][3]
 Transpose of left cubic transform.
 
static constexpr Real Tlq [2][2]
 Left quadratic boundary transform.
 
static constexpr Real Tlq_inv [2][2]
 Inverse left quadratic transform.
 
static constexpr Real Tlq_tr [2][2]
 Transpose of left quadratic transform.
 
static constexpr Real Trc [3][3]
 Right cubic boundary transform.
 
static constexpr Real Trc_deboor [3][3]
 Right cubic de Boor endpoint conversion.
 
static constexpr Real Trc_inv [3][3]
 Inverse right cubic transform.
 
static constexpr Real Trc_tr [3][3]
 Transpose of right cubic transform.
 
static constexpr Real Trq [2][2]
 Right quadratic boundary transform.
 
static constexpr Real Trq_inv [2][2]
 Inverse right quadratic transform.
 
static constexpr Real Trq_tr [2][2]
 Transpose of right quadratic transform.
 

Detailed Description

Provides solver quadrature, indexing, RNG, and radial-boundary transforms.

Boundary matrices are transcribed so M_cpp[i][j] equals Fortran M(i+1,j+1) despite the languages' different initializer/reshape ordering.

Fortran reference solver/MathUtil.F90, module MathUtil.

Member Typedef Documentation

◆ HostRealView

using orb5x::MathUtil::HostRealView = Kokkos::View<Real*, Kokkos::LayoutStride, Kokkos::HostSpace>

Strided host vector accepted by quadrature helpers.

Member Function Documentation

◆ computeMapping2to1()

static int orb5x::MathUtil::computeMapping2to1 ( int  i,
int  j,
int  nj 
)
static

Flatten a one-based two-dimensional index.

Parameters
[in]iOne-based first index.
[in]jOne-based second index.
[in]njExtent of the second dimension.
Returns
One-based flattened index j + nj*(i-1).

◆ computeMapping2to1_0()

static int orb5x::MathUtil::computeMapping2to1_0 ( int  i,
int  j,
int  nj 
)
static

Flatten a zero-based two-dimensional index.

Parameters
[in]iZero-based first index.
[in]jZero-based second index.
[in]njExtent of the second dimension.
Returns
Zero-based flattened index j + nj*i.

◆ computeQuadraturePoints()

template<typename PointsView , typename WeightsView >
static void orb5x::MathUtil::computeQuadraturePoints ( Real  x1,
Real  x2,
PointsView  points,
WeightsView  weights,
int  nbq,
int  method 
)
inlinestatic

Fill quadrature abscissae and weights on interval \([x_1,x_2]\).

Parameters
[in]x1Lower integration bound.
[in]x2Upper integration bound.
[out]pointsView with at least nbq entries.
[out]weightsCorresponding integration weights.
[in]nbqNumber of quadrature points.
[in]methodQUAD_GAUSS or QUAD_EQUID.

◆ computeVelocitySpaceDiscretization()

static void orb5x::MathUtil::computeVelocitySpaceDiscretization ( Real  dx,
int  nqw,
int  nqa,
Real  lw,
int &  nw,
int &  na 
)
static

Choose velocity-magnitude and pitch grid counts consistent with spatial spacing.

Parameters
[in]dxSpatial grid scale entering resolution estimates.
[in]nqwQuadrature order in speed.
[in]nqaQuadrature order in pitch angle.
[in]lwMaximum normalized speed coordinate.
[out]nwNumber of speed intervals/points selected.
[out]naNumber of pitch intervals/points selected.

◆ gaussian_number()

static Real orb5x::MathUtil::gaussian_number ( )
static

Draw a standard-normal variate via Box–Muller.

Returns
Dimensionless pseudorandom value with zero mean and unit variance.

◆ plusminus()

static Real orb5x::MathUtil::plusminus ( )
static

Draw a random sign.

Returns
-1 or +1 with equal probability.

◆ seed()

static void orb5x::MathUtil::seed ( unsigned int  s)
static

Reset the utility random stream.

Parameters
[in]sUnsigned engine seed.

◆ uniform()

static Real orb5x::MathUtil::uniform ( )
static

Draw a unit-uniform variate.

Returns
Dimensionless pseudorandom value in [0,1).

Member Data Documentation

◆ coeffsc

constexpr Real orb5x::MathUtil::coeffsc[3] = {5.0, -4.0, -1.0}
staticconstexpr

Cubic endpoint constraint coefficients.

◆ coeffsq

constexpr Real orb5x::MathUtil::coeffsq[2] = {1.0, -1.0}
staticconstexpr

Quadratic endpoint constraint coefficients.

◆ CPONE

constexpr Complex orb5x::MathUtil::CPONE = Complex(1.0, 0.0)
staticconstexpr

Complex multiplicative identity.

◆ CPZERO

constexpr Complex orb5x::MathUtil::CPZERO = Complex(0.0, 0.0)
staticconstexpr

Complex additive identity.

◆ QUAD_EQUID

constexpr int orb5x::MathUtil::QUAD_EQUID = 2
staticconstexpr

Equidistant Newton–Cotes-like selector.

◆ QUAD_GAUSS

constexpr int orb5x::MathUtil::QUAD_GAUSS = 1
staticconstexpr

Gauss–Legendre quadrature selector.

◆ Tlc

constexpr Real orb5x::MathUtil::Tlc[3][3]
staticconstexpr
Initial value:
= {
{ 6.0, 0.0, 0.0},
{-4.0, 1.0, 0.0},
{-1.0, 0.0, 1.0}
}

Left cubic boundary transform.

◆ Tlc_deboor

constexpr Real orb5x::MathUtil::Tlc_deboor[3][3]
staticconstexpr
Initial value:
= {
{1.0/6.0, 0.0, 0.0},
{2.0/3.0, 2.0/3.0, 0.0},
{1.0/6.0, 1.0/3.0, 1.0}
}

Left cubic de Boor endpoint conversion.

◆ Tlc_inv

constexpr Real orb5x::MathUtil::Tlc_inv[3][3]
staticconstexpr
Initial value:
= {
{1.0/6.0, 0.0, 0.0},
{2.0/3.0, 1.0, 0.0},
{1.0/6.0, 0.0, 1.0}
}

Inverse left cubic transform.

◆ Tlc_tr

constexpr Real orb5x::MathUtil::Tlc_tr[3][3]
staticconstexpr
Initial value:
= {
{ 6.0, -4.0, -1.0},
{ 0.0, 1.0, 0.0},
{ 0.0, 0.0, 1.0}
}

Transpose of left cubic transform.

◆ Tlq

constexpr Real orb5x::MathUtil::Tlq[2][2]
staticconstexpr
Initial value:
= {
{ 2.0, 0.0},
{-1.0, 1.0}
}

Left quadratic boundary transform.

◆ Tlq_inv

constexpr Real orb5x::MathUtil::Tlq_inv[2][2]
staticconstexpr
Initial value:
= {
{0.5, 0.0},
{0.5, 1.0}
}

Inverse left quadratic transform.

◆ Tlq_tr

constexpr Real orb5x::MathUtil::Tlq_tr[2][2]
staticconstexpr
Initial value:
= {
{ 2.0, -1.0},
{ 0.0, 1.0}
}

Transpose of left quadratic transform.

◆ Trc

constexpr Real orb5x::MathUtil::Trc[3][3]
staticconstexpr
Initial value:
= {
{1.0, 0.0, -1.0},
{0.0, 1.0, -4.0},
{0.0, 0.0, 6.0}
}

Right cubic boundary transform.

◆ Trc_deboor

constexpr Real orb5x::MathUtil::Trc_deboor[3][3]
staticconstexpr
Initial value:
= {
{1.0, 1.0/3.0, 1.0/6.0},
{0.0, 2.0/3.0, 2.0/3.0},
{0.0, 0.0, 1.0/6.0}
}

Right cubic de Boor endpoint conversion.

◆ Trc_inv

constexpr Real orb5x::MathUtil::Trc_inv[3][3]
staticconstexpr
Initial value:
= {
{1.0, 0.0, 1.0/6.0},
{0.0, 1.0, 2.0/3.0},
{0.0, 0.0, 1.0/6.0}
}

Inverse right cubic transform.

◆ Trc_tr

constexpr Real orb5x::MathUtil::Trc_tr[3][3]
staticconstexpr
Initial value:
= {
{ 1.0, 0.0, 0.0},
{ 0.0, 1.0, 0.0},
{-1.0, -4.0, 6.0}
}

Transpose of right cubic transform.

◆ Trq

constexpr Real orb5x::MathUtil::Trq[2][2]
staticconstexpr
Initial value:
= {
{1.0, -1.0},
{0.0, 2.0}
}

Right quadratic boundary transform.

◆ Trq_inv

constexpr Real orb5x::MathUtil::Trq_inv[2][2]
staticconstexpr
Initial value:
= {
{1.0, 0.5},
{0.0, 0.5}
}

Inverse right quadratic transform.

◆ Trq_tr

constexpr Real orb5x::MathUtil::Trq_tr[2][2]
staticconstexpr
Initial value:
= {
{ 1.0, 0.0},
{-1.0, 2.0}
}

Transpose of right quadratic transform.


The documentation for this class was generated from the following file: