Extension: Geometries
#include "dg/geometries/geometries.h"
4. Fieldaligned derivatives

\( \nabla_\parallel f\) More...

Classes

struct  dg::geo::DS< ProductGeometry, IMatrix, Matrix, container >
 Class for the evaluation of parallel derivatives. More...
 
struct  dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >
 Create and manage interpolation matrices from fieldline integration. More...
 

Typedefs

typedef ONE dg::geo::FullLimiter
 Full Limiter means there is a limiter everywhere. More...
 
typedef ZERO dg::geo::NoLimiter
 No Limiter. More...
 

Enumerations

enum  dg::geo::whichMatrix {
  dg::geo::einsPlus = 0 , dg::geo::einsPlusT , dg::geo::einsMinus , dg::geo::einsMinusT ,
  dg::geo::zeroPlus , dg::geo::zeroMinus , dg::geo::zeroPlusT , dg::geo::zeroMinusT ,
  dg::geo::zeroForw , dg::geo::einsPlus = 0 , dg::geo::einsPlusT , dg::geo::einsMinus ,
  dg::geo::einsMinusT , dg::geo::zeroPlus , dg::geo::zeroMinus , dg::geo::zeroPlusT ,
  dg::geo::zeroMinusT , dg::geo::zeroBack , dg::geo::einsPlus = 0 , dg::geo::einsPlusT ,
  dg::geo::einsMinus , dg::geo::einsMinusT , dg::geo::zeroPlus , dg::geo::zeroMinus ,
  dg::geo::zeroPlusT , dg::geo::zeroMinusT , dg::geo::zeroForw
}
 Enum for the use in Fieldaligned. More...
 
enum  dg::geo::whichMatrix {
  dg::geo::einsPlus = 0 , dg::geo::einsPlusT , dg::geo::einsMinus , dg::geo::einsMinusT ,
  dg::geo::zeroPlus , dg::geo::zeroMinus , dg::geo::zeroPlusT , dg::geo::zeroMinusT ,
  dg::geo::zeroForw , dg::geo::einsPlus = 0 , dg::geo::einsPlusT , dg::geo::einsMinus ,
  dg::geo::einsMinusT , dg::geo::zeroPlus , dg::geo::zeroMinus , dg::geo::zeroPlusT ,
  dg::geo::zeroMinusT , dg::geo::zeroBack , dg::geo::einsPlus = 0 , dg::geo::einsPlusT ,
  dg::geo::einsMinus , dg::geo::einsMinusT , dg::geo::zeroPlus , dg::geo::zeroMinus ,
  dg::geo::zeroPlusT , dg::geo::zeroMinusT , dg::geo::zeroForw
}
 Enum for the use in Fieldaligned. More...
 
enum  dg::geo::whichMatrix {
  dg::geo::einsPlus = 0 , dg::geo::einsPlusT , dg::geo::einsMinus , dg::geo::einsMinusT ,
  dg::geo::zeroPlus , dg::geo::zeroMinus , dg::geo::zeroPlusT , dg::geo::zeroMinusT ,
  dg::geo::zeroForw , dg::geo::einsPlus = 0 , dg::geo::einsPlusT , dg::geo::einsMinus ,
  dg::geo::einsMinusT , dg::geo::zeroPlus , dg::geo::zeroMinus , dg::geo::zeroPlusT ,
  dg::geo::zeroMinusT , dg::geo::zeroBack , dg::geo::einsPlus = 0 , dg::geo::einsPlusT ,
  dg::geo::einsMinus , dg::geo::einsMinusT , dg::geo::zeroPlus , dg::geo::zeroMinus ,
  dg::geo::zeroPlusT , dg::geo::zeroMinusT , dg::geo::zeroForw
}
 Enum for the use in Fieldaligned. More...
 

Functions

template<class FieldAligned , class container >
void dg::geo::assign_bc_along_field_2nd (const FieldAligned &fa, const container &fm, const container &f, const container &fp, container &fmg, container &fpg, dg::bc bound, std::array< double, 2 > boundary_value={0, 0})
 Assign boundary conditions along magnetic field lines interpolating a 2nd order polynomial. More...
 
