4#include <cusp/csr_matrix.h>
39static void parse_method( std::string method, std::string& i, std::string& p, std::string& f)
42 if( method ==
"dg") i =
"dg", p =
"dg";
43 else if( method ==
"linear") i =
"linear", p =
"dg";
44 else if( method ==
"cubic") i =
"cubic", p =
"dg";
45 else if( method ==
"nearest") i =
"nearest", p =
"dg";
46 else if( method ==
"dg-nearest") i =
"dg", p =
"nearest";
47 else if( method ==
"linear-nearest") i =
"linear", p =
"nearest";
48 else if( method ==
"cubic-nearest") i =
"cubic", p =
"nearest";
49 else if( method ==
"nearest-nearest") i =
"nearest", p =
"nearest";
50 else if( method ==
"dg-linear") i =
"dg", p =
"linear";
51 else if( method ==
"linear-linear") i =
"linear", p =
"linear";
52 else if( method ==
"cubic-linear") i =
"cubic", p =
"linear";
53 else if( method ==
"nearest-linear") i =
"nearest", p =
"linear";
54 else if( method ==
"dg-equi") i =
"dg", p =
"dg", f =
"equi";
55 else if( method ==
"linear-equi") i =
"linear", p =
"dg", f =
"equi";
56 else if( method ==
"cubic-equi") i =
"cubic", p =
"dg", f =
"equi";
57 else if( method ==
"nearest-equi") i =
"nearest", p =
"dg", f =
"equi";
58 else if( method ==
"dg-equi-nearest") i =
"dg", p =
"nearest", f =
"equi";
59 else if( method ==
"linear-equi-nearest") i =
"linear", p =
"nearest", f =
"equi";
60 else if( method ==
"cubic-equi-nearest") i =
"cubic", p =
"nearest", f =
"equi";
61 else if( method ==
"nearest-equi-nearest") i =
"nearest", p =
"nearest", f =
"equi";
62 else if( method ==
"dg-equi-linear") i =
"dg", p =
"linear", f =
"equi";
63 else if( method ==
"linear-equi-linear") i =
"linear", p =
"linear", f =
"equi";
64 else if( method ==
"cubic-equi-linear") i =
"cubic", p =
"linear", f =
"equi";
65 else if( method ==
"nearest-equi-linear") i =
"nearest", p =
"linear", f =
"equi";
70struct DSFieldCylindrical3
73 void operator()(
double t,
const std::array<double,3>&
y,
74 std::array<double,3>& yp)
const {
75 double R =
y[0], Z =
y[1];
76 double vz = m_v.z()(R, Z);
77 yp[0] = m_v.x()(R, Z)/vz;
78 yp[1] = m_v.y()(R, Z)/vz;
85struct DSFieldCylindrical4
88 void operator()(
double t,
const std::array<double,3>&
y,
89 std::array<double,3>& yp)
const {
90 double R =
y[0], Z =
y[1];
91 double vx = m_v.x()(R,Z);
92 double vy = m_v.y()(R,Z);
93 double vz = m_v.z()(R,Z);
94 double divvvz = m_v.divvvz()(R,Z);
125 void operator()(
double t,
const std::array<double,3>&
y, std::array<double,3>& yp)
const
133 thrust::host_vector<double> dzetadphi_, detadphi_, dvdphi_;
138template<
class real_type>
142 std::array<thrust::host_vector<real_type>,3>& yp,
143 const thrust::host_vector<double>& vol0,
144 thrust::host_vector<real_type>& yp2b,
145 thrust::host_vector<bool>& in_boxp,
146 real_type deltaPhi, real_type eps)
150 std::array<thrust::host_vector<real_type>,3>
y{
157 dg::geo::detail::DSField field;
159 field = dg::geo::detail::DSField( vec, grid_field);
162 dg::geo::detail::DSFieldCylindrical4 cyl_field(vec);
163 const unsigned size = grid_evaluate.
size();
165 "Dormand-Prince-7-4-5", std::array<real_type,3>{0,0,0});
174 for(
unsigned i=0; i<size; i++)
176 std::array<real_type,3> coords{
y[0][i],
y[1][i],
y[2][i]}, coordsP;
178 real_type phi1 = deltaPhi;
179 odeint.set_dt( deltaPhi/2.);
180 odeint.integrate( 0, coords, phi1, coordsP);
181 yp[0][i] = coordsP[0], yp[1][i] = coordsP[1], yp[2][i] = coordsP[2];
183 yp2b.assign( grid_evaluate.
size(), deltaPhi);
184 in_boxp.resize( yp2b.size());
186 for(
unsigned i=0; i<size; i++)
188 std::array<real_type,3> coords{
y[0][i],
y[1][i],
y[2][i]}, coordsP;
189 in_boxp[i] = grid_field.
contains( yp[0][i], yp[1][i]) ? true :
false;
190 if(
false == in_boxp[i])
193 real_type phi1 = deltaPhi;
194 odeint.integrate_in_domain( 0., coords, phi1, coordsP, 0., (
const
235 double maxPhi,
double eps, std::string type) :
236 m_domain( domain), m_cyl_field(vec),
237 m_deltaPhi( maxPhi), m_eps( eps), m_type(type)
239 if( m_type !=
"phi" && m_type !=
"s")
240 throw std::runtime_error(
"Distance type "+m_type+
" not recognized!\n");
254 std::array<double,3> coords{ R, Z, 0}, coordsP(coords);
256 m_cyl_field( 0., coords, coordsP);
257 double sign = coordsP[2] > 0 ? +1. : -1.;
258 double phi1 = sign*m_deltaPhi;
261 "Dormand-Prince-7-4-5", coords);
268 }
catch (std::exception& e)
272 phi1 = sign*m_deltaPhi;
273 coordsP[2] = 1e6*phi1;
282 dg::geo::detail::DSFieldCylindrical3 m_cyl_field;
283 double m_deltaPhi, m_eps;
314 double maxPhi,
double eps, std::string type) :
315 m_domain( domain), m_cyl_field(vec),
316 m_deltaPhi( maxPhi), m_eps( eps), m_type(type)
318 if( m_type !=
"phi" && m_type !=
"s")
319 throw std::runtime_error(
"Distance type "+m_type+
" not recognized!\n");
323 double phiP = m_deltaPhi, phiM = -m_deltaPhi;
324 std::array<double,3> coords{ R, Z, 0}, coordsP(coords), coordsM(coords);
326 m_cyl_field( 0., coords, coordsP);
327 double sign = coordsP[2] > 0 ? +1. : -1.;
331 "Dormand-Prince-7-4-5", coords), m_cyl_field,
337 }
catch (std::exception& e)
341 coordsP[2] = 1e6*phiP;
343 coordsM[2] = 1e6*phiM;
346 return sign*(-phiP-phiM)/(phiP-phiM);
347 double sP = coordsP[2], sM = coordsM[2];
348 double value = sign*(-sP-sM)/(sP-sM);
349 if( (phiM <= -m_deltaPhi) && (phiP >= m_deltaPhi))
351 if( (phiM <= -m_deltaPhi))
352 return value*sign > 0 ? value : 0.;
353 if( (phiP >= m_deltaPhi))
354 return value*sign < 0 ? value : 0.;
360 dg::geo::detail::DSFieldCylindrical3 m_cyl_field;
361 double m_deltaPhi, m_eps;
431template<
class ProductGeometry,
class IMatrix,
class container >
440 template <
class Limiter>
442 const ProductGeometry&
grid,
447 unsigned mx=12,
unsigned my=12,
449 std::string interpolation_method =
"linear-nearest",
460 template <
class Limiter>
462 const ProductGeometry&
grid,
467 unsigned mx=12,
unsigned my=12,
469 std::string interpolation_method =
"linear-nearest",
477 template<
class ...Params>
556 const container&
hbm()
const {
561 const container&
hbp()
const {
596 const container&
bbm()
const {
601 const container&
bbo()
const {
606 const container&
bbp()
const {
610 const ProductGeometry&
grid()
const{
return *m_g;}
666 template<
class BinaryOp,
class UnaryOp>
667 container
evaluate( BinaryOp binary, UnaryOp unary,
668 unsigned p0,
unsigned rounds)
const;
671 std::string
method()
const{
return m_interpolation_method;}
674 void ePlus(
enum whichMatrix which,
const container& in, container& out);
675 void eMinus(
enum whichMatrix which,
const container& in, container& out);
676 void zero(
enum whichMatrix which,
const container& in, container& out);
677 IMatrix m_plus, m_zero, m_minus, m_plusT, m_minusT;
678 container m_hbm, m_hbp;
679 container m_G, m_Gm, m_Gp;
680 container m_bphi, m_bphiM, m_bphiP;
681 container m_bbm, m_bbp, m_bbo;
683 container m_left, m_right;
685 container m_ghostM, m_ghostP;
686 unsigned m_Nz, m_perp_size;
687 dg::bc m_bcx, m_bcy, m_bcz;
688 std::vector<dg::View<const container>> m_f;
689 std::vector<dg::View< container>> m_temp;
693 std::string m_interpolation_method;
695 bool m_have_adjoint =
false;
696 void updateAdjoint( )
700 m_have_adjoint =
true;
707template<
class Geometry,
class IMatrix,
class container>
708template <
class Limiter>
711 const Geometry& grid,
713 unsigned mx,
unsigned my,
double deltaPhi, std::string interpolation_method,
bool benchmark) :
715 m_interpolation_method(interpolation_method)
718 std::string inter_m, project_m, fine_m;
719 detail::parse_method( interpolation_method, inter_m, project_m, fine_m);
720 if( benchmark) std::cout <<
"# Interpolation method: \""<<inter_m <<
"\" projection method: \""<<project_m<<
"\" fine grid \""<<fine_m<<
"\"\n";
731 if( benchmark) t.
tic();
736 grid_equidist.set( 1,
grid.gx().size(),
grid.gy().size());
738 grid_magnetic->set( grid_transform->n() < 3 ? 4 : 7, grid_magnetic->Nx(), grid_magnetic->Ny());
740 if( project_m !=
"dg" && fine_m ==
"dg")
742 unsigned rx = mx %
grid.nx(), ry = my %
grid.ny();
743 if( 0 != rx || 0 != ry)
745 std::cerr <<
"#Warning: for projection method \"const\" mx and my must be multiples of nx and ny! Rounding up for you ...\n";
746 mx = mx +
grid.nx() - rx;
747 my = my +
grid.ny() - ry;
750 if( fine_m ==
"equi")
751 grid_fine = grid_equidist;
752 grid_fine.multiplyCellNumbers((
double)mx, (
double)my);
756 std::cout <<
"# DS: High order grid gen took: "<<t.
diff()<<
"\n";
760 std::array<thrust::host_vector<double>,3> yp_trafo, ym_trafo, yp, ym;
761 thrust::host_vector<bool> in_boxp, in_boxm;
762 thrust::host_vector<double>
hbp,
hbm;
766 detail::integrate_all_fieldlines2d( vec, *grid_magnetic, *grid_transform,
768 detail::integrate_all_fieldlines2d( vec, *grid_magnetic, *grid_transform,
774 *grid_transform,
dg::NEU,
dg::NEU, grid_transform->n() < 3 ?
"cubic" :
"dg");
777 for(
int i=0; i<2; i++)
786 std::cout <<
"# DS: Computing all points took: "<<t.
diff()<<
"\n";
793 if( project_m ==
"dg")
802 *grid_transform,
bcx,
bcy,
"dg");
806 *grid_transform,
bcx,
bcy,
"dg");
810 *grid_transform,
bcx,
bcy,
"dg");
817 if( project_m ==
"dg")
829 grid_equidist,
bcx,
bcy, inter_m);
830 cusp::multiply( multi, fine, temp);
835 grid_equidist,
bcx,
bcy, inter_m);
836 cusp::multiply( multi, fine, temp);
841 grid_equidist,
bcx,
bcy, inter_m);
842 cusp::multiply( multi, fine, temp);
850 std::cout <<
"# DS: Multiplication PI took: "<<t.
diff()<<
"\n";
853 dg::HVec hbphi( yp_trafo[2]), hbphiP(hbphi), hbphiM(hbphi);
858 for(
unsigned i=0; i<hbphiP.size(); i++)
860 hbphiP[i] = vec.
z()(yp_trafo[0][i], yp_trafo[1][i]);
861 hbphiM[i] = vec.
z()(ym_trafo[0][i], ym_trafo[1][i]);
868 for(
unsigned i=0; i<yp_trafo[0].size(); i++)
871 yp_trafo[1][i], *grid_magnetic);
873 ym_trafo[1][i], *grid_magnetic);
898 thrust::host_vector<double>
bbm( in_boxp.size(),0.),
bbo(
bbm),
bbp(
bbm);
899 for(
unsigned i=0; i<in_boxp.size(); i++)
901 if( !in_boxp[i] && !in_boxm[i])
903 else if( !in_boxp[i] && in_boxm[i])
905 else if( in_boxp[i] && !in_boxm[i])
916 m_perp_size = grid_transform->size();
919 m_ghostM = m_ghostP = m_right = m_left;
923template<
class G,
class I,
class container>
925 const G& grid,
const container& in)
930 assert( m_g->Nz() % grid.Nz() == 0);
931 unsigned Nz_coarse = grid.Nz(), Nz = m_g->Nz();
932 unsigned cphi = Nz / Nz_coarse;
937 std::vector<dg::View< container>> out_split =
dg::split( out, *m_g);
938 std::vector<dg::View< const container>> in_split =
dg::split( in, grid);
939 for (
int i=0; i<(int)Nz_coarse; i++)
947 for (
int i=0; i<(int)Nz_coarse; i++)
949 for(
int j=1; j<(int)cphi; j++)
954 dg::blas2::symv( m_plus, m_temp[(i*cphi+cphi+1-j)%Nz], m_temp[i*cphi+cphi-j]);
958 for(
int i=0; i<(int)Nz_coarse; i++)
959 for(
int j=1; j<(int)cphi; j++)
961 double alpha = (double)(cphi-j)/(double)cphi;
962 double beta = (double)j/(
double)cphi;
963 dg::blas1::axpby( alpha, out_split[i*cphi+j], beta, m_temp[i*cphi+j], out_split[i*cphi+j]);
967template<
class G,
class I,
class container>
970 assert( m_g->Nz() % grid.Nz() == 0);
971 unsigned Nz_coarse = grid.Nz(), Nz = m_g->Nz();
972 unsigned cphi = Nz / Nz_coarse;
975 container helperP( in), helperM(in), tempP(in), tempM(in);
978 for(
int j=1; j<(int)cphi; j++)
992template<
class G,
class I,
class container>
1002template<
class G,
class I,
class container>
1003void Fieldaligned<G, I, container>::zero(
enum whichMatrix which,
1004 const container& f, container& f0)
1009 for(
unsigned i0=0; i0<m_Nz; i0++)
1017 if( ! m_have_adjoint) updateAdjoint( );
1022 if( ! m_have_adjoint) updateAdjoint( );
1027 if ( m_interpolation_method !=
"dg" )
1036template<
class G,
class I,
class container>
1037void Fieldaligned<G, I, container>::ePlus(
enum whichMatrix which,
1038 const container& f, container& fpe)
1043 for(
unsigned i0=0; i0<m_Nz; i0++)
1045 unsigned ip = (i0==m_Nz-1) ? 0:i0+1;
1050 if( ! m_have_adjoint) updateAdjoint( );
1068template<
class G,
class I,
class container>
1069void Fieldaligned<G, I, container>::eMinus(
enum whichMatrix which,
1070 const container& f, container& fme)
1075 for(
unsigned i0=0; i0<m_Nz; i0++)
1077 unsigned im = (i0==0) ? m_Nz-1:i0-1;
1080 if( ! m_have_adjoint) updateAdjoint( );
1100template<
class G,
class I,
class container>
1101template<
class BinaryOp,
class UnaryOp>
1103 UnaryOp unary,
unsigned p0,
unsigned rounds)
const
1107 assert( p0 < m_g->Nz());
1112 container temp(init2d), tempP(init2d), tempM(init2d);
1114 std::vector<container> plus2d(m_Nz, zero2d), minus2d(plus2d), result(plus2d);
1115 unsigned turns = rounds;
1116 if( turns ==0) turns++;
1118 for(
unsigned r=0; r<turns; r++)
1119 for(
unsigned i0=0; i0<m_Nz; i0++)
1123 unsigned rep = r*m_Nz + i0;
1124 for(
unsigned k=0; k<rep; k++)
1141 for(
unsigned i0=0; i0<m_Nz; i0++)
1143 int idx = (int)i0 - (
int)p0;
1145 result[i0] = plus2d[idx];
1147 result[i0] = minus2d[abs(idx)];
1148 thrust::copy( result[i0].begin(), result[i0].end(), vec3d.begin() + i0*m_perp_size);
1153 for(
unsigned i0=0; i0<m_Nz; i0++)
1155 unsigned revi0 = (m_Nz - i0)%m_Nz;
1160 for(
unsigned i0=0; i0<m_Nz; i0++)
1162 int idx = ((int)i0 -(
int)p0 + m_Nz)%m_Nz;
1163 thrust::copy( result[idx].begin(), result[idx].end(), vec3d.begin() + i0*m_perp_size);
1203template<
class BinaryOp,
class UnaryOp>
1207 const BinaryOp& binary,
1208 const UnaryOp& unary,
1213 unsigned Nz = grid.
Nz();
1217 std::vector<dg::HVec> plus2d(Nz, tempP), minus2d(plus2d), result(plus2d);
1220 std::array<dg::HVec,3> yy0{
1224 dg::geo::detail::DSFieldCylindrical3 cyl_field(vec);
1225 double deltaPhi = grid.
hz();
1226 double phiM0 = 0., phiP0 = 0.;
1227 unsigned turns = rounds;
1228 if( turns == 0) turns++;
1229 for(
unsigned r=0; r<turns; r++)
1230 for(
unsigned i0=0; i0<Nz; i0++)
1232 unsigned rep = r*Nz + i0;
1234 tempM = tempP = init2d;
1238 "Dormand-Prince-7-4-5", std::array<double,3>{0,0,0});
1242 for(
unsigned i=0; i<g2d->size(); i++)
1245 double phiM1 = phiM0 + deltaPhi;
1246 std::array<double,3>
1247 coords0{yy0[0][i],yy0[1][i],yy0[2][i]}, coords1;
1248 odeint.integrate_in_domain( phiM0, coords0, phiM1, coords1,
1249 deltaPhi, *g2d, eps);
1250 yy1[0][i] = coords1[0], yy1[1][i] = coords1[1], yy1[2][i] =
1252 tempM[i] = binary( yy1[0][i], yy1[1][i]);
1255 double phiP1 = phiP0 - deltaPhi;
1256 coords0 = std::array<double,3>{xx0[0][i],xx0[1][i],xx0[2][i]};
1257 odeint.integrate_in_domain( phiP0, coords0, phiP1, coords1,
1258 -deltaPhi, *g2d, eps);
1259 xx1[0][i] = coords1[0], xx1[1][i] = coords1[1], xx1[2][i] =
1261 tempP[i] = binary( xx1[0][i], xx1[1][i]);
1263 std::swap( yy0, yy1);
1264 std::swap( xx0, xx1);
1276 for(
unsigned i0=0; i0<Nz; i0++)
1278 int idx = (int)i0 - (
int)p0;
1280 result[i0] = plus2d[idx];
1282 result[i0] = minus2d[abs(idx)];
1283 thrust::copy( result[i0].begin(), result[i0].end(), vec3d.begin() +
1289 for(
unsigned i0=0; i0<Nz; i0++)
1291 unsigned revi0 = (Nz - i0)%Nz;
1296 for(
unsigned i0=0; i0<Nz; i0++)
1298 int idx = ((int)i0 -(
int)p0 + Nz)%Nz;
1299 thrust::copy( result[idx].begin(), result[idx].end(), vec3d.begin()
void assign(const from_ContainerType &from, ContainerType &to, Params &&... ps)
static DG_DEVICE double cooY2d(double x, double y)
static DG_DEVICE double zero(double x)
static DG_DEVICE double cooX2d(double x, double y)
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
void scal(ContainerType &x, get_value_type< ContainerType > alpha)
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)
void transfer(const MatrixType &x, AnotherMatrixType &y)
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
static std::string bc2str(bc bcx)
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
whichMatrix
Enum for the use in Fieldaligned.
Definition: fieldaligned.h:17
ZERO NoLimiter
No Limiter.
Definition: fieldaligned.h:35
thrust::host_vector< double > fieldaligned_evaluate(const aProductGeometry3d &grid, const CylindricalVectorLvl0 &vec, const BinaryOp &binary, const UnaryOp &unary, unsigned p0, unsigned rounds, double eps=1e-5)
Evaluate a 2d functor and transform to all planes along the fieldlines
Definition: fieldaligned.h:1204
ONE FullLimiter
Full Limiter means there is a limiter everywhere.
Definition: fieldaligned.h:31
@ zeroPlusT
transposed plus interpolation in the current plane
Definition: fieldaligned.h:24
@ einsMinus
minus interpolation in previous plane
Definition: fieldaligned.h:20
@ einsMinusT
transposed minus interpolation in next plane
Definition: fieldaligned.h:21
@ zeroMinusT
transposed minus interpolation in the current plane
Definition: fieldaligned.h:25
@ einsPlusT
transposed plus interpolation in previous plane
Definition: fieldaligned.h:19
@ zeroForw
from dg to transformed coordinates
Definition: fieldaligned.h:26
@ zeroMinus
minus interpolation in the current plane
Definition: fieldaligned.h:23
@ zeroPlus
plus interpolation in the current plane
Definition: fieldaligned.h:22
@ einsPlus
plus interpolation in next plane
Definition: fieldaligned.h:18
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
cusp::coo_matrix< int, real_type, cusp::host_memory > interpolation(const thrust::host_vector< real_type > &x, const RealGrid1d< real_type > &g, dg::bc bcx=dg::NEU, std::string method="dg")
real_type interpolate(dg::space sp, const thrust::host_vector< real_type > &v, real_type x, const RealGrid1d< real_type > &g, dg::bc bcx=dg::NEU)
dg::MIHMatrix_t< real_type > projection(const aRealMPITopology2d< real_type > &g_new, const aRealMPITopology2d< real_type > &g_old, std::string method="dg")
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
thrust::host_vector< real_type > forward_transform(const thrust::host_vector< real_type > &in, const aRealTopology2d< real_type > &g)
void transpose(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
thrust::host_vector< real_type > pullback(const Functor &f, const aRealGeometryX2d< real_type > &g)
void pushForwardPerp(const Functor1 &vR, const Functor2 &vZ, container &vx, container &vy, const Geometry &g)
void assign3dfrom2d(const thrust::host_vector< real_type > &in2d, Container &out, const aRealTopology3d< real_type > &grid)
dg::IHMatrix_t< real_type > backproject(const RealGrid1d< real_type > &g)
dg::IHMatrix_t< real_type > inv_backproject(const RealGrid1d< real_type > &g)
void split(SharedContainer &in, std::vector< View< SharedContainer > > &out, const aRealTopology3d< real_type > &grid)
ContainerType volume(const SparseTensor< ContainerType > &t)
IHMatrix_t< double > IHMatrix
thrust::host_vector< double > HVec
void integrate_in_domain(value_type t0, const ContainerType &u0, value_type &t1, ContainerType &u1, value_type dt, Domain &&domain, value_type eps_root)
aRealGeometry2d< real_type > * perp_grid() const
bool contains(real_type x, real_type y) const
Definition: fluxfunctions.h:412
This struct bundles a vector field and its divergence.
Definition: fluxfunctions.h:440
const CylindricalFunctor & y() const
y-component of the vector
Definition: fluxfunctions.h:468
const CylindricalFunctor & x() const
x-component of the vector
Definition: fluxfunctions.h:466
const CylindricalFunctor & divvvz() const
Definition: fluxfunctions.h:474
const CylindricalFunctor & z() const
z-component of the vector
Definition: fluxfunctions.h:470
Create and manage interpolation matrices from fieldline integration.
Definition: fieldaligned.h:433
dg::bc bcx() const
Definition: fieldaligned.h:484
const container & hbp() const
Distance between the planes .
Definition: fieldaligned.h:561
const container & bphi() const
bphi
Definition: fieldaligned.h:581
container interpolate_from_coarse_grid(const ProductGeometry &grid_coarse, const container &coarse)
Interpolate along fieldlines from a coarse to a fine grid in phi.
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.
Definition: fieldaligned.h:441
void integrate_between_coarse_grid(const ProductGeometry &grid_coarse, const container &coarse, container &out)
Integrate a 2d function on the fine grid.
const container & bbp() const
Mask plus, 1 if fieldline intersects wall in plus direction but not in minus direction,...
Definition: fieldaligned.h:606
container evaluate(BinaryOp binary, UnaryOp unary, unsigned p0, unsigned rounds) const
Evaluate a 2d functor and transform to all planes along the fieldline
const container & sqrtG() const
Volume form (including weights) .
Definition: fieldaligned.h:566
void operator()(enum whichMatrix which, const container &in, container &out)
Apply the interpolation to three-dimensional vectors.
const container & sqrtGm() const
Volume form on minus plane (including weights) .
Definition: fieldaligned.h:571
void set_boundaries(dg::bc bcz, double left, double right)
Set boundary conditions in the limiter region.
Definition: fieldaligned.h:501
std::string method() const
Return the interpolation_method string given in the constructor.
Definition: fieldaligned.h:671
const container & hbm() const
Distance between the planes and the boundary .
Definition: fieldaligned.h:556
void set_boundaries(dg::bc bcz, const container &global, double scal_left, double scal_right)
Set boundary conditions in the limiter region.
Definition: fieldaligned.h:535
const container & bphiM() const
bphi on minus plane
Definition: fieldaligned.h:586
dg::bc bcy() const
Definition: fieldaligned.h:487
double deltaPhi() const
Definition: fieldaligned.h:553
Fieldaligned()
do not allocate memory; no member call except construct is valid
Definition: fieldaligned.h:436
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: fieldaligned.h:478
const container & bbo() const
Mask both, 1 if fieldline intersects wall in plus direction and in minus direction,...
Definition: fieldaligned.h:601
const container & bbm() const
Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction,...
Definition: fieldaligned.h:596
const container & sqrtGp() const
Volume form on plus plane (including weights) .
Definition: fieldaligned.h:576
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.
const container & bphiP() const
bphi on plus plane
Definition: fieldaligned.h:591
const ProductGeometry & grid() const
Grid used for construction.
Definition: fieldaligned.h:610
void set_boundaries(dg::bc bcz, const container &left, const container &right)
Set boundary conditions in the limiter region.
Definition: fieldaligned.h:518
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
Normalized coordinate relative to wall along fieldline in phi or s coordinate.
Definition: fieldaligned.h:308
WallFieldlineCoordinate(const dg::geo::CylindricalVectorLvl0 &vec, const dg::aRealTopology2d< double > &domain, double maxPhi, double eps, std::string type)
Construct with vector field, domain.
Definition: fieldaligned.h:311
double do_compute(double R, double Z) const
Definition: fieldaligned.h:321
Distance to wall along fieldline in phi or s coordinate
Definition: fieldaligned.h:221
WallFieldlineDistance(const dg::geo::CylindricalVectorLvl0 &vec, const dg::aRealTopology2d< double > &domain, double maxPhi, double eps, std::string type)
Construct with vector field, domain.
Definition: fieldaligned.h:232
double do_compute(double R, double Z) const
Integrate fieldline until wall is reached.
Definition: fieldaligned.h:252
Represent functions written in cylindrical coordinates that are independent of the angle phi serving ...
Definition: fluxfunctions.h:66