15struct DSMetricCylindrical
28 void operator()(
double t,
const std::array<double,6>& y,
29 std::array<double,6>& yp)
const {
30 double R =
y[0], Z =
y[1];
31 double vx = m_bR(R,Z);
32 double vy = m_bZ(R,Z);
33 double vz = m_bP(R,Z);
34 double vxx = m_bRR(R,Z);
35 double vyx = m_bZR(R,Z);
36 double vzx = m_bPR(R,Z);
37 double vxy = m_bRZ(R,Z);
38 double vyy = m_bZZ(R,Z);
39 double vzy = m_bPZ(R,Z);
42 double vxzx = (vxx/vz - vx*vzx/vz/vz);
43 double vyzx = (vyx/vz - vy*vzx/vz/vz);
44 double vxzy = (vxy/vz - vx*vzy/vz/vz);
45 double vyzy = (vyy/vz - vy*vzy/vz/vz);
46 yp[2] = - vxzx*
y[2] - vyzx*
y[3];
47 yp[3] = - vxzy*
y[2] - vyzy*
y[3];
48 yp[4] = - vxzx*
y[4] - vyzx*
y[5];
49 yp[5] = - vxzy*
y[4] - vyzy*
y[5];
62template<
class real_type>
63inline real_type ds_metric_norm(
const std::array<real_type,6>& x0){
64 return sqrt( x0[0]*x0[0] +x0[1]*x0[1] );
91 m_R0(R0), m_R1(R1), m_Z0(Z0), m_Z1(Z1), m_deltaPhi(deltaPhi), m_dsmetric( mag)
99 virtual double do_width() const override final{
return m_R1-m_R0;}
100 virtual double do_height() const override final{
return m_Z1-m_Z0;}
101 virtual void do_generate(
102 const thrust::host_vector<double>& zeta1d,
103 const thrust::host_vector<double>& eta1d,
104 thrust::host_vector<double>& x,
105 thrust::host_vector<double>& y,
106 thrust::host_vector<double>& zetaX,
107 thrust::host_vector<double>& zetaY,
108 thrust::host_vector<double>& etaX,
109 thrust::host_vector<double>& etaY)
const override final
111 unsigned Nx = zeta1d.size(), Ny = eta1d.size();
112 unsigned size = Nx*Ny;
113 for(
unsigned k=0; k<Ny; k++)
114 for(
unsigned i=0; i<Nx; i++)
116 x[k*Nx+i] = m_R0 + zeta1d[i];
117 y[k*Nx+i] = m_Z0 + eta1d[k];
120 for(
unsigned i=0; i<size; i++)
122 std::array<double,6> coords{
x[i],
y[i],1, 0,0,1}, coordsP;
123 double phi1 = m_deltaPhi;
125 using Vec = std::array<double,6>;
128 detail::ds_metric_norm, 1e-8, 1e-10, 2);
129 loop.set_dt( m_deltaPhi/2.);
130 loop.integrate( 0, coords, phi1, coordsP);
134 zetaX[i] = coordsP[2];
135 zetaY[i] = coordsP[3];
136 etaX[i] = coordsP[4];
137 etaY[i] = coordsP[5];
140 double m_R0, m_R1, m_Z0, m_Z1, m_deltaPhi;
141 dg::geo::detail::DSMetricCylindrical m_dsmetric;
A transformed field grid generator.
Definition: ds_generator.h:79
virtual DSPGenerator * clone() const override final
Abstract clone method that returns a copy on the heap.
Definition: ds_generator.h:96
DSPGenerator(const dg::geo::TokamakMagneticField &mag, double R0, double R1, double Z0, double Z1, double deltaPhi)
Only magnetic fields are admissable vector fields.
Definition: ds_generator.h:90
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
The abstract generator base class.
Definition: generator.h:20