template<class FieldAligned , class container >
void dg::geo::assign_bc_along_field_1st (const FieldAligned &fa, const container &fm, const container &fp, container &fmg, container &fpg, dg::bc bound, std::array< double, 2 > boundary_value={0, 0})
 Assign boundary conditions along magnetic field lines interpolating a 1st order polynomial (a line) More...
 
template<class FieldAligned , class container >
void dg::geo::swap_bc_perp (const FieldAligned &fa, const container &fm, const container &fp, container &fmg, container &fpg)
 Swap the perp boundary condition. More...
 
template<class FieldAligned , class container >
void dg::geo::ds_forward (const FieldAligned &fa, double alpha, const container &f, const container &fp, double beta, container &g)
 forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_forward2 (const FieldAligned &fa, double alpha, const container &f, const container &fp, const container &fpp, double beta, container &g)
 2nd order forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_backward (const FieldAligned &fa, double alpha, const container &fm, const container &f, double beta, container &g)
 backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_backward2 (const FieldAligned &fa, double alpha, const container &fmm, const container &fm, const container &f, double beta, container &g)
 2nd order backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_centered (const FieldAligned &fa, double alpha, const container &fm, const container &fp, double beta, container &g)
 centered derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::dss_centered (const FieldAligned &fa, double alpha, const container &fm, const container &f, const container &fp, double beta, container &g)
 Centered derivative \( g = \alpha (\vec v\cdot \nabla)^2 f + \beta g \). More...
 
template<class FieldAligned , class container >
void dg::geo::dssd_centered (const FieldAligned &fa, double alpha, const container &fm, const container &f, const container &fp, double beta, container &g)
 Centered derivative \( g = \alpha \nabla\cdot(\vec v \vec v\cdot \nabla) f + \beta g \). More...
 
