1#ifndef OPALX_FIELDMAP2DDYNAMIC_HH
2#define OPALX_FIELDMAP2DDYNAMIC_HH
6#include <Kokkos_Core.hpp>
7#include <Kokkos_DualView.hpp>
58 double& xIni,
double& xFinal,
double& yIni,
double& yFinal,
double& zIni,
59 double& zFinal)
const override;
62 virtual void swap()
override;
65 virtual void getInfo(Inform* msg)
override;
92 template <
class ViewType>
95 const ViewType& Ez,
const ViewType& Er,
const ViewType& Bt,
double hr_m,
double hz_m,
97 const double RR = sqrt(R(0) * R(0) + R(1) * R(1));
99 const int indexr = (int)floor(RR /
hr_m);
100 const double leverr = (RR /
hr_m) - indexr;
102 const int indexz = (int)floor((R(2) -
zbegin_m) /
hz_m);
103 const double leverz = (R(2) -
zbegin_m) /
hz_m - indexz;
105 if ((indexz < 0) || (indexz + 2 >
num_gridpz_m))
return;
112 const double EfieldR = (1.0 - leverz) * (1.0 - leverr) * Er(index1)
113 + leverz * (1.0 - leverr) * Er(index1 + 1)
114 + (1.0 - leverz) * leverr * Er(index2)
115 + leverz * leverr * Er(index2 + 1);
117 const double EfieldZ = (1.0 - leverz) * (1.0 - leverr) * Ez(index1)
118 + leverz * (1.0 - leverr) * Ez(index1 + 1)
119 + (1.0 - leverz) * leverr * Ez(index2)
120 + leverz * leverr * Ez(index2 + 1);
122 const double BfieldT = (1.0 - leverz) * (1.0 - leverr) * Bt(index1)
123 + leverz * (1.0 - leverr) * Bt(index1 + 1)
124 + (1.0 - leverz) * leverr * Bt(index2)
125 + leverz * leverr * Bt(index2 + 1);
128 E(0) += EfieldR * R(0) / RR;
129 E(1) += EfieldR * R(1) / RR;
130 B(0) -= BfieldT * R(1) / RR;
131 B(1) += BfieldT * R(0) / RR;
142 void applyField(std::shared_ptr<ParticleContainer_t> pc,
double)
override;
157 std::shared_ptr<ParticleContainer_t> pc,
double electricScale,
double magneticScale,
158 double startField,
double endField);
160 virtual void getOnaxisEz(std::vector<std::pair<double, double> >& F)
override;
ippl::Vector< T, Dim > Vector_t
bool isInside(const Vector_t< double, 3 > &r) const override
Checks if the given coordinate is inside the volume covered by the fieldmap.
Kokkos::DualView< double * > FieldstrengthEr_m
Kokkos::DualView< double * > FieldstrengthEz_m
Fieldstrengths.
double rbegin_m
Radius Bounds.
Kokkos::DualView< double * > FieldstrengthBt_m
virtual void swap() override
Swap coordinates.
void applyRFField(std::shared_ptr< ParticleContainer_t > pc, double electricScale, double magneticScale, double startField, double endField)
Apply the RF-scaled dynamic field map to all particles.
void freeMap() override
Pure virtual method to free the map data.
double zbegin_m
Z Bounds relative to element edge.
virtual double getFrequency() const override
Get the frequency.
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const override
Get the field derivative with respect to a direction.
virtual void getInfo(Inform *msg) override
Print info about the field map.
void readMap() override
Pure virtual method to read the map data. Called by the public static readMap().
virtual void getFieldDimensions(double &zBegin, double &zEnd) const override
Get the longitudinal dimensions of the field.
void applyField(std::shared_ptr< ParticleContainer_t > pc, double) override
Apply the FM to all the particles.
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const override
Get the field strength at a given point.
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &F) override
virtual void setFrequency(double freq) override
Set the frequency.
static KOKKOS_INLINE_FUNCTION void computeField(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const ViewType &Ez, const ViewType &Er, const ViewType &Bt, double hr_m, double hz_m, double zbegin_m, int num_gridpr_m, int num_gridpz_m)
Abstract base class for all field maps. It acts as a factory for creating specific field map types ba...