3#include <thrust/host_vector.h>
25template <
class container >
44 double deltapsi = 0.5*(psipZmax*g2d.
hy() +psipRmax*g2d.
hx())/g2d.
nx();
45 m_eps = deltapsi*width_factor;
80 container m_f, m_g, m_delta, m_psi;
81 const container m_w2d;
92template<
class container>
101 template<
class Geometry2d>
140 container m_f, m_g, m_heavi, m_psi;
141 const container m_w2d;
153template <
class container >
165 m_avg( g2d,mag, width_factor), m_area( g2d, mag, width_factor)
192 return m_avg(psip0)/m_area(psip0);
220 m_fsi( g2d, mag, width_factor)
238 return m_fsi( psip0)/(2.*
M_PI);
258 m_fpsi( mag.get_psip(), mag.get_ipol(), mag.R0(), 0.,false){}
267 return 1./m_fpsi( psip0);
270 dg::geo::flux::detail::Fpsi m_fpsi;
static DG_DEVICE double one(double x)
static DG_DEVICE double cooX2d(double x, double y)
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
OutputType reduce(const ContainerType &x, OutputType zero, BinaryOp binary_op, UnaryOp unary_op=UnaryOp())
void evaluate(ContainerType &y, BinarySubroutine f, Functor g, const ContainerType0 &x0, const ContainerTypes &...xs)
void pointwiseDivide(get_value_type< ContainerType > alpha, const ContainerType1 &x1, const ContainerType2 &x2, get_value_type< ContainerType > beta, ContainerType &y)
void pointwiseDot(get_value_type< ContainerType > alpha, const ContainerType1 &x1, const ContainerType2 &x2, get_value_type< ContainerType > beta, ContainerType &y)
get_value_type< ContainerType1 > dot(const ContainerType1 &x, const ContainerType2 &y)
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
Operator< real_type > delta(unsigned n)
thrust::host_vector< real_type > pullback(const Functor &f, const aRealGeometryX2d< real_type > &g)
ContainerType volume(const SparseTensor< ContainerType > &t)
Flux surface average (differential volume average) over quantity .
Definition: average.h:155
void set_container(const container &f)
Reset the function to average.
Definition: average.h:181
double get_deltapsi() const
Definition: average.h:174
double operator()(double psip0)
Calculate the Flux Surface Average.
Definition: average.h:190
FluxSurfaceAverage(const dg::Grid2d &g2d, const TokamakMagneticField &mag, const container &f, container weights, double width_factor=1.)
Construct from a field and a grid.
Definition: average.h:164
Flux surface integral of the form .
Definition: average.h:27
void set_right(const container &g)
Set the right function to integrate.
Definition: average.h:62
FluxSurfaceIntegral(const dg::Grid2d &g2d, const TokamakMagneticField &mag, double width_factor=1.)
Construct from a grid and a magnetic field f and g are default initialized to 1.
Definition: average.h:35
double operator()(double psip0)
Calculate the Flux Surface Integral.
Definition: average.h:71
void set_left(const container &f)
Set the left function to integrate.
Definition: average.h:54
double get_deltapsi() const
Definition: average.h:47
Flux volume integral of the form .
Definition: average.h:94
FluxVolumeIntegral(const Geometry2d &g2d, const TokamakMagneticField &mag)
Construct from a grid and a magnetic field f and g are default initialized to 1.
Definition: average.h:102
void set_right(const container &g)
Set the right function to integrate.
Definition: average.h:122
void set_left(const container &f)
Set the left function to integrate.
Definition: average.h:114
double operator()(double psip0)
Calculate the Flux Volume Integral.
Definition: average.h:131
Class for the evaluation of the safety factor q based on a flux-surface integral .
Definition: average.h:212
void set_weights(const thrust::host_vector< double > &weights)
Weight function H (can be used to cut away parts of the domain e.g. below the X-point)
Definition: average.h:228
SafetyFactorAverage(const dg::Grid2d &g2d, const TokamakMagneticField &mag, double width_factor=1.)
Construct from a field and a grid.
Definition: average.h:219
double operator()(double psip0)
Calculate the q(psip0)
Definition: average.h:236
Evaluation of the safety factor q based on direct integration of .
Definition: average.h:256
SafetyFactor(const TokamakMagneticField &mag)
Definition: average.h:257
double operator()(double psip0)
Calculate q(psip0)
Definition: average.h:265
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
const CylindricalFunctor & psipR() const
, where R, Z are cylindrical coordinates
Definition: magnetic_field.h:181
const CylindricalFunctor & ipol() const
the current
Definition: magnetic_field.h:191
const CylindricalFunctor & psipZ() const
, where R, Z are cylindrical coordinates
Definition: magnetic_field.h:183