template<class FieldAligned , class container >
void dg::geo::ds_divBackward (const FieldAligned &fa, double alpha, const container &fm, const container &f, double beta, container &g)
 backward derivative \( g = \alpha \nabla \cdot \vec v f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_divForward (const FieldAligned &fa, double alpha, const container &f, const container &fp, double beta, container &g)
 forward derivative \( g = \alpha \nabla \cdot \vec v f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_divCentered (const FieldAligned &fa, double alpha, const container &fm, const container &fp, double beta, container &g)
 centered derivative \( g = \alpha \nabla \cdot \vec v f + \beta g\) More...
 
template<class FieldAligned , class container >
void dg::geo::ds_average (const FieldAligned &fa, double alpha, const container &fm, const container &fp, double beta, container &g)
 Compute average along a fieldline \( g = \alpha \frac{f_{k+1} + f_{k-1}}{2} + \beta g\). More...
 
template<class FieldAligned , class container >
void dg::geo::ds_slope (const FieldAligned &fa, double alpha, const container &fm, const container &fp, double beta, container &g)
 Compute simple slope along a fieldline \( g = \alpha v^\varphi\frac{f_{k+1} - f_{k-1}}{2\Delta\varphi} + \beta g\). More...
 
template<class BinaryOp , class UnaryOp >
thrust::host_vector< double > dg::geo::fieldaligned_evaluate (const aProductGeometry3d &grid, const CylindricalVectorLvl0 &vec, const BinaryOp &binary, const UnaryOp &unary, unsigned p0, unsigned rounds, double eps=1e-5)
 Evaluate a 2d functor and transform to all planes along the fieldlines More...
 
template<class BinaryOp , class UnaryOp >
MPI_Vector< thrust::host_vector< double > > dg::geo::fieldaligned_evaluate (const aProductMPIGeometry3d &grid, const CylindricalVectorLvl0 &vec, const BinaryOp &binary, const UnaryOp &unary, unsigned p0, unsigned rounds, double eps=1e-5)
 Evaluate a 2d functor and transform to all planes along the fieldlines (MPI Version) More...
 

Detailed Description

\( \nabla_\parallel f\)

Typedef Documentation

◆ FullLimiter

Full Limiter means there is a limiter everywhere.

◆ NoLimiter

No Limiter.

Enumeration Type Documentation

◆ whichMatrix [1/3]

Enum for the use in Fieldaligned.

Enumerator
einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroForw 

from dg to transformed coordinates

einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroBack 

from transfomred back to dg coordinates

einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroForw 

from dg to transformed coordinates

◆ whichMatrix [2/3]

Enum for the use in Fieldaligned.

Enumerator
einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroForw 

from dg to transformed coordinates

einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroBack 

from transfomred back to dg coordinates

einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroForw 

from dg to transformed coordinates

◆ whichMatrix [3/3]

Enum for the use in Fieldaligned.

Enumerator
einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroForw 

from dg to transformed coordinates

einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroBack 

from transfomred back to dg coordinates

einsPlus 

plus interpolation in next plane

einsPlusT 

transposed plus interpolation in previous plane

einsMinus 

minus interpolation in previous plane

einsMinusT 

transposed minus interpolation in next plane

zeroPlus 

plus interpolation in the current plane

zeroMinus 

minus interpolation in the current plane

zeroPlusT 

transposed plus interpolation in the current plane

zeroMinusT 

transposed minus interpolation in the current plane

zeroForw 

from dg to transformed coordinates

Function Documentation

◆ assign_bc_along_field_1st()

template<class FieldAligned , class container >
void dg::geo::assign_bc_along_field_1st ( const FieldAligned &  fa,
const container &  fm,
const container &  fp,
container &  fmg,
container &  fpg,
dg::bc  bound,
std::array< double, 2 >  boundary_value = {0,0} 
)

Assign boundary conditions along magnetic field lines interpolating a 1st order polynomial (a line)

Template Parameters
FieldAligned
container
Parameters
fa
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
fmgresult (can alias fm)
fpgresult (can alias fp)
boundeither dg::NEU or dg::DIR (rest not implemented yet)
boundary_valuefirst value is for incoming fieldlines, second one for outgoing
Attention
The boundary condition given as a parameter to this function overrules the boundary conditions used in the given dg::geo::Fieldaligned object and the ones implicit in the einsPlus and einsMinus interpolations (Independently of whether the magnetic field was periodified or not). In this way it is possible to apply the same Fieldaligned object to several quantities with different boundary conditions and save quite a bit of memory consumption.

◆ assign_bc_along_field_2nd()

template<class FieldAligned , class container >
void dg::geo::assign_bc_along_field_2nd ( const FieldAligned &  fa,
const container &  fm,
const container &  f,
const container &  fp,
container &  fmg,
container &  fpg,
dg::bc  bound,
std::array< double, 2 >  boundary_value = {0,0} 
)

Assign boundary conditions along magnetic field lines interpolating a 2nd order polynomial.

Call this function before one of the freestanding ds functions to replace the default boundary conditions with along field boundary conditions

This function replaces the values of the plus and minus fields that are outside of the domain with ghost values. These values are constructed by fitting a polynomial through the boundary point, the plus or minus point and the center point. For the exact resulting formula consult the parallel derivative writeup. This is achieved using masks that mark the points where fieldlines intersect the domain boundary and replace the interpolated boundary values.

Template Parameters
FieldAligned
container
Parameters
fathis object will be used to get grid distances and masking regions
fmfieldaligned(einsMinus, f, fm)
f
fpfieldaligned(einsPlus, f, fp)
fmgresulting eMinus field (can alias fm)
fpgresulting ePlus field (can alias fp)
boundeither dg::NEU or dg::DIR (rest not implemented yet)
boundary_valuefirst value is for incoming fieldlines, second one for outgoing
Attention
The boundary condition given as a parameter to this function overrules the boundary conditions used in the given dg::geo::Fieldaligned object and the ones implicit in the einsPlus and einsMinus interpolations (Independently of whether the magnetic field was periodified or not). In this way it is possible to apply the same Fieldaligned object to several quantities with different boundary conditions and save quite a bit of memory consumption.

◆ ds_average()

template<class FieldAligned , class container >
void dg::geo::ds_average ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  fp,
double  beta,
container &  g 
)

Compute average along a fieldline \( g = \alpha \frac{f_{k+1} + f_{k-1}}{2} + \beta g\).

Note
The idea is to use this function on staggered grid implementations. There it can be used to convert a function from one grid to the staggered grid and back
Parameters
fathis object will be used to get grid distances
alphaScalar
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
betaScalar
gcontains result on output (may alias input vectors)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_backward()

template<class FieldAligned , class container >
void dg::geo::ds_backward ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  f,
double  beta,
container &  g 
)

backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)

backward derivative \( g_i = \alpha \frac{v^\varphi}{\Delta\varphi}(f_{i} - f_{i-1}) + \beta g_i \)

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
the vector sizes need to equal the grid size in the constructor
Parameters
fmfieldaligned(einsMinus, f, fm)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_backward2()

template<class FieldAligned , class container >
void dg::geo::ds_backward2 ( const FieldAligned &  fa,
double  alpha,
const container &  fmm,
const container &  fm,
const container &  f,
double  beta,
container &  g 
)

2nd order backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)

backward derivative \( g_i = \alpha \frac{v^\varphi}{2\Delta\varphi}(3f_{i} - 4f_{i-1} + f_{i-2}) + \beta g_i \)

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
the vector sizes need to equal the grid size in the constructor
Parameters
fmfieldaligned(einsMinus, f, fm)
fmmtwice apply fieldaligned(einsMinus, f, fm)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_centered()

template<class FieldAligned , class container >
void dg::geo::ds_centered ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  fp,
double  beta,
container &  g 
)

centered derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)

The formula used is \( g_i = \alpha \frac{v^\varphi}{2\Delta\varphi}(f_{i+1} - f_{i-1}) + \beta g_i \)

Parameters
fathis object will be used to get grid distances
alphaScalar
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
betaScalar
gcontains result on output (may alias input vectors)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_divBackward()

template<class FieldAligned , class container >
void dg::geo::ds_divBackward ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  f,
double  beta,
container &  g 
)

backward derivative \( g = \alpha \nabla \cdot \vec v f + \beta g\)

backward derivative \( g_i = \alpha \frac{1}{\Delta\varphi\sqrt{G_i}}(\sqrt{G_{i}}v^\varphi_{i}f_{i} - \sqrt{G_{i-1}}v^\varphi_{i-1}f_{i-1}) + \beta g_i\)

Parameters
fathis object will be used to get grid distances
alphaScalar
fmfieldaligned(einsMinus, f, fm)
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_divCentered()

template<class FieldAligned , class container >
void dg::geo::ds_divCentered ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  fp,
double  beta,
container &  g 
)

centered derivative \( g = \alpha \nabla \cdot \vec v f + \beta g\)

centered derivative \( g_i = \alpha \frac{1}{2\Delta\varphi\sqrt{G_i}}(\sqrt{G_{i+1}}v^\varphi_{i+1}f_{i+1} - \sqrt{G_{i-1}}v^\varphi_{i-1}f_{i-1}) + \beta g_i\)

Parameters
fathis object will be used to get grid distances
alphaScalar
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
betaScalar
gcontains result on output (may alias input vectors)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_divForward()

template<class FieldAligned , class container >
void dg::geo::ds_divForward ( const FieldAligned &  fa,
double  alpha,
const container &  f,
const container &  fp,
double  beta,
container &  g 
)

forward derivative \( g = \alpha \nabla \cdot \vec v f + \beta g\)

forward derivative \( g_i = \alpha \frac{1}{\Delta\varphi\sqrt{G_i}}(\sqrt{G_{i+1}}v^\varphi_{i+1}f_{i+1} - \sqrt{G_{i}}v^\varphi_{i}f_{i}) + \beta g_i\)

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
fpfieldaligned(einsPlus, f, fp)
betaScalar
gcontains result on output (may alias input vectors)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_forward()

template<class FieldAligned , class container >
void dg::geo::ds_forward ( const FieldAligned &  fa,
double  alpha,
const container &  f,
const container &  fp,
double  beta,
container &  g 
)

forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)

forward derivative \( g_i = \alpha \frac{v^\varphi}{\Delta\varphi}(f_{i+1} - f_{i}) + \beta g_i\)

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
the vector sizes need to equal the grid size in the constructor
Parameters
fpfieldaligned(einsPlus, f, fp)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_forward2()

template<class FieldAligned , class container >
void dg::geo::ds_forward2 ( const FieldAligned &  fa,
double  alpha,
const container &  f,
const container &  fp,
const container &  fpp,
double  beta,
container &  g 
)

