4#include <cusp/csr_matrix.h>
40struct DSFieldCylindrical3
43 void operator()(
double t,
const std::array<double,3>& y,
44 std::array<double,3>& yp)
const {
45 double R =
y[0], Z =
y[1];
46 double vz = m_v.z()(R, Z);
47 yp[0] = m_v.x()(R, Z)/vz;
48 yp[1] = m_v.y()(R, Z)/vz;
55struct DSFieldCylindrical4
58 void operator()(
double t,
const std::array<double,3>& y,
59 std::array<double,3>& yp)
const {
60 double R =
y[0], Z =
y[1];
61 double vx = m_v.x()(R,Z);
62 double vy = m_v.y()(R,Z);
63 double vz = m_v.z()(R,Z);
64 double divvvz = m_v.divvvz()(R,Z);
95 void operator()(
double t,
const std::array<double,3>& y, std::array<double,3>& yp)
const
103 thrust::host_vector<double> dzetadphi_, detadphi_, dvdphi_;
108template<
class real_type>
112 std::array<thrust::host_vector<real_type>,3>& yp,
113 const thrust::host_vector<double>& vol0,
114 thrust::host_vector<real_type>& yp2b,
115 thrust::host_vector<bool>& in_boxp,
116 real_type deltaPhi, real_type eps)
120 std::array<thrust::host_vector<real_type>,3>
y{
127 dg::geo::detail::DSField field;
129 field = dg::geo::detail::DSField( vec, grid_field);
132 dg::geo::detail::DSFieldCylindrical4 cyl_field(vec);
133 const unsigned size = grid_evaluate.
size();
135 "Dormand-Prince-7-4-5", std::array<real_type,3>{0,0,0});
144 for(
unsigned i=0; i<size; i++)
146 std::array<real_type,3> coords{
y[0][i],
y[1][i],
y[2][i]}, coordsP;
148 real_type phi1 = deltaPhi;
149 odeint.
set_dt( deltaPhi/2.);
150 odeint.
integrate( 0, coords, phi1, coordsP);
151 yp[0][i] = coordsP[0], yp[1][i] = coordsP[1], yp[2][i] = coordsP[2];
153 yp2b.assign( grid_evaluate.
size(), deltaPhi);
154 in_boxp.resize( yp2b.size());
156 for(
unsigned i=0; i<size; i++)
158 std::array<real_type,3> coords{
y[0][i],
y[1][i],
y[2][i]}, coordsP;
159 in_boxp[i] = grid_field.
contains( yp[0][i], yp[1][i]) ? true :
false;
160 if(
false == in_boxp[i])
163 real_type phi1 = deltaPhi;
181struct WallFieldlineDistance :
public aCylindricalFunctor<WallFieldlineDistance>
200 double maxPhi,
double eps, std::string type) :
201 m_domain( domain), m_cyl_field(vec),
202 m_deltaPhi( maxPhi), m_eps( eps), m_type(type)
204 if( m_type !=
"phi" && m_type !=
"s")
205 throw std::runtime_error(
"Distance type "+m_type+
" not recognized!\n");
219 std::array<double,3> coords{ R, Z, 0}, coordsP(coords);
221 m_cyl_field( 0., coords, coordsP);
222 double sign = coordsP[2] > 0 ? +1. : -1.;
223 double phi1 = sign*m_deltaPhi;
226 "Dormand-Prince-7-4-5", coords);
233 }
catch (std::exception& e)
237 phi1 = sign*m_deltaPhi;
238 coordsP[2] = 1e6*phi1;
247 dg::geo::detail::DSFieldCylindrical3 m_cyl_field;
248 double m_deltaPhi, m_eps;
264struct WallFieldlineCoordinate :
public aCylindricalFunctor<WallFieldlineCoordinate>
270 double maxPhi,
double eps, std::string type) :
271 m_domain( domain), m_cyl_field(vec),
272 m_deltaPhi( maxPhi), m_eps( eps), m_type(type)
274 if( m_type !=
"phi" && m_type !=
"s")
275 throw std::runtime_error(
"Distance type "+m_type+
" not recognized!\n");
279 double phiP = m_deltaPhi, phiM = -m_deltaPhi;
280 std::array<double,3> coords{ R, Z, 0}, coordsP(coords), coordsM(coords);
282 m_cyl_field( 0., coords, coordsP);
283 double sign = coordsP[2] > 0 ? +1. : -1.;
287 "Dormand-Prince-7-4-5", coords), m_cyl_field,
293 }
catch (std::exception& e)
297 coordsP[2] = 1e6*phiP;
299 coordsM[2] = 1e6*phiM;
302 return sign*(-phiP-phiM)/(phiP-phiM);
303 double sP = coordsP[2], sM = coordsM[2];
304 double value = sign*(-sP-sM)/(sP-sM);
305 if( (phiM <= -m_deltaPhi) && (phiP >= m_deltaPhi))
307 if( (phiM <= -m_deltaPhi))
308 return value*sign > 0 ? value : 0.;
309 if( (phiP >= m_deltaPhi))
310 return value*sign < 0 ? value : 0.;
316 dg::geo::detail::DSFieldCylindrical3 m_cyl_field;
317 double m_deltaPhi, m_eps;
372template<
class ProductGeometry,
class IMatrix,
class container >
381 template <
class Limiter>
383 const ProductGeometry&
grid,
388 unsigned mx=10,
unsigned my=10,
390 std::string interpolation_method =
"dg",
401 template <
class Limiter>
403 const ProductGeometry&
grid,
408 unsigned mx=10,
unsigned my=10,
410 std::string interpolation_method =
"dg",
418 template<
class ...Params>
497 const container&
hbm()
const {
502 const container&
hbp()
const {
537 const container&
bbm()
const {
542 const container&
bbo()
const {
547 const container&
bbp()
const {
551 const ProductGeometry&
grid()
const{
return *m_g;}
607 template<
class BinaryOp,
class UnaryOp>
608 container
evaluate( BinaryOp binary, UnaryOp unary,
609 unsigned p0,
unsigned rounds)
const;
611 std::string
method()
const{
return m_interpolation_method;}
614 void ePlus(
enum whichMatrix which,
const container& in, container& out);
615 void eMinus(
enum whichMatrix which,
const container& in, container& out);
616 void zero(
enum whichMatrix which,
const container& in, container& out);
617 IMatrix m_plus, m_minus, m_plusT, m_minusT;
619 IMatrix m_back, m_forw;
620 IMatrix m_stencil, m_stencilY;
621 container m_hbm, m_hbp;
622 container m_G, m_Gm, m_Gp;
623 container m_bphi, m_bphiM, m_bphiP;
624 container m_bbm, m_bbp, m_bbo;
626 container m_left, m_right, m_temp2d;
628 container m_ghostM, m_ghostP;
629 unsigned m_Nz, m_perp_size;
630 dg::bc m_bcx, m_bcy, m_bcz;
631 std::vector<dg::View<const container>> m_f;
632 std::vector<dg::View< container>> m_temp, m_temp2;
636 std::string m_interpolation_method;
638 bool m_have_adjoint =
false;
639 void updateAdjoint( )
643 m_have_adjoint =
true;
650template<
class Geometry,
class IMatrix,
class container>
651template <
class Limiter>
654 const Geometry& grid,
656 unsigned mx,
unsigned my,
double deltaPhi, std::string interpolation_method,
bool benchmark)
661 if( (grid.bcx() ==
PER && bcx !=
PER) || (grid.bcx() !=
PER && bcx ==
PER) )
662 throw(
dg::Error(
dg::Message(_ping_)<<
"Fieldaligned: Got conflicting periodicity in x. The grid says "<<
bc2str(grid.bcx())<<
" while the parameter says "<<
bc2str(bcx)));
663 if( (grid.bcy() ==
PER && bcy !=
PER) || (grid.bcy() !=
PER && bcy ==
PER) )
664 throw(
dg::Error(
dg::Message(_ping_)<<
"Fieldaligned: Got conflicting boundary conditions in y. The grid says "<<
bc2str(grid.bcy())<<
" while the parameter says "<<
bc2str(bcy)));
665 m_Nz=grid.Nz(), m_bcx = bcx, m_bcy = bcy, m_bcz=grid.bcz();
667 if( deltaPhi <=0) deltaPhi = grid.hz();
675 if( benchmark) t.
tic();
686 grid_magnetic->set( grid_original->n() < 3 ? 4 : 7, grid_magnetic->Nx(), grid_magnetic->Ny());
688 if( interpolation_method ==
"dg-const" || interpolation_method ==
"dg")
690 grid_fine = grid_original;
691 if( interpolation_method ==
"dg-const")
697 m_forw = dg::create::smoothing( *grid_transform);
699 grid_fine->multiplyCellNumbers((
double)mx, (
double)my);
703 grid_original->set( 1, grid.gx().size(), grid.gy().size());
704 grid_original3d->set( 1, grid.gx().size(), grid.gy().size(), grid.gz().size());
706 if( interpolation_method ==
"linear")
712 tmp.y0(), tmp.y1(), tmp.n(), tmp.Nx(), tmp.Ny(),
713 tmp.bcx(), tmp.bcy());
716 if ( interpolation_method ==
"linear-const")
718 grid_fine = grid_original;
719 grid_fine->multiplyCellNumbers((
double)mx, (
double)my);
726 std::cout <<
"# DS: High order grid gen took: "<<t.
diff()<<
"\n";
730 std::array<thrust::host_vector<double>,3> yp_trafo, ym_trafo, yp, ym;
731 thrust::host_vector<bool> in_boxp, in_boxm;
732 thrust::host_vector<double> hbp, hbm;
733 thrust::host_vector<double> vol =
dg::tensor::volume(grid_transform3d->metric()), vol2d0;
734 auto vol2d =
dg::split( vol, *grid_transform3d);
736 detail::integrate_all_fieldlines2d( vec, *grid_magnetic, *grid_transform,
737 yp_trafo, vol2d0, hbp, in_boxp, deltaPhi, eps);
738 detail::integrate_all_fieldlines2d( vec, *grid_magnetic, *grid_transform,
739 ym_trafo, vol2d0, hbm, in_boxm, -deltaPhi, eps);
744 *grid_transform,
dg::NEU,
dg::NEU, grid_transform->n() < 3 ?
"cubic" :
"dg");
747 for(
int i=0; i<2; i++)
756 std::cout <<
"# DS: Computing all points took: "<<t.
diff()<<
"\n";
761 if( interpolation_method ==
"dg-const" || interpolation_method ==
"dg")
764 *grid_transform, bcx, bcy,
"dg");
766 *grid_transform, bcx, bcy,
"dg");
771 *grid_original, bcx, bcy,
"linear");
773 *grid_original, bcx, bcy,
"linear");
775 cusp::multiply( plusFineTmp, forw, plusFine);
776 cusp::multiply( minusFineTmp, forw, minusFine);
778 if( mx == 1 && my == 1)
786 if( interpolation_method ==
"dg-const")
793 else if( interpolation_method ==
"dg")
795 else if( interpolation_method ==
"linear")
803 cusp::multiply( Vf, tmp, Wf);
814 cusp::multiply(
projection, minusFine, minus);
819 std::cout <<
"# DS: Multiplication PI took: "<<t.
diff()<<
"\n";
824 dg::HVec hbphi( yp_trafo[2]), hbphiP(hbphi), hbphiM(hbphi);
829 for(
unsigned i=0; i<hbphiP.size(); i++)
831 hbphiP[i] = vec.
z()(yp_trafo[0][i], yp_trafo[1][i]);
832 hbphiM[i] = vec.
z()(ym_trafo[0][i], ym_trafo[1][i]);
839 for(
unsigned i=0; i<yp_trafo[0].size(); i++)
842 yp_trafo[1][i], *grid_magnetic);
844 ym_trafo[1][i], *grid_magnetic);
862 m_f =
dg::split( (
const container&)m_hbm, *grid_transform3d);
863 m_temp =
dg::split( m_hbm, *grid_transform3d);
864 m_temp2 =
dg::split( m_hbm, *grid_transform3d);
870 thrust::host_vector<double> bbm( in_boxp.size(),0.), bbo(bbm), bbp(bbm);
871 for(
unsigned i=0; i<in_boxp.size(); i++)
873 if( !in_boxp[i] && !in_boxm[i])
875 else if( !in_boxp[i] && in_boxm[i])
877 else if( in_boxp[i] && !in_boxm[i])
885 m_deltaPhi = deltaPhi;
887 m_interpolation_method = interpolation_method;
890 m_perp_size = grid_transform->size();
893 m_temp2d = m_ghostM = m_ghostP = m_right = m_left;
897template<
class G,
class I,
class container>
899 const G& grid,
const container& in)
904 assert( m_g->Nz() % grid.Nz() == 0);
905 unsigned Nz_coarse = grid.Nz(), Nz = m_g->Nz();
906 unsigned cphi = Nz / Nz_coarse;
911 std::vector<dg::View< container>> out_split =
dg::split( out, *m_g);
912 std::vector<dg::View< const container>> in_split =
dg::split( in, grid);
913 for (
int i=0; i<(int)Nz_coarse; i++)
921 for (
int i=0; i<(int)Nz_coarse; i++)
923 for(
int j=1; j<(int)cphi; j++)
928 dg::blas2::symv( m_plus, m_temp[(i*cphi+cphi+1-j)%Nz], m_temp[i*cphi+cphi-j]);
932 for(
int i=0; i<(int)Nz_coarse; i++)
933 for(
int j=1; j<(int)cphi; j++)
935 double alpha = (double)(cphi-j)/(double)cphi;
936 double beta = (double)j/(
double)cphi;
937 dg::blas1::axpby( alpha, out_split[i*cphi+j], beta, m_temp[i*cphi+j], out_split[i*cphi+j]);
941template<
class G,
class I,
class container>
944 assert( m_g->Nz() % grid.Nz() == 0);
945 unsigned Nz_coarse = grid.Nz(), Nz = m_g->Nz();
946 unsigned cphi = Nz / Nz_coarse;
949 container helperP( in), helperM(in), tempP(in), tempM(in);
952 for(
int j=1; j<(int)cphi; j++)
966template<
class G,
class I,
class container>
974 if( m_interpolation_method ==
"dg-const")
986template<
class G,
class I,
class container>
987void Fieldaligned<G, I, container>::zero(
enum whichMatrix which,
988 const container& f, container& f0)
993 for(
unsigned i0=0; i0<m_Nz; i0++)
1001 if( ! m_have_adjoint) updateAdjoint( );
1006 if( ! m_have_adjoint) updateAdjoint( );
1012 if ( m_interpolation_method ==
"linear-const" )
1018 else if ( m_interpolation_method ==
"linear" )
1028template<
class G,
class I,
class container>
1029void Fieldaligned<G, I, container>::ePlus(
enum whichMatrix which,
1030 const container& f, container& fpe)
1035 for(
unsigned i0=0; i0<m_Nz; i0++)
1037 unsigned ip = (i0==m_Nz-1) ? 0:i0+1;
1042 if( ! m_have_adjoint) updateAdjoint( );
1060template<
class G,
class I,
class container>
1061void Fieldaligned<G, I, container>::eMinus(
enum whichMatrix which,
1062 const container& f, container& fme)
1067 for(
unsigned i0=0; i0<m_Nz; i0++)
1069 unsigned im = (i0==0) ? m_Nz-1:i0-1;
1072 if( ! m_have_adjoint) updateAdjoint( );
1092template<
class G,
class I,
class container>
1093template<
class BinaryOp,
class UnaryOp>
1095 UnaryOp unary,
unsigned p0,
unsigned rounds)
const
1099 assert( p0 < m_g->Nz());
1104 container temp(init2d), tempP(init2d), tempM(init2d);
1106 std::vector<container> plus2d(m_Nz, zero2d), minus2d(plus2d), result(plus2d);
1107 unsigned turns = rounds;
1108 if( turns ==0) turns++;
1110 for(
unsigned r=0; r<turns; r++)
1111 for(
unsigned i0=0; i0<m_Nz; i0++)
1115 unsigned rep = r*m_Nz + i0;
1116 for(
unsigned k=0; k<rep; k++)
1133 for(
unsigned i0=0; i0<m_Nz; i0++)
1135 int idx = (int)i0 - (
int)p0;
1137 result[i0] = plus2d[idx];
1139 result[i0] = minus2d[abs(idx)];
1140 thrust::copy( result[i0].begin(), result[i0].end(), vec3d.begin() + i0*m_perp_size);
1145 for(
unsigned i0=0; i0<m_Nz; i0++)
1147 unsigned revi0 = (m_Nz - i0)%m_Nz;
1152 for(
unsigned i0=0; i0<m_Nz; i0++)
1154 int idx = ((int)i0 -(
int)p0 + m_Nz)%m_Nz;
1155 thrust::copy( result[idx].begin(), result[idx].end(), vec3d.begin() + i0*m_perp_size);
1195template<
class BinaryOp,
class UnaryOp>
1198 const CylindricalVectorLvl0& vec,
1199 const BinaryOp& binary,
1200 const UnaryOp& unary,
1205 unsigned Nz = grid.
Nz();
1209 std::vector<dg::HVec> plus2d(Nz, tempP), minus2d(plus2d), result(plus2d);
1212 std::array<dg::HVec,3> yy0{
1216 dg::geo::detail::DSFieldCylindrical3 cyl_field(vec);
1217 double deltaPhi = grid.
hz();
1218 double phiM0 = 0., phiP0 = 0.;
1219 unsigned turns = rounds;
1220 if( turns == 0) turns++;
1221 for(
unsigned r=0; r<turns; r++)
1222 for(
unsigned i0=0; i0<Nz; i0++)
1224 unsigned rep = r*Nz + i0;
1226 tempM = tempP = init2d;
1230 "Dormand-Prince-7-4-5", std::array<double,3>{0,0,0});
1234 for(
unsigned i=0; i<g2d->size(); i++)
1237 double phiM1 = phiM0 + deltaPhi;
1238 std::array<double,3>
1239 coords0{yy0[0][i],yy0[1][i],yy0[2][i]}, coords1;
1241 deltaPhi, *g2d, eps);
1242 yy1[0][i] = coords1[0], yy1[1][i] = coords1[1], yy1[2][i] =
1244 tempM[i] = binary( yy1[0][i], yy1[1][i]);
1247 double phiP1 = phiP0 - deltaPhi;
1248 coords0 = std::array<double,3>{xx0[0][i],xx0[1][i],xx0[2][i]};
1250 -deltaPhi, *g2d, eps);
1251 xx1[0][i] = coords1[0], xx1[1][i] = coords1[1], xx1[2][i] =
1253 tempP[i] = binary( xx1[0][i], xx1[1][i]);
1255 std::swap( yy0, yy1);
1256 std::swap( xx0, xx1);
1268 for(
unsigned i0=0; i0<Nz; i0++)
1270 int idx = (int)i0 - (
int)p0;
1272 result[i0] = plus2d[idx];
1274 result[i0] = minus2d[abs(idx)];
1275 thrust::copy( result[i0].begin(), result[i0].end(), vec3d.begin() +
1281 for(
unsigned i0=0; i0<Nz; i0++)
1283 unsigned revi0 = (Nz - i0)%Nz;
1288 for(
unsigned i0=0; i0<Nz; i0++)
1290 int idx = ((int)i0 -(
int)p0 + Nz)%Nz;
1291 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 plus(ContainerType &x, get_value_type< ContainerType > alpha)
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)
void stencil(FunctorType f, 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)
thrust::host_vector< real_type > fem_inv_weights(const RealGrid1d< real_type > &g)
dg::InverseKroneckerTriDiagonal2d< dg::HVec_t< real_type > > inv_fem_mass2d(const aRealTopology3d< real_type > &g)
dg::InverseKroneckerTriDiagonal2d< dg::HVec_t< real_type > > inv_fem_linear2const2d(const aRealTopology3d< 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 > diagonal(const thrust::host_vector< real_type > &diagonal)
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
get_host_vector< Geometry > volume(const Geometry &g)
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)
dg::IHMatrix_t< real_type > limiter_stencil(const RealGrid1d< real_type > &g, dg::bc bound)
ContainerType volume(const SparseTensor< ContainerType > &t)
IHMatrix_t< double > IHMatrix
thrust::host_vector< double > HVec
void set_dt(value_type dt)
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
void integrate(value_type t0, const ContainerType &u0, value_type t1, ContainerType &u1)
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_tmp.h:502
const container & bphi() const
bphi
Definition: fieldaligned_tmp.h:522
container interpolate_from_coarse_grid(const ProductGeometry &grid_coarse, const container &coarse)
Interpolate along fieldlines from a coarse to a fine grid in phi.
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_tmp.h:547
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_tmp.h:507
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_tmp.h:512
void set_boundaries(dg::bc bcz, double left, double right)
Set boundary conditions in the limiter region.
Definition: fieldaligned_tmp.h:442
std::string method() const
Definition: fieldaligned_tmp.h:611
const container & hbm() const
Distance between the planes and the boundary .
Definition: fieldaligned_tmp.h:497
void set_boundaries(dg::bc bcz, const container &global, double scal_left, double scal_right)
Set boundary conditions in the limiter region.
Definition: fieldaligned_tmp.h:476
const container & bphiM() const
bphi on minus plane
Definition: fieldaligned_tmp.h:527
dg::bc bcy() const
Definition: fieldaligned.h:487
double deltaPhi() const
Definition: fieldaligned.h:553
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.
Definition: fieldaligned_tmp.h:382
Fieldaligned()
do not allocate memory; no member call except construct is valid
Definition: fieldaligned_tmp.h:377
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: fieldaligned_tmp.h:419
const container & bbo() const
Mask both, 1 if fieldline intersects wall in plus direction and in minus direction,...
Definition: fieldaligned_tmp.h:542
const container & bbm() const
Mask minus, 1 if fieldline intersects wall in minus direction but not in plus direction,...
Definition: fieldaligned_tmp.h:537
const container & sqrtGp() const
Volume form on plus plane (including weights) .
Definition: fieldaligned_tmp.h:517
const container & bphiP() const
bphi on plus plane
Definition: fieldaligned_tmp.h:532
const ProductGeometry & grid() const
Grid used for construction.
Definition: fieldaligned.h:610
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.
void set_boundaries(dg::bc bcz, const container &left, const container &right)
Set boundary conditions in the limiter region.
Definition: fieldaligned_tmp.h:459
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
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_tmp.h:267
double do_compute(double R, double Z) const
Definition: fieldaligned_tmp.h:277
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_tmp.h:197
double do_compute(double R, double Z) const
Integrate fieldline until wall is reached.
Definition: fieldaligned_tmp.h:217