Extension: Geometries
#include "dg/geometries/geometries.h"
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container > Struct Template Reference

Create and manage interpolation matrices from fieldline integration. More...

Public Member Functions

 Fieldaligned ()
 do not allocate memory; no member call except construct is valid More...
 
template<class Limiter >
 Fieldaligned (const dg::geo::TokamakMagneticField &vec, const ProductGeometry &grid, dg::bc bcx=dg::NEU, dg::bc bcy=dg::NEU, Limiter limit=FullLimiter(), double eps=1e-5, unsigned mx=12, unsigned my=12, double deltaPhi=-1, std::string interpolation_method="linear-nearest", bool benchmark=true)
 Construct from a magnetic field and a grid. More...
 
template<class Limiter >
 Fieldaligned (const dg::geo::CylindricalVectorLvl1 &vec, const ProductGeometry &grid, dg::bc bcx=dg::NEU, dg::bc bcy=dg::NEU, Limiter limit=FullLimiter(), double eps=1e-5, unsigned mx=12, unsigned my=12, double deltaPhi=-1, std::string interpolation_method="linear-nearest", bool benchmark=true)
 Construct from a vector field and a grid. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
dg::bc bcx () const
 
dg::bc bcy () const
 
void set_boundaries (dg::bc bcz, double left, double right)
 Set boundary conditions in the limiter region. More...
 
void set_boundaries (dg::bc bcz, const container &left, const container &right)
 Set boundary conditions in the limiter region. More...
 
void set_boundaries (dg::bc bcz, const container &global, double scal_left, double scal_right)
 Set boundary conditions in the limiter region. More...
 
void operator() (enum whichMatrix which, const container &in, container &out)
 Apply the interpolation to three-dimensional vectors. More...
 
double deltaPhi () const
 
const container & hbm () const
 Distance between the planes and the boundary \( (s_{k}-s_{b}^-) \). More...
 
const container & hbp () const
 Distance between the planes \( (s_b^+-s_{k}) \). More...
 
const container & sqrtG () const
 Volume form (including weights) \( \sqrt{G}_{k} \). More...
 
const container & sqrtGm () const
 Volume form on minus plane (including weights) \( \sqrt{G}_{k-1} \). More...
 
const container & sqrtGp () const
 Volume form on plus plane (including weights) \( \sqrt{G}_{k+1} \). More...
 
const container & bphi () const
 bphi More...
 
const container & bphiM () const
 bphi on minus plane More...
 
const container & bphiP () const
 bphi on plus plane More...
 
const container & bbm () const
 Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction, 0 else. More...
 
const container & bbo () const
 Mask both, 1 if fieldline intersects wall in plus direction and in minus direction, 0 else. More...
 
const container & bbp () const
 Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction, 0 else. More...
 
const ProductGeometry & grid () const
 Grid used for construction. More...
 
container interpolate_from_coarse_grid (const ProductGeometry &grid_coarse, const container &coarse)
 Interpolate along fieldlines from a coarse to a fine grid in phi. More...
 
void integrate_between_coarse_grid (const ProductGeometry &grid_coarse, const container &coarse, container &out)
 Integrate a 2d function on the fine grid. More...
 
template<class BinaryOp , class UnaryOp >
container evaluate (BinaryOp binary, UnaryOp unary, unsigned p0, unsigned rounds) const
 Evaluate a 2d functor and transform to all planes along the fieldline More...
 
std::string method () const
 Return the interpolation_method string given in the constructor. More...
 
 Fieldaligned ()
 do not allocate memory; no member call except construct is valid More...
 
template<class Limiter >
 Fieldaligned (const dg::geo::TokamakMagneticField &vec, const ProductGeometry &grid, dg::bc bcx=dg::NEU, dg::bc bcy=dg::NEU, Limiter limit=FullLimiter(), double eps=1e-5, unsigned mx=10, unsigned my=10, double deltaPhi=-1, std::string interpolation_method="dg", bool benchmark=true)
 Construct from a magnetic field and a grid. More...
 
template<class Limiter >
 Fieldaligned (const dg::geo::CylindricalVectorLvl1 &vec, const ProductGeometry &grid, dg::bc bcx=dg::NEU, dg::bc bcy=dg::NEU, Limiter limit=FullLimiter(), double eps=1e-5, unsigned mx=10, unsigned my=10, double deltaPhi=-1, std::string interpolation_method="dg", bool benchmark=true)
 Construct from a vector field and a grid. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
dg::bc bcx () const
 
dg::bc bcy () const
 
void set_boundaries (dg::bc bcz, double left, double right)
 Set boundary conditions in the limiter region. More...
 
void set_boundaries (dg::bc bcz, const container &left, const container &right)
 Set boundary conditions in the limiter region. More...
 
void set_boundaries (dg::bc bcz, const container &global, double scal_left, double scal_right)
 Set boundary conditions in the limiter region. More...
 
void operator() (enum whichMatrix which, const container &in, container &out)
 Apply the interpolation to three-dimensional vectors. More...
 
double deltaPhi () const
 
const container & hbm () const
 Distance between the planes and the boundary \( (s_{k}-s_{b}^-) \). More...
 
const container & hbp () const
 Distance between the planes \( (s_b^+-s_{k}) \). More...
 
const container & sqrtG () const
 Volume form (including weights) \( \sqrt{G}_{k} \). More...
 
const container & sqrtGm () const
 Volume form on minus plane (including weights) \( \sqrt{G}_{k-1} \). More...
 
const container & sqrtGp () const
 Volume form on plus plane (including weights) \( \sqrt{G}_{k+1} \). More...
 
const container & bphi () const
 bphi More...
 