2nd order forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)

forward derivative \( g_i = \alpha \frac{v^\varphi}{2\Delta\varphi}(-f_{i+2} + 4f_{i+1} - 3f_{i}) + \beta g_i\)

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
the vector sizes need to equal the grid size in the constructor
Parameters
fpfieldaligned(einsPlus, f, fp)
fpptwice apply fieldaligned(einsPlus, f, fp)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ ds_slope()

template<class FieldAligned , class container >
void dg::geo::ds_slope ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  fp,
double  beta,
container &  g 
)

Compute simple slope along a fieldline \( g = \alpha v^\varphi\frac{f_{k+1} - f_{k-1}}{2\Delta\varphi} + \beta g\).

Note
The idea is to use this function on staggered grid implementations. There it can be used to compute the gradient from one grid onto the staggered grid and vice versa
Parameters
fathis object will be used to get grid distances
alphaScalar
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
betaScalar
gcontains result on output (may alias input vectors)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp
See also
Does exactly the same as ds_centered

◆ dss_centered()

template<class FieldAligned , class container >
void dg::geo::dss_centered ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  f,
const container &  fp,
double  beta,
container &  g 
)

Centered derivative \( g = \alpha (\vec v\cdot \nabla)^2 f + \beta g \).

The formula used is

\[ \nabla_\parallel^2 f = 2\left(\frac{f^+}{h_z^+ h_z^0} - \frac{f^0}{h_z^- h_z^+} + \frac{f^-}{h_z^-h_z^0}\right) \]

which is the second derivative of a 2nd order polynomial fitted through the plus, minus and centre points the boundary conditions are implemented by mirroring points perpendicular to the boundary, which has some drawbacks as to the numerical stability and toroidal resolution.

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
the vector sizes need to equal the grid size in the constructor
Parameters
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ dssd_centered()

template<class FieldAligned , class container >
void dg::geo::dssd_centered ( const FieldAligned &  fa,
double  alpha,
const container &  fm,
const container &  f,
const container &  fp,
double  beta,
container &  g 
)

Centered derivative \( g = \alpha \nabla\cdot(\vec v \vec v\cdot \nabla) f + \beta g \).

The formula used is

\[ \Delta_\parallel f = \nabla\cdot (\vec v \nabla_\parallel f )\]

Parameters
fathis object will be used to get grid distances
alphaScalar
fThe vector to derive
betaScalar
gcontains result on output (may alias input vectors)
Note
the vector sizes need to equal the grid size in the constructor
Parameters
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
Note
This function computes the same as the corresponding member function of dg::geo::DS but you have to compute the einsPlus and einsMinus interpolations from dg::geo::Fieldaligned yourself. The reasoning for this function is that you can re-use the latter interpolations if you compute for example both first and second derivative of a function or even if you compute it for difference boundary conditions using dg::geo::assign_bc_along_field_2nd, dg::geo::assign_bc_along_field_1st or dg::geo::swap_bc_perp

◆ fieldaligned_evaluate() [1/2]

template<class BinaryOp , class UnaryOp >
thrust::host_vector< double > dg::geo::fieldaligned_evaluate ( const aProductGeometry3d grid,
const CylindricalVectorLvl0 vec,
const BinaryOp &  binary,
const UnaryOp &  unary,
unsigned  p0,
unsigned  rounds,
double  eps = 1e-5 
)

Evaluate a 2d functor and transform to all planes along the fieldlines

The algorithm does the equivalent of the following:

  • Evaluate the given BinaryOp on a 2d plane
  • integrate fieldlines \( r N_z \Delta\varphi\) in both directions where \( N_z\) is the number of planes in the global 3d grid and \( r\) is the number of rounds. Then evaluate BinaryOp at the resulting points.
  • Scale the transformations with \( u ( \pm (iN_z + j)\Delta\varphi) \), where u is the given UnarayOp, i in [0..r] is the round index and j in [0..Nz] is the plane index and \(\Delta\varphi\) is the angular distance given in the constructor (can be different from the actual grid distance hz!).
  • Sum all transformations with the same plane index j , where the minus transformations get the inverted index \( N_z - j\).
  • Shift the index by \( p_0\)
