14 std::string tmpString;
22 bool parsing_passed =
true;
24 parsing_passed = interpretLine<std::string, std::string>(file, tmpString, tmpString);
26 parsing_passed = interpretLine<std::string, std::string, std::string>(
27 file, tmpString, tmpString, tmpString);
30 if (tmpString !=
"TRUE" && tmpString !=
"FALSE")
32 "FM2DDynamic::FM2DDynamic",
33 "The third string on the first line of 2D field "
34 "maps has to be either TRUE or FALSE");
39 if (tmpString ==
"ZX") {
46 parsing_passed = parsing_passed && interpretLine<double>(file,
frequency_m);
51 }
else if (tmpString ==
"XZ") {
58 parsing_passed = parsing_passed && interpretLine<double>(file,
frequency_m);
64 std::cerr <<
"unknown orientation of 2D dynamic fieldmap" << std::endl;
65 parsing_passed =
false;
71 parsing_passed = parsing_passed
72 && interpretLine<double, double, double, double>(
73 file, tmpDouble, tmpDouble, tmpDouble, tmpDouble);
81 if (!parsing_passed) {
85 "FM2DDynamic::FM2DDynamic",
86 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
117 std::string tmpString;
118 double tmpDouble, Ezmax = 0.0;
139 interpretLine<double, double, double, double>(
147 interpretLine<double, double, double, double>(
158 for (
size_t i = 0; i < size; ++i) {
159 if (std::abs(Ez(i)) > Ezmax) {
160 Ezmax = std::abs(Ez(i));
168 double const scaleE = 1.e6 / Ezmax;
171 for (
size_t i = 0; i < size; i++) {
186 Inform m(
"FM2DDynamic::readMap");
187 m << level3 <<
"Read in fieldmap '" <<
Filename_m <<
"'" << endl;
197 Inform m(
"FM2DDynamic::freeMap");
198 m << level3 <<
"Freed fieldmap '" <<
Filename_m <<
"'" << endl;
223 auto Rview = pc->R.getView();
224 auto Eview = pc->E.getView();
225 auto Bview = pc->B.getView();
227 const size_t nLocal = pc->getLocalNum();
229 Kokkos::parallel_for(
230 "FM2DDynamic::applyField", nLocal, KOKKOS_LAMBDA(
const size_t i) {
231 if (Rview(i)(2) >= zbegin && Rview(i)(2) < zend
232 && sqrt(Rview(i)(0) * Rview(i)(0) + Rview(i)(1) * Rview(i)(1)) < rend) {
234 Rview(i), Eview(i), Bview(i), Ez_device, Er_device, Bt_device, hr, hz,
235 zbegin, num_gridpr, num_gridpz);
241 std::shared_ptr<ParticleContainer_t> pc,
double electricScale,
double magneticScale,
242 double startField,
double endField) {
255 auto Rview = pc->R.getView();
256 auto Eview = pc->E.getView();
257 auto Bview = pc->B.getView();
259 const size_t nLocal = pc->getLocalNum();
261 Kokkos::parallel_for(
262 "FM2DDynamic::applyRFField", nLocal, KOKKOS_LAMBDA(
const size_t i) {
263 const auto& R = Rview(i);
265 if (R(2) >= startField && R(2) < endField && R(2) >= zbegin && R(2) < zend
266 && sqrt(R(0) * R(0) + R(1) * R(1)) < rend) {
270 R, tmpE, tmpB, Ez_device, Er_device, Bt_device, hr, hz, zbegin,
271 num_gridpr, num_gridpz);
273 Eview(i) += electricScale * tmpE;
274 Bview(i) += magneticScale * tmpB;
323 double& ,
double& ,
double& ,
double& ,
324 double& ,
double& )
const {
347 F[i].second = Ez(i) / 1e6;
ippl::Vector< T, Dim > Vector_t
Template PIC bunch: IPPL PicManager, shared field mesh/solver, and multiple particle containers.
bool isInside(const Vector_t< double, 3 > &r) const override
Checks if the given coordinate is inside the volume covered by the fieldmap.
FM2DDynamic(const std::string &filename)
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...
bool interpreteEOF(std::ifstream &in)
void disableFieldmapWarning()
void getLine(std::ifstream &in, std::string &buffer)
constexpr double two_pi
The value of.
constexpr double mu_0
The permeability of vacuum in Vs/Am.
std::string toUpper(const std::string &str)