const container & bphiM () const
 bphi on minus plane More...
 
const container & bphiP () const
 bphi on plus plane More...
 
const container & bbm () const
 Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction, 0 else. More...
 
const container & bbo () const
 Mask both, 1 if fieldline intersects wall in plus direction and in minus direction, 0 else. More...
 
const container & bbp () const
 Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction, 0 else. More...
 
const ProductGeometry & grid () const
 Grid used for construction. More...
 
container interpolate_from_coarse_grid (const ProductGeometry &grid_coarse, const container &coarse)
 Interpolate along fieldlines from a coarse to a fine grid in phi. More...
 
void integrate_between_coarse_grid (const ProductGeometry &grid_coarse, const container &coarse, container &out)
 Integrate a 2d function on the fine grid. More...
 
template<class BinaryOp , class UnaryOp >
container evaluate (BinaryOp binary, UnaryOp unary, unsigned p0, unsigned rounds) const
 Evaluate a 2d functor and transform to all planes along the fieldline More...
 
std::string method () const
 
 Fieldaligned ()
 do not allocate memory; no member call except construct is valid More...
 
template<class Limiter >
 Fieldaligned (const dg::geo::TokamakMagneticField &vec, const ProductGeometry &grid, dg::bc bcx=dg::NEU, dg::bc bcy=dg::NEU, Limiter limit=FullLimiter(), double eps=1e-5, unsigned mx=10, unsigned my=10, double deltaPhi=-1, std::string interpolation_method="dg", bool benchmark=true)
 Construct from a magnetic field and a grid. More...
 
template<class Limiter >
 Fieldaligned (const dg::geo::CylindricalVectorLvl1 &vec, const ProductGeometry &grid, dg::bc bcx=dg::NEU, dg::bc bcy=dg::NEU, Limiter limit=FullLimiter(), double eps=1e-5, unsigned mx=10, unsigned my=10, double deltaPhi=-1, std::string interpolation_method="dg", bool benchmark=true)
 Construct from a vector field and a grid. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
dg::bc bcx () const
 
dg::bc bcy () const
 
void set_boundaries (dg::bc bcz, double left, double right)
 Set boundary conditions in the limiter region. More...
 
void set_boundaries (dg::bc bcz, const container &left, const container &right)
 Set boundary conditions in the limiter region. More...
 
void set_boundaries (dg::bc bcz, const container &global, double scal_left, double scal_right)
 Set boundary conditions in the limiter region. More...
 
void operator() (enum whichMatrix which, const container &in, container &out)
 Apply the interpolation to three-dimensional vectors. More...
 
double deltaPhi () const
 
const container & hbm () const
 Distance between the planes and the boundary \( (s_{k}-s_{b}^-) \). More...
 
const container & hbp () const
 Distance between the planes \( (s_b^+-s_{k}) \). More...
 
const container & sqrtG () const
 Volume form (including weights) \( \sqrt{G}_{k} \). More...
 
const container & sqrtGm () const
 Volume form on minus plane (including weights) \( \sqrt{G}_{k-1} \). More...
 
const container & sqrtGp () const
 Volume form on plus plane (including weights) \( \sqrt{G}_{k+1} \). More...
 
const container & bphi () const
 bphi More...
 
const container & bphiM () const
 bphi on minus plane More...
 
const container & bphiP () const
 bphi on plus plane More...
 
const container & bbm () const
 Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction, 0 else. More...
 
const container & bbo () const
 Mask both, 1 if fieldline intersects wall in plus direction and in minus direction, 0 else. More...
 
const container & bbp () const
 Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction, 0 else. More...
 
const ProductGeometry & grid () const
 Grid used for construction. More...
 
container interpolate_from_coarse_grid (const ProductGeometry &grid_coarse, const container &coarse)
 Interpolate along fieldlines from a coarse to a fine grid in phi. More...
 
void integrate_between_coarse_grid (const ProductGeometry &grid_coarse, const container &coarse, container &out)
 Integrate a 2d function on the fine grid. More...
 
template<class BinaryOp , class UnaryOp >
container evaluate (BinaryOp binary, UnaryOp unary, unsigned p0, unsigned rounds) const
 Evaluate a 2d functor and transform to all planes along the fieldline More...
 
std::string method () const
 

Detailed Description

template<class ProductGeometry, class IMatrix, class container>
struct dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >

Create and manage interpolation matrices from fieldline integration.

const dg::CylindricalGrid3d g3d( R_0-a, R_0+a, -a, a, 0, 2.*M_PI, n, Nx, Ny, Nz, dg::NEU, dg::NEU, dg::PER);
//create magnetic field
auto bhat = dg::geo::createBHat(mag);
//create Fieldaligned object and construct DS from it
bhat, g3d, dg::NEU, dg::NEU, dg::geo::NoLimiter(), 1e-8, mx[0], mx[1],
-1, method);
ds( dsFA );
static dg::geo::TokamakMagneticField createCircularField(double R0, double I0, double a=1, double b=1)
Definition: toroidal.h:136
CylindricalVectorLvl1 createBHat(const TokamakMagneticField &mag)
Contravariant components of the magnetic unit vector field and its Divergence and derivative in cylin...
Definition: magnetic_field.h:931
Class for the evaluation of parallel derivatives.
Definition: ds.h:349
Create and manage interpolation matrices from fieldline integration.
Definition: fieldaligned.h:433
std::string method() const
Return the interpolation_method string given in the constructor.
Definition: fieldaligned.h:671
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
Template Parameters
ProductGeometrymust be either dg::aProductGeometry3d or dg::aProductMPIGeometry3d or any derivative
IMatrixThe type of the interpolation matrix
containerThe container-class on which the interpolation matrix operates on
See also
The pdf parallel derivative writeup