Attention
This version of the algorithm is more exact but much slower than the evaluate member contained in dg::geo::Fieldaligned
Template Parameters
BinaryOpBinary Functor
UnaryOpUnary Functor
Parameters
gridThe grid on which to integrate fieldlines.
vecThe vector field to integrate. Note that you can control how the boundary conditions are represented by changing vec outside the grid domain using e.g. the periodify function.
binaryFunctor to evaluate in x-y
unaryFunctor to evaluate in z
Note
unary is evaluated such that p0 corresponds to z=0, p0+1 corresponds to z=hz, p0-1 to z=-hz, ...
Parameters
p0The index of the plane to start
roundsThe number of rounds r to follow a fieldline; can be zero, then the fieldlines are only followed within the current box ( no periodicity)
epsThe accuracy of the fieldline integrator
Returns
3d vector

◆ fieldaligned_evaluate() [2/2]

template<class BinaryOp , class UnaryOp >
MPI_Vector< thrust::host_vector< double > > dg::geo::fieldaligned_evaluate ( const aProductMPIGeometry3d grid,
const CylindricalVectorLvl0 vec,
const BinaryOp &  binary,
const UnaryOp &  unary,
unsigned  p0,
unsigned  rounds,
double  eps = 1e-5 
)

Evaluate a 2d functor and transform to all planes along the fieldlines (MPI Version)

The algorithm does the equivalent of the following:

  • Evaluate the given BinaryOp on a 2d plane
  • integrate fieldlines \( r N_z \Delta\varphi\) in both directions where \( N_z\) is the number of planes in the global 3d grid and \( r\) is the number of rounds. Then evaluate BinaryOp at the resulting points.
  • Scale the transformations with \( u ( \pm (iN_z + j)\Delta\varphi) \), where u is the given UnarayOp, i in [0..r] is the round index and j in [0..Nz] is the plane index and \(\Delta\varphi\) is the angular distance given in the constructor (can be different from the actual grid distance hz!).
  • Sum all transformations with the same plane index j , where the minus transformations get the inverted index \( N_z - j\).
  • Shift the index by \( p_0\)
Attention
This version of the algorithm is more exact but much slower than the evaluate member contained in dg::geo::Fieldaligned
Template Parameters
BinaryOpBinary Functor
UnaryOpUnary Functor
Parameters
gridThe grid on which to integrate fieldlines.
vecThe vector field to integrate. Note that you can control how the boundary conditions are represented by changing vec outside the grid domain using e.g. the periodify function.
binaryFunctor to evaluate in x-y
unaryFunctor to evaluate in z
Note
unary is evaluated such that p0 corresponds to z=0, p0+1 corresponds to z=hz, p0-1 to z=-hz, ...
Parameters
p0The index of the plane to start
roundsThe number of rounds r to follow a fieldline; can be zero, then the fieldlines are only followed within the current box ( no periodicity)
epsThe accuracy of the fieldline integrator
Returns
3d vector

◆ swap_bc_perp()

template<class FieldAligned , class container >
void dg::geo::swap_bc_perp ( const FieldAligned &  fa,
const container &  fm,
const container &  fp,
container &  fmg,
container &  fpg 
)

Swap the perp boundary condition.

This function multiplies (-1) to every value that lies outside the box. This effectively swaps the boundary conditions in the Fourier boundary mode, i.e. if NEU was used in Fieldaligned, then now they are DIR and vice versa.

Template Parameters
FieldAligned
container
Parameters
fathis object will be used to get masking regions
fmfieldaligned(einsMinus, f, fm)
fpfieldaligned(einsPlus, f, fp)
fmgresulting eMinus field (can alias fm)
fpgresulting ePlus field (can alias fp)
Note
The motivation for this function is to avoid reconstructing a fieldaligned object since its constructor is quite expensive in runtime and memory. The idea is to construct Fieldaligned with NEU boundary conditions and then use this function to swap them to DIR whenever needed.
The swapping of bc is not exactly (but almost) the same as re-constructing the fieldaligned object in case the support operator is used (mx, my > 1), this is because the swap is performed only on the coarse grid. In all tests the error is negligible so far.