Extension: Geometries
#include "dg/geometries/geometries.h"
|
Class for the evaluation of parallel derivatives. More...
Public Types | |
typedef dg::geo::Fieldaligned< ProductGeometry, IMatrix, container > | FA |
Public Member Functions | |
DS () | |
No memory allocation; all member calls except construct are invalid. More... | |
template<class Limiter > | |
DS (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) | |
Create the magnetic unit vector field and construct. More... | |
template<class Limiter > | |
DS (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) | |
Use the given vector field to construct. More... | |
DS (FA fieldaligned) | |
Re-construct from a given Fieldaligned object. More... | |
template<class ... Params> | |
void | construct (Params &&...ps) |
Perfect forward parameters to one of the constructors. More... | |
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 | forward (double alpha, const container &f, double beta, container &g) |
forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More... | |
void | forward2 (double alpha, const container &f, double beta, container &g) |
2nd order forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More... | |
void | backward (double alpha, const container &f, double beta, container &g) |
backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More... | |
void | backward2 (double alpha, const container &f, double beta, container &g) |
2nd order backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More... | |
void | centered (double alpha, const container &f, double beta, container &g) |
centered derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\) More... | |
void | centered_bc_along_field (double alpha, const container &f, double beta, container &g, dg::bc bound, std::array< double, 2 > boundary_value={0, 0}) |
Same as dg::geo::ds_centered after dg::geo::ds_assign_bc_along_field_2nd . More... | |
void | backward (const container &f, container &g) |
backward derivative \( g = \vec v \cdot \nabla f \) More... | |
void | forward (const container &f, container &g) |
forward derivative \( g = \vec v \cdot \nabla f \) More... | |
void | centered (const container &f, container &g) |
centered derivative \( g = \vec v \cdot \nabla f \) More... | |
void | divForward (double alpha, const container &f, double beta, container &g) |
forward divergence \( g = \alpha \nabla\cdot(\vec v f) + \beta g\) More... | |
void | divBackward (double alpha, const container &f, double beta, container &g) |
backward divergence \( g = \alpha \nabla\cdot(\vec v f) + \beta g\) More... | |
void | divCentered (double alpha, const container &f, double beta, container &g) |
centered divergence \( g = \alpha \nabla\cdot(\vec v f) + \beta g\) More... | |
void | divForward (const container &f, container &g) |
forward divergence \( g = \nabla\cdot(\vec v f)\) More... | |
void | divBackward (const container &f, container &g) |
backward divergence \( g = \nabla\cdot(\vec v f)\) More... | |
void | divCentered (const container &f, container &g) |
centered divergence \( g = \nabla\cdot(\vec v f)\) More... | |
void | ds (dg::direction dir, const container &f, container &g) |
Discretizes \( g = \vec v\cdot \nabla f \). More... | |
void | ds (dg::direction dir, double alpha, const container &f, double beta, container &g) |
Discretizes \( g = \alpha \vec v\cdot \nabla f + \beta g \). More... | |
void | div (dg::direction dir, const container &f, container &g) |
Discretizes \( g = \nabla \cdot ( \vec v f) \). More... | |
void | div (dg::direction dir, double alpha, const container &f, double beta, container &g) |
Discretizes \( g = \alpha \nabla \cdot( \vec v f) + \beta g \). More... | |
void | symv (const container &f, container &g) |
Discretizes \( g = \nabla\cdot ( \vec v \vec v \cdot \nabla f )\). More... | |
void | symv (double alpha, const container &f, double beta, container &g) |
Discretizes \( g = \alpha \nabla\cdot ( \vec v \vec v \cdot \nabla f ) + \beta g\) as a symmetric matrix. More... | |
void | dss (const container &f, container &g) |
Discretizes \( g = (\vec v\cdot \nabla)^2 f \). More... | |
void | dss (double alpha, const container &f, double beta, container &g) |
Discretizes \( g = \alpha (\vec v\cdot \nabla)^2 f + \beta g \). More... | |
void | dss_bc_along_field (double alpha, const container &f, double beta, container &g, dg::bc bound, std::array< double, 2 > boundary_value={0, 0}) |
Same as dg::geo::dss_centered after dg::geo::ds_assign_bc_along_field_2nd . More... | |
void | dssd (double alpha, const container &f, double beta, container &g) |
Same as dg::geo::dssd_centered . More... | |
void | dssd_bc_along_field (double alpha, const container &f, double beta, container &g, dg::bc bound, std::array< double, 2 > boundary_value={0, 0}) |
Same as dg::geo::dssd_centered after dg::geo::ds_assign_bc_along_field_2nd . More... | |
void | set_jfactor (double new_jfactor) |
Set the currently used jfactor ( \( \alpha \)) More... | |
double | get_jfactor () const |
Get the currently used jfactor ( \( \alpha \)) More... | |
const container & | weights () const |
The volume form with dG weights. More... | |
FA & | fieldaligned () |
access the underlying Fieldaligned object More... | |
const FA & | fieldaligned () const |
Class for the evaluation of parallel derivatives.
This class discretizes the operators \( \nabla_\parallel = \vec{v}\cdot \nabla = v^\zeta\partial_\zeta + v^\eta\partial_\eta + v^\varphi\partial_\varphi \), \(\nabla_\parallel^\dagger = -\nabla\cdot(\vec v .)\) and \(\Delta_\parallel=-\nabla_\parallel^\dagger\cdot\nabla_\parallel\) in arbitrary coordinates
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)ProductGeometry | must be either dg::aProductGeometry3d or dg::aProductMPIGeometry3d or any derivative |
IMatrix | The type of the interpolation matrix |
Matrix | The matrix class of the jump matrix
|
container | The container-class on which the interpolation matrix operates on |
typedef dg::geo::Fieldaligned<ProductGeometry, IMatrix, container> dg::geo::DS< ProductGeometry, IMatrix, Matrix, container >::FA |
conveniently abbreviates underlying Fieldaligned
type
|
inline |
No memory allocation; all member calls except construct are invalid.
|
inline |
Create the magnetic unit vector field and construct.
Limiter | Class 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. |
vec | The 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. |
grid | The grid on which to integrate fieldlines. |
bcx | This 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. |
bcy | analogous to bcx , applies to y direction |
limit | Instance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere) |
eps | Desired accuracy of the fieldline integrator |
mx | refinement 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 |
my | analogous to mx , applies to y direction |
deltaPhi | The 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. |
grid.bcz()
variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic. interpolation_method | parsed 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)
benchmark | If true write construction timings to std::cout |
eps | Desired accuracy of the fieldline integrator |
mx | refinement 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) |
my | analogous to mx , applies to y direction |
deltaPhi | The 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. |
grid.bcz()
variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic. interpolation_method | Several 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 |
benchmark | If true write construction timings to std::cout |
Fieldaligned
|
inline |
Use the given vector field to construct.
Limiter | Class 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. |
vec | The 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. |
grid | The grid on which to integrate fieldlines. |
bcx | This 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. |
bcy | analogous to bcx , applies to y direction |
limit | Instance of the limiter class (Note that if grid.bcz()==dg::PER this parameter is ignored, Default is a limiter everywhere) |
eps | Desired accuracy of the fieldline integrator |
mx | refinement 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 |
my | analogous to mx , applies to y direction |
deltaPhi | The 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. |
grid.bcz()
variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic. interpolation_method | parsed 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)
benchmark | If true write construction timings to std::cout |
eps | Desired accuracy of the fieldline integrator |
mx | refinement 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) |
my | analogous to mx , applies to y direction |
deltaPhi | The 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. |
grid.bcz()
variable and can be changed by the set_boundaries function. If there is no limiter, the boundary condition is periodic. interpolation_method | Several 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 |
benchmark | If true write construction timings to std::cout |
Fieldaligned
dg::geo::DS< ProductGeometry, IMatrix, Matrix, container >::DS | ( | FA | fieldaligned | ) |
Re-construct from a given Fieldaligned
object.
fieldaligned | this object will be used in all further member calls |
|
inline |
backward derivative \( g = \vec v \cdot \nabla f \)
backward derivative \( g_i = \frac{v^\varphi}{\Delta\varphi}(f_{i} - f_{i-1}) \)
f | The vector to derive |
g | contains result on output (may alias input vectors) |
|
inline |
backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)
backward derivative \( g_i = \alpha \frac{1}{h_z^-}(f_{i} - f_{i-1}) + \beta g_i \)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
2nd order backward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)
backward derivative \( g_i = \alpha \frac{1}{2h_z^-}(3f_{i} - 4f_{i-1} + f_{i-2}) + \beta g_i \)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
centered derivative \( g = \vec v \cdot \nabla f \)
centered derivative \( g_i = \frac{v^\varphi}{2\Delta\varphi}(f_{i+1} - f_{i-1})\)
f | The vector to derive |
g | contains result on output (may alias input vectors) |
|
inline |
centered derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)
The centered derivative is constructed by fitting a polynomial through the plus point the minus point and the center point and evaluating its derivative at the center point. For the exact resulting formula consult the parallel derivative writeup
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
Same as dg::geo::ds_centered
after dg::geo::ds_assign_bc_along_field_2nd
.
|
inline |
Perfect forward parameters to one of the constructors.
Params | deduced by the compiler |
ps | parameters forwarded to constructors |
|
inline |
Discretizes \( g = \nabla \cdot ( \vec v f) \).
dir | redirects to either divForward() , divBackward() or divCentered() |
f | The vector to derive |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned) void dg::geo::DS< ProductGeometry, IMatrix, Matrix, container >::div | ( | dg::direction | dir, |
double | alpha, | ||
const container & | f, | ||
double | beta, | ||
container & | g | ||
) |
Discretizes \( g = \alpha \nabla \cdot( \vec v f) + \beta g \).
dir | redirects to either divForward() , divBackward() or divCentered() |
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
backward divergence \( g = \nabla\cdot(\vec v f)\)
f | The vector to derive |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
backward divergence \( g = \alpha \nabla\cdot(\vec v f) + \beta g\)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
centered divergence \( g = \nabla\cdot(\vec v f)\)
f | The vector to derive |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
centered divergence \( g = \alpha \nabla\cdot(\vec v f) + \beta g\)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
forward divergence \( g = \nabla\cdot(\vec v f)\)
f | The vector to derive |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
forward divergence \( g = \alpha \nabla\cdot(\vec v f) + \beta g\)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
Discretizes \( g = \vec v\cdot \nabla f \).
dir | redirects to either forward() , backward() or centered() |
f | The vector to derive |
g | contains result on output (may alias input vectors) |
void dg::geo::DS< ProductGeometry, IMatrix, Matrix, container >::ds | ( | dg::direction | dir, |
double | alpha, | ||
const container & | f, | ||
double | beta, | ||
container & | g | ||
) |
Discretizes \( g = \alpha \vec v\cdot \nabla f + \beta g \).
dir | redirects to either forward() , backward() or centered() |
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
Discretizes \( g = (\vec v\cdot \nabla)^2 f \).
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
f | The vector to derive |
g | contains result on output (may alias input vectors) |
|
inline |
Discretizes \( 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
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
Same as dg::geo::dss_centered
after dg::geo::ds_assign_bc_along_field_2nd
.
|
inline |
Same as dg::geo::dssd_centered
.
|
inline |
Same as dg::geo::dssd_centered
after dg::geo::ds_assign_bc_along_field_2nd
.
|
inline |
access the underlying Fieldaligned object
|
inline |
|
inline |
forward derivative \( g = \vec v \cdot \nabla f \)
forward derivative \( g_i = \frac{v^\varphi}{\Delta\varphi}(f_{i+1} - f_{i})\)
f | The vector to derive |
g | contains result on output (may alias input vectors) |
|
inline |
forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)
forward derivative \( g_i = \alpha \frac{1}{h_z^+}(f_{i+1} - f_{i}) + \beta g_i\)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
2nd order forward derivative \( g = \alpha \vec v \cdot \nabla f + \beta g\)
forward derivative \( g_i = \alpha \frac{1}{2h_z^+}(-f_{i+2} + 4f_{i+1} - 3f_{i}) + \beta g_i\)
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
|
inline |
Get the currently used jfactor ( \( \alpha \))
|
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
bcz | boundary condition |
global | 3D vector containing boundary values |
scal_left | left scaling factor |
scal_right | right scaling factor |
|
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
bcz | boundary condition |
left | spatially variable left boundary value (2d size) |
right | spatially variable right boundary value (2d size) |
|
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
bcz | boundary condition |
left | constant left boundary value |
right | constant right boundary value |
|
inline |
Set the currently used jfactor ( \( \alpha \))
new_jfactor | The new scale factor for jump terms |
|
inline |
Discretizes \( g = \nabla\cdot ( \vec v \vec v \cdot \nabla f )\).
f | The vector to derive |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned) void dg::geo::DS< ProductGeometry, IMatrix, Matrix, container >::symv | ( | double | alpha, |
const container & | f, | ||
double | beta, | ||
container & | g | ||
) |
Discretizes \( g = \alpha \nabla\cdot ( \vec v \vec v \cdot \nabla f ) + \beta g\) as a symmetric matrix.
alpha | Scalar |
f | The vector to derive |
beta | Scalar |
g | contains result on output (may alias input vectors) |
div
and symv
member functions are close to but not exactly volume conserving (at least if not the linear interpolation is chosen in Fieldaligned)
|
inline |
The volume form with dG weights.