Constructor & Destructor Documentation

◆ Fieldaligned() [1/9]

template<class ProductGeometry , class IMatrix , class container >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( )
inline

do not allocate memory; no member call except construct is valid

◆ Fieldaligned() [2/9]

template<class ProductGeometry , class IMatrix , class container >
template<class Limiter >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( const dg::geo::TokamakMagneticField vec,
const ProductGeometry &  grid,
dg::bc  bcx = dg::NEU,
dg::bc  bcy = dg::NEU,
Limiter  limit = FullLimiter(),
double  eps = 1e-5,
unsigned  mx = 12,
unsigned  my = 12,
double  deltaPhi = -1,
std::string  interpolation_method = "linear-nearest",
bool  benchmark = true 
)
inline

Construct from a magnetic field and a grid.

Template Parameters
LimiterClass that can be evaluated on a 2d grid, returns 1 if there is a limiter and 0 if there isn't. If a field line crosses the limiter in the plane \( \phi=0\) then the limiter boundary conditions apply.
Parameters
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.
gridThe grid on which to integrate fieldlines.
bcxThis parameter is passed on to dg::create::interpolation(const thrust::host_vector<real_type>&,const thrust::host_vector<real_type>&,const aRealTopology2d<real_type>&,dg::bc,dg::bc,std::string) (see there for more details) function and deterimens what happens when the endpoint of the fieldline integration leaves the domain boundaries of grid. Note that bcx and grid.bcx() have to be either both periodic or both not periodic.
bcyanalogous to bcx, applies to y direction
limitInstance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere)
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 12 is a good start) If the projection method (parsed from interpolation_method) is not "dg" then mx must be a multiple of nx
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodparsed according to
interpolation_method interpolation projection
"dg" "dg" "dg"
"linear" "linear" "dg"
"cubic" "cubic" "dg"
"nearest" "nearest" "dg"
"linear-nearest" (##) "linear" "nearest"
"cubic-nearest" "cubic" "nearest"
"nearest-nearest" "nearest" "nearest"
"dg-linear" "dg" "linear"
"linear-linear" "linear" "linear"
"cubic-linear" "cubic" "linear"
"nearest-linear" "nearest" "linear"

(##) Use "linear-nearest" if in doubt. The table yields one parameter passed to create::interpolation (from the given grid to the fine grid) and one parameter to create::projection (from the fine grid to the given grid)

Parameters
benchmarkIf true write construction timings to std::cout
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 10 is a good start)
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodSeveral interpolation methods are available: dg uses the native dG interpolation scheme given by the grid, nearest searches for the nearest point and copies its value, linear searches for the two (in 2d four, etc.) closest points and linearly interpolates their values, cubic searches for the four (in 2d 16, etc) closest points and interpolates a cubic polynomial
benchmarkIf true write construction timings to std::cout

◆ Fieldaligned() [3/9]

template<class ProductGeometry , class IMatrix , class container >
template<class Limiter >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( const dg::geo::CylindricalVectorLvl1 vec,
const ProductGeometry &  grid,
dg::bc  bcx = dg::NEU,
dg::bc  bcy = dg::NEU,
Limiter  limit = FullLimiter(),
double  eps = 1e-5,
unsigned  mx = 12,
unsigned  my = 12,
double  deltaPhi = -1,
std::string  interpolation_method = "linear-nearest",
bool  benchmark = true 
)

Construct from a vector field and a grid.

Template Parameters
LimiterClass that can be evaluated on a 2d grid, returns 1 if there is a limiter and 0 if there isn't. If a field line crosses the limiter in the plane \( \phi=0\) then the limiter boundary conditions apply.
Parameters
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.
gridThe grid on which to integrate fieldlines.
bcxThis parameter is passed on to dg::create::interpolation(const thrust::host_vector<real_type>&,const thrust::host_vector<real_type>&,const aRealTopology2d<real_type>&,dg::bc,dg::bc,std::string) (see there for more details) function and deterimens what happens when the endpoint of the fieldline integration leaves the domain boundaries of grid. Note that bcx and grid.bcx() have to be either both periodic or both not periodic.
bcyanalogous to bcx, applies to y direction
limitInstance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere)
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 12 is a good start) If the projection method (parsed from interpolation_method) is not "dg" then mx must be a multiple of nx
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodparsed according to
interpolation_method interpolation projection
"dg" "dg" "dg"
"linear" "linear" "dg"
"cubic" "cubic" "dg"
"nearest" "nearest" "dg"
"linear-nearest" (##) "linear" "nearest"
"cubic-nearest" "cubic" "nearest"
"nearest-nearest" "nearest" "nearest"
"dg-linear" "dg" "linear"
"linear-linear" "linear" "linear"
"cubic-linear" "cubic" "linear"
"nearest-linear" "nearest" "linear"

(##) Use "linear-nearest" if in doubt. The table yields one parameter passed to create::interpolation (from the given grid to the fine grid) and one parameter to create::projection (from the fine grid to the given grid)

Parameters
benchmarkIf true write construction timings to std::cout
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 10 is a good start)
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodSeveral interpolation methods are available: dg uses the native dG interpolation scheme given by the grid, nearest searches for the nearest point and copies its value, linear searches for the two (in 2d four, etc.) closest points and linearly interpolates their values, cubic searches for the four (in 2d 16, etc) closest points and interpolates a cubic polynomial
benchmarkIf true write construction timings to std::cout

◆ Fieldaligned() [4/9]

template<class ProductGeometry , class IMatrix , class container >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( )
inline

do not allocate memory; no member call except construct is valid

◆ Fieldaligned() [5/9]

template<class ProductGeometry , class IMatrix , class container >
template<class Limiter >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( const dg::geo::TokamakMagneticField vec,
const ProductGeometry &  grid,
dg::bc  bcx = dg::NEU,
dg::bc  bcy = dg::NEU,
Limiter  limit = FullLimiter(),
double  eps = 1e-5,
unsigned  mx = 10,
unsigned  my = 10,
double  deltaPhi = -1,
std::string  interpolation_method = "dg",
bool  benchmark = true 
)
inline

Construct from a magnetic field and a grid.

Template Parameters
LimiterClass that can be evaluated on a 2d grid, returns 1 if there is a limiter and 0 if there isn't. If a field line crosses the limiter in the plane \( \phi=0\) then the limiter boundary conditions apply.
Parameters
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.
gridThe grid on which to integrate fieldlines.
bcxThis parameter is passed on to dg::create::interpolation(const thrust::host_vector<real_type>&,const thrust::host_vector<real_type>&,const aRealTopology2d<real_type>&,dg::bc,dg::bc,std::string) (see there for more details) function and deterimens what happens when the endpoint of the fieldline integration leaves the domain boundaries of grid. Note that bcx and grid.bcx() have to be either both periodic or both not periodic.
bcyanalogous to bcx, applies to y direction
limitInstance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere)
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 12 is a good start) If the projection method (parsed from interpolation_method) is not "dg" then mx must be a multiple of nx
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodparsed according to
interpolation_method interpolation projection
"dg" "dg" "dg"
"linear" "linear" "dg"
"cubic" "cubic" "dg"
"nearest" "nearest" "dg"
"linear-nearest" (##) "linear" "nearest"
"cubic-nearest" "cubic" "nearest"
"nearest-nearest" "nearest" "nearest"
"dg-linear" "dg" "linear"
"linear-linear" "linear" "linear"
"cubic-linear" "cubic" "linear"
"nearest-linear" "nearest" "linear"

(##) Use "linear-nearest" if in doubt. The table yields one parameter passed to create::interpolation (from the given grid to the fine grid) and one parameter to create::projection (from the fine grid to the given grid)

Parameters
benchmarkIf true write construction timings to std::cout
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 10 is a good start)
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodSeveral interpolation methods are available: dg uses the native dG interpolation scheme given by the grid, nearest searches for the nearest point and copies its value, linear searches for the two (in 2d four, etc.) closest points and linearly interpolates their values, cubic searches for the four (in 2d 16, etc) closest points and interpolates a cubic polynomial
benchmarkIf true write construction timings to std::cout

◆ Fieldaligned() [6/9]

template<class ProductGeometry , class IMatrix , class container >
template<class Limiter >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( const dg::geo::CylindricalVectorLvl1 vec,
const ProductGeometry &  grid,
dg::bc  bcx = dg::NEU,
dg::bc  bcy = dg::NEU,
Limiter  limit = FullLimiter(),
double  eps = 1e-5,
unsigned  mx = 10,
unsigned  my = 10,
double  deltaPhi = -1,
std::string  interpolation_method = "dg",
bool  benchmark = true 
)

Construct from a vector field and a grid.

Template Parameters
LimiterClass that can be evaluated on a 2d grid, returns 1 if there is a limiter and 0 if there isn't. If a field line crosses the limiter in the plane \( \phi=0\) then the limiter boundary conditions apply.
Parameters
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.
gridThe grid on which to integrate fieldlines.
bcxThis parameter is passed on to dg::create::interpolation(const thrust::host_vector<real_type>&,const thrust::host_vector<real_type>&,const aRealTopology2d<real_type>&,dg::bc,dg::bc,std::string) (see there for more details) function and deterimens what happens when the endpoint of the fieldline integration leaves the domain boundaries of grid. Note that bcx and grid.bcx() have to be either both periodic or both not periodic.
bcyanalogous to bcx, applies to y direction
limitInstance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere)
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 12 is a good start) If the projection method (parsed from interpolation_method) is not "dg" then mx must be a multiple of nx
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodparsed according to
interpolation_method interpolation projection
"dg" "dg" "dg"
"linear" "linear" "dg"
"cubic" "cubic" "dg"
"nearest" "nearest" "dg"
"linear-nearest" (##) "linear" "nearest"
"cubic-nearest" "cubic" "nearest"
"nearest-nearest" "nearest" "nearest"
"dg-linear" "dg" "linear"
"linear-linear" "linear" "linear"
"cubic-linear" "cubic" "linear"
"nearest-linear" "nearest" "linear"

(##) Use "linear-nearest" if in doubt. The table yields one parameter passed to create::interpolation (from the given grid to the fine grid) and one parameter to create::projection (from the fine grid to the given grid)

Parameters
benchmarkIf true write construction timings to std::cout
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 10 is a good start)
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodSeveral interpolation methods are available: dg uses the native dG interpolation scheme given by the grid, nearest searches for the nearest point and copies its value, linear searches for the two (in 2d four, etc.) closest points and linearly interpolates their values, cubic searches for the four (in 2d 16, etc) closest points and interpolates a cubic polynomial
benchmarkIf true write construction timings to std::cout

◆ Fieldaligned() [7/9]

template<class ProductGeometry , class IMatrix , class container >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( )
inline

do not allocate memory; no member call except construct is valid

◆ Fieldaligned() [8/9]

template<class ProductGeometry , class IMatrix , class container >
template<class Limiter >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( const dg::geo::TokamakMagneticField vec,
const ProductGeometry &  grid,
dg::bc  bcx = dg::NEU,
dg::bc  bcy = dg::NEU,
Limiter  limit = FullLimiter(),
double  eps = 1e-5,
unsigned  mx = 10,
unsigned  my = 10,
double  deltaPhi = -1,
std::string  interpolation_method = "dg",
bool  benchmark = true 
)
inline

Construct from a magnetic field and a grid.

Template Parameters
LimiterClass that can be evaluated on a 2d grid, returns 1 if there is a limiter and 0 if there isn't. If a field line crosses the limiter in the plane \( \phi=0\) then the limiter boundary conditions apply.
Parameters
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.
gridThe grid on which to integrate fieldlines.
bcxThis parameter is passed on to dg::create::interpolation(const thrust::host_vector<real_type>&,const thrust::host_vector<real_type>&,const aRealTopology2d<real_type>&,dg::bc,dg::bc,std::string) (see there for more details) function and deterimens what happens when the endpoint of the fieldline integration leaves the domain boundaries of grid. Note that bcx and grid.bcx() have to be either both periodic or both not periodic.
bcyanalogous to bcx, applies to y direction
limitInstance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere)
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 12 is a good start) If the projection method (parsed from interpolation_method) is not "dg" then mx must be a multiple of nx
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodparsed according to
interpolation_method interpolation projection
"dg" "dg" "dg"
"linear" "linear" "dg"
"cubic" "cubic" "dg"
"nearest" "nearest" "dg"
"linear-nearest" (##) "linear" "nearest"
"cubic-nearest" "cubic" "nearest"
"nearest-nearest" "nearest" "nearest"
"dg-linear" "dg" "linear"
"linear-linear" "linear" "linear"
"cubic-linear" "cubic" "linear"
"nearest-linear" "nearest" "linear"

(##) Use "linear-nearest" if in doubt. The table yields one parameter passed to create::interpolation (from the given grid to the fine grid) and one parameter to create::projection (from the fine grid to the given grid)

Parameters
benchmarkIf true write construction timings to std::cout
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 10 is a good start)
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodSeveral interpolation methods are available: dg uses the native dG interpolation scheme given by the grid, nearest searches for the nearest point and copies its value, linear searches for the two (in 2d four, etc.) closest points and linearly interpolates their values, cubic searches for the four (in 2d 16, etc) closest points and interpolates a cubic polynomial
benchmarkIf true write construction timings to std::cout

◆ Fieldaligned() [9/9]

template<class ProductGeometry , class IMatrix , class container >
template<class Limiter >
dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::Fieldaligned ( const dg::geo::CylindricalVectorLvl1 vec,
const ProductGeometry &  grid,
dg::bc  bcx = dg::NEU,
dg::bc  bcy = dg::NEU,
Limiter  limit = FullLimiter(),
double  eps = 1e-5,
unsigned  mx = 10,
unsigned  my = 10,
double  deltaPhi = -1,
std::string  interpolation_method = "dg",
bool  benchmark = true 
)

Construct from a vector field and a grid.

Template Parameters
LimiterClass that can be evaluated on a 2d grid, returns 1 if there is a limiter and 0 if there isn't. If a field line crosses the limiter in the plane \( \phi=0\) then the limiter boundary conditions apply.
Parameters
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.
gridThe grid on which to integrate fieldlines.
bcxThis parameter is passed on to dg::create::interpolation(const thrust::host_vector<real_type>&,const thrust::host_vector<real_type>&,const aRealTopology2d<real_type>&,dg::bc,dg::bc,std::string) (see there for more details) function and deterimens what happens when the endpoint of the fieldline integration leaves the domain boundaries of grid. Note that bcx and grid.bcx() have to be either both periodic or both not periodic.
bcyanalogous to bcx, applies to y direction
limitInstance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere)
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 12 is a good start) If the projection method (parsed from interpolation_method) is not "dg" then mx must be a multiple of nx
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodparsed according to
interpolation_method interpolation projection
"dg" "dg" "dg"
"linear" "linear" "dg"
"cubic" "cubic" "dg"
"nearest" "nearest" "dg"
"linear-nearest" (##) "linear" "nearest"
"cubic-nearest" "cubic" "nearest"
"nearest-nearest" "nearest" "nearest"
"dg-linear" "dg" "linear"
"linear-linear" "linear" "linear"
"cubic-linear" "cubic" "linear"
"nearest-linear" "nearest" "linear"

(##) Use "linear-nearest" if in doubt. The table yields one parameter passed to create::interpolation (from the given grid to the fine grid) and one parameter to create::projection (from the fine grid to the given grid)

Parameters
benchmarkIf true write construction timings to std::cout
epsDesired accuracy of the fieldline integrator
mxrefinement factor in X of the fine grid relative to grid (Set to 1, if the x-component of vec vanishes, else as high as possible, 10 is a good start)
myanalogous to mx, applies to y direction
deltaPhiThe angular distance that the fieldline-integrator will integrate. Per default this is the distance between planes, which is chosen automatically if you set it <=0, i.e. if deltaPhi <=0 then it will be overwritten to deltaPhi = grid.hz(). Sometimes however, you may want to set it to a different value from grid.hz() for example for 2d problems or for a staggered grid.
Note
deltaPhi influences the interpolation matrices and the parallel modulation in the evaluate() member function.
If there is a limiter, the boundary condition on the first/last plane is set by the grid.bcz() variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic.
Parameters
interpolation_methodSeveral interpolation methods are available: dg uses the native dG interpolation scheme given by the grid, nearest searches for the nearest point and copies its value, linear searches for the two (in 2d four, etc.) closest points and linearly interpolates their values, cubic searches for the four (in 2d 16, etc) closest points and interpolates a cubic polynomial
benchmarkIf true write construction timings to std::cout

Member Function Documentation

◆ bbm() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbm ( ) const
inline

Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction, 0 else.

Returns
three-dimensional vector

◆ bbm() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbm ( ) const
inline

Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction, 0 else.

Returns
three-dimensional vector

◆ bbm() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbm ( ) const
inline

Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction, 0 else.

Returns
three-dimensional vector

◆ bbo() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbo ( ) const
inline

Mask both, 1 if fieldline intersects wall in plus direction and in minus direction, 0 else.

Returns
three-dimensional vector

◆ bbo() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbo ( ) const
inline

Mask both, 1 if fieldline intersects wall in plus direction and in minus direction, 0 else.

Returns
three-dimensional vector

◆ bbo() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbo ( ) const
inline

Mask both, 1 if fieldline intersects wall in plus direction and in minus direction, 0 else.

Returns
three-dimensional vector

◆ bbp() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbp ( ) const
inline

Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction, 0 else.

Returns
three-dimensional vector

◆ bbp() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbp ( ) const
inline

Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction, 0 else.

Returns
three-dimensional vector

◆ bbp() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bbp ( ) const
inline

Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction, 0 else.

Returns
three-dimensional vector

◆ bcx() [1/3]

template<class ProductGeometry , class IMatrix , class container >
dg::bc dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bcx ( ) const
inline

◆ bcx() [2/3]

template<class ProductGeometry , class IMatrix , class container >
dg::bc dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bcx ( ) const
inline

◆ bcx() [3/3]

template<class ProductGeometry , class IMatrix , class container >
dg::bc dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bcx ( ) const
inline

◆ bcy() [1/3]

template<class ProductGeometry , class IMatrix , class container >
dg::bc dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bcy ( ) const
inline

◆ bcy() [2/3]

template<class ProductGeometry , class IMatrix , class container >
dg::bc dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bcy ( ) const
inline

◆ bcy() [3/3]

template<class ProductGeometry , class IMatrix , class container >
dg::bc dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bcy ( ) const
inline

◆ bphi() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphi ( ) const
inline

bphi

Returns
three-dimensional vector

◆ bphi() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphi ( ) const
inline

bphi

Returns
three-dimensional vector

◆ bphi() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphi ( ) const
inline

bphi

Returns
three-dimensional vector

◆ bphiM() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphiM ( ) const
inline

bphi on minus plane

Returns
three-dimensional vector

◆ bphiM() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphiM ( ) const
inline

bphi on minus plane

Returns
three-dimensional vector

◆ bphiM() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphiM ( ) const
inline

bphi on minus plane

Returns
three-dimensional vector

◆ bphiP() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphiP ( ) const
inline

bphi on plus plane

Returns
three-dimensional vector

◆ bphiP() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphiP ( ) const
inline

bphi on plus plane

Returns
three-dimensional vector

◆ bphiP() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::bphiP ( ) const
inline

bphi on plus plane

Returns
three-dimensional vector

◆ construct() [1/3]

template<class ProductGeometry , class IMatrix , class container >
template<class ... Params>
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

◆ construct() [2/3]

template<class ProductGeometry , class IMatrix , class container >
template<class ... Params>
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

◆ construct() [3/3]

template<class ProductGeometry , class IMatrix , class container >
template<class ... Params>
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

◆ deltaPhi() [1/3]

template<class ProductGeometry , class IMatrix , class container >
double dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::deltaPhi ( ) const
inline

◆ deltaPhi() [2/3]

template<class ProductGeometry , class IMatrix , class container >
double dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::deltaPhi ( ) const
inline

◆ deltaPhi() [3/3]

template<class ProductGeometry , class IMatrix , class container >
double dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::deltaPhi ( ) const
inline

◆ evaluate() [1/3]

template<class ProductGeometry , class IMatrix , class container >
template<class BinaryOp , class UnaryOp >
container dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::evaluate ( BinaryOp  binary,
UnaryOp  unary,
unsigned  p0,
unsigned  rounds 
) const

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

The algorithm does the equivalent of the following:

  • Evaluate the given BinaryOp on a 2d plane
  • Apply the plus and minus transformation each \( r N_z\) times where \( N_z\) is the number of planes in the global 3d grid and \( r\) is the number of rounds.
  • 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 less exact but much faster than dg::geo::fieldaligned_evaluate
Template Parameters
BinaryOpBinary Functor
UnaryOpUnary Functor
Parameters
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)
Attention
It is recommended to use mx>1 and my>1 when this function is used, else there might occur some unfavourable summation effects due to the repeated use of transformations especially for low perpendicular resolution.
Returns
3d vector

◆ evaluate() [2/3]

template<class ProductGeometry , class IMatrix , class container >
template<class BinaryOp , class UnaryOp >
container dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::evaluate ( BinaryOp  binary,
UnaryOp  unary,
unsigned  p0,
unsigned  rounds 
) const

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

The algorithm does the equivalent of the following:

  • Evaluate the given BinaryOp on a 2d plane
  • Apply the plus and minus transformation each \( r N_z\) times where \( N_z\) is the number of planes in the global 3d grid and \( r\) is the number of rounds.
  • 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 less exact but much faster than dg::geo::fieldaligned_evaluate
Template Parameters
BinaryOpBinary Functor
UnaryOpUnary Functor
Parameters
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)
Attention
It is recommended to use mx>1 and my>1 when this function is used, else there might occur some unfavourable summation effects due to the repeated use of transformations especially for low perpendicular resolution.
Returns
3d vector

◆ evaluate() [3/3]

template<class ProductGeometry , class IMatrix , class container >
template<class BinaryOp , class UnaryOp >
container dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::evaluate ( BinaryOp  binary,
UnaryOp  unary,
unsigned  p0,
unsigned  rounds 
) const

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

The algorithm does the equivalent of the following:

  • Evaluate the given BinaryOp on a 2d plane
  • Apply the plus and minus transformation each \( r N_z\) times where \( N_z\) is the number of planes in the global 3d grid and \( r\) is the number of rounds.
  • 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 less exact but much faster than dg::geo::fieldaligned_evaluate
Template Parameters
BinaryOpBinary Functor
UnaryOpUnary Functor
Parameters
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)
Attention
It is recommended to use mx>1 and my>1 when this function is used, else there might occur some unfavourable summation effects due to the repeated use of transformations especially for low perpendicular resolution.
Returns
3d vector

◆ grid() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const ProductGeometry & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::grid ( ) const
inline

Grid used for construction.

◆ grid() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const ProductGeometry & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::grid ( ) const
inline

Grid used for construction.

◆ grid() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const ProductGeometry & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::grid ( ) const
inline

Grid used for construction.

◆ hbm() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::hbm ( ) const
inline

Distance between the planes and the boundary \( (s_{k}-s_{b}^-) \).

Returns
three-dimensional vector

◆ hbm() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::hbm ( ) const
inline

Distance between the planes and the boundary \( (s_{k}-s_{b}^-) \).

Returns
three-dimensional vector

◆ hbm() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::hbm ( ) const
inline

Distance between the planes and the boundary \( (s_{k}-s_{b}^-) \).

Returns
three-dimensional vector

◆ hbp() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::hbp ( ) const
inline

Distance between the planes \( (s_b^+-s_{k}) \).

Returns
three-dimensional vector

◆ hbp() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::hbp ( ) const
inline

Distance between the planes \( (s_b^+-s_{k}) \).

Returns
three-dimensional vector

◆ hbp() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::hbp ( ) const
inline

Distance between the planes \( (s_b^+-s_{k}) \).

Returns
three-dimensional vector

◆ integrate_between_coarse_grid() [1/3]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::integrate_between_coarse_grid ( const ProductGeometry &  grid_coarse,
const container &  coarse,
container &  out 
)

Integrate a 2d function on the fine grid.

\[ \frac{1}{\Delta\varphi} \int_{-\Delta\varphi}^{\Delta\varphi}d \varphi w(\varphi) f(R(\varphi), Z(\varphi) \]

Parameters
grid_coarseThe coarse grid (coarse_grid.Nz() must integer divide Nz from input grid). The x and y dimensions must be equal to the input grid.
coarsethe 2d input vector
outthe integral (2d vector, may alias coarse)

◆ integrate_between_coarse_grid() [2/3]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::integrate_between_coarse_grid ( const ProductGeometry &  grid_coarse,
const container &  coarse,
container &  out 
)

Integrate a 2d function on the fine grid.

\[ \frac{1}{\Delta\varphi} \int_{-\Delta\varphi}^{\Delta\varphi}d \varphi w(\varphi) f(R(\varphi), Z(\varphi) \]

Parameters
grid_coarseThe coarse grid (coarse_grid.Nz() must integer divide Nz from input grid). The x and y dimensions must be equal to the input grid.
coarsethe 2d input vector
outthe integral (2d vector)

◆ integrate_between_coarse_grid() [3/3]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::integrate_between_coarse_grid ( const ProductGeometry &  grid_coarse,
const container &  coarse,
container &  out 
)

Integrate a 2d function on the fine grid.

\[ \frac{1}{\Delta\varphi} \int_{-\Delta\varphi}^{\Delta\varphi}d \varphi w(\varphi) f(R(\varphi), Z(\varphi) \]

Parameters
grid_coarseThe coarse grid (coarse_grid.Nz() must integer divide Nz from input grid). The x and y dimensions must be equal to the input grid.
coarsethe 2d input vector
outthe integral (2d vector)

◆ interpolate_from_coarse_grid() [1/3]

template<class ProductGeometry , class IMatrix , class container >
container dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::interpolate_from_coarse_grid ( const ProductGeometry &  grid_coarse,
const container &  coarse 
)

Interpolate along fieldlines from a coarse to a fine grid in phi.

In this function we assume that the Fieldaligned object lives on the fine grid and we now want to interpolate values from a vector living on a coarse grid along the fieldlines onto the fine grid. Here, coarse and fine are with respect to the phi direction. The perpendicular directions need to have the same resolution in both input and output, i.e. there is no interpolation in those directions.

Parameters
grid_coarseThe coarse grid (coarse_grid.Nz() must integer divide Nz from input grid) The x and y dimensions must be equal
coarsethe coarse input vector
Returns
the input interpolated onto the grid given in the constructor
Note
the interpolation weights are taken in the phi distance not the s-distance, which makes the interpolation linear in phi

◆ interpolate_from_coarse_grid() [2/3]

template<class ProductGeometry , class IMatrix , class container >
container dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::interpolate_from_coarse_grid ( const ProductGeometry &  grid_coarse,
const container &  coarse 
)

Interpolate along fieldlines from a coarse to a fine grid in phi.

In this function we assume that the Fieldaligned object lives on the fine grid and we now want to interpolate values from a vector living on a coarse grid along the fieldlines onto the fine grid. Here, coarse and fine are with respect to the phi direction. The perpendicular directions need to have the same resolution in both input and output, i.e. there is no interpolation in those directions.

Parameters
grid_coarseThe coarse grid (coarse_grid.Nz() must integer divide Nz from input grid) The x and y dimensions must be equal
coarsethe coarse input vector
Returns
the input interpolated onto the grid given in the constructor
Note
the interpolation weights are taken in the phi distance not the s-distance, which makes the interpolation linear in phi

◆ interpolate_from_coarse_grid() [3/3]

template<class ProductGeometry , class IMatrix , class container >
container dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::interpolate_from_coarse_grid ( const ProductGeometry &  grid_coarse,
const container &  coarse 
)

Interpolate along fieldlines from a coarse to a fine grid in phi.

In this function we assume that the Fieldaligned object lives on the fine grid and we now want to interpolate values from a vector living on a coarse grid along the fieldlines onto the fine grid. Here, coarse and fine are with respect to the phi direction. The perpendicular directions need to have the same resolution in both input and output, i.e. there is no interpolation in those directions.

Parameters
grid_coarseThe coarse grid (coarse_grid.Nz() must integer divide Nz from input grid) The x and y dimensions must be equal
coarsethe coarse input vector
Returns
the input interpolated onto the grid given in the constructor
Note
the interpolation weights are taken in the phi distance not the s-distance, which makes the interpolation linear in phi

◆ method() [1/3]

template<class ProductGeometry , class IMatrix , class container >
std::string dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::method ( ) const
inline

Return the interpolation_method string given in the constructor.

◆ method() [2/3]

template<class ProductGeometry , class IMatrix , class container >
std::string dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::method ( ) const
inline

◆ method() [3/3]

template<class ProductGeometry , class IMatrix , class container >
std::string dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::method ( ) const
inline

◆ operator()() [1/3]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::operator() ( enum whichMatrix  which,
const container &  in,
container &  out 
)

Apply the interpolation to three-dimensional vectors.

computes \( y = 1^\pm \otimes \mathcal T x\)

Parameters
whichspecify what interpolation should be applied
ininput
outoutput may not equal input

◆ operator()() [2/3]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::operator() ( enum whichMatrix  which,
const container &  in,
container &  out 
)

Apply the interpolation to three-dimensional vectors.

computes \( y = 1^\pm \otimes \mathcal T x\)

Parameters
whichspecify what interpolation should be applied
ininput
outoutput may not equal input

◆ operator()() [3/3]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::operator() ( enum whichMatrix  which,
const container &  in,
container &  out 
)

Apply the interpolation to three-dimensional vectors.

computes \( y = 1^\pm \otimes \mathcal T x\)

Parameters
whichspecify what interpolation should be applied
ininput
outoutput may not equal input

◆ set_boundaries() [1/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
const container &  global,
double  scal_left,
double  scal_right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
global3D vector containing boundary values
scal_leftleft scaling factor
scal_rightright scaling factor

◆ set_boundaries() [2/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
const container &  global,
double  scal_left,
double  scal_right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
global3D vector containing boundary values
scal_leftleft scaling factor
scal_rightright scaling factor

◆ set_boundaries() [3/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
const container &  global,
double  scal_left,
double  scal_right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
global3D vector containing boundary values
scal_leftleft scaling factor
scal_rightright scaling factor

◆ set_boundaries() [4/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
const container &  left,
const container &  right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
leftspatially variable left boundary value (2d size)
rightspatially variable right boundary value (2d size)

◆ set_boundaries() [5/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
const container &  left,
const container &  right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
leftspatially variable left boundary value (2d size)
rightspatially variable right boundary value (2d size)

◆ set_boundaries() [6/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
const container &  left,
const container &  right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
leftspatially variable left boundary value (2d size)
rightspatially variable right boundary value (2d size)

◆ set_boundaries() [7/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
double  left,
double  right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
leftconstant left boundary value
rightconstant right boundary value

◆ set_boundaries() [8/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
double  left,
double  right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
leftconstant left boundary value
rightconstant right boundary value

◆ set_boundaries() [9/9]

template<class ProductGeometry , class IMatrix , class container >
void dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::set_boundaries ( dg::bc  bcz,
double  left,
double  right 
)
inline

Set boundary conditions in the limiter region.

if Dirichlet boundaries are used the left value is the left function value, if Neumann boundaries are used the left value is the left derivative value

Parameters
bczboundary condition
leftconstant left boundary value
rightconstant right boundary value

◆ sqrtG() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtG ( ) const
inline

Volume form (including weights) \( \sqrt{G}_{k} \).

Returns
three-dimensional vector

◆ sqrtG() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtG ( ) const
inline

Volume form (including weights) \( \sqrt{G}_{k} \).

Returns
three-dimensional vector

◆ sqrtG() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtG ( ) const
inline

Volume form (including weights) \( \sqrt{G}_{k} \).

Returns
three-dimensional vector

◆ sqrtGm() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtGm ( ) const
inline

Volume form on minus plane (including weights) \( \sqrt{G}_{k-1} \).

Returns
three-dimensional vector

◆ sqrtGm() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtGm ( ) const
inline

Volume form on minus plane (including weights) \( \sqrt{G}_{k-1} \).

Returns
three-dimensional vector

◆ sqrtGm() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtGm ( ) const
inline

Volume form on minus plane (including weights) \( \sqrt{G}_{k-1} \).

Returns
three-dimensional vector

◆ sqrtGp() [1/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtGp ( ) const
inline

Volume form on plus plane (including weights) \( \sqrt{G}_{k+1} \).

Returns
three-dimensional vector

◆ sqrtGp() [2/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtGp ( ) const
inline

Volume form on plus plane (including weights) \( \sqrt{G}_{k+1} \).

Returns
three-dimensional vector

◆ sqrtGp() [3/3]

template<class ProductGeometry , class IMatrix , class container >
const container & dg::geo::Fieldaligned< ProductGeometry, IMatrix, container >::sqrtGp ( ) const
inline

Volume form on plus plane (including weights) \( \sqrt{G}_{k+1} \).

Returns
three-dimensional vector

The documentation for this struct was generated from the following files: