23 std::string tmpString;
31 bool parsing_passed =
true;
33 parsing_passed = interpretLine<std::string, std::string>(file, tmpString, tmpString);
35 parsing_passed = interpretLine<std::string, std::string, std::string>(
36 file, tmpString, tmpString, tmpString);
39 if (tmpString !=
"TRUE" && tmpString !=
"FALSE")
41 "FM2DMagnetoStatic::FM2DMagnetoStatic",
42 "The third string on the first line of 2D field "
43 "maps has to be either TRUE or FALSE");
48 if (tmpString ==
"ZX") {
58 }
else if (tmpString ==
"XZ") {
69 std::cerr <<
"unknown orientation of 2D magnetostatic fieldmap" << std::endl;
70 parsing_passed =
false;
75 parsing_passed && interpretLine<double, double>(file, tmpDouble, tmpDouble);
83 if (!parsing_passed) {
87 "FM2DMagnetoStatic::FM2DMagnetoStatic",
88 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
116 std::string tmpString;
134 interpretLine<double, double>(
144 interpretLine<double, double>(
158 if (std::abs(Bz(i)) > Bzmax) {
159 Bzmax = std::abs(Bz(i));
164 for (
size_t i = 0; i < size; ++i) {
207 auto Rview = pc->R.getView();
208 auto Bview = pc->B.getView();
209 const size_t nLocal = pc->getLocalNum();
211 Kokkos::parallel_for(
212 "FM2DMagnetoStatic::applyField", nLocal, KOKKOS_LAMBDA(
const size_t i) {
214 if (Rview(i)(2) >= zbegin && Rview(i)(2) < zend
215 && sqrt(Rview(i)(0) * Rview(i)(0) + Rview(i)(1) * Rview(i)(1)) < rend) {
218 Rview(i), tmpB, Bz_device, Br_device, hr, hz, zbegin, num_gridpr,
220 Bview(i) += scale * tmpB;
270 double& xIni,
double& xFinal,
double& yIni,
double& yFinal,
double& zIni,
271 double& zFinal)
const {
272 const double radius = std::max(std::abs(
rbegin_m), std::abs(
rend_m));
ippl::Vector< T, Dim > Vector_t
Template PIC bunch: IPPL PicManager, shared field mesh/solver, and multiple particle containers.
virtual void swap() override
Swap coordinates.
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 double getFrequency() const override
Get the frequency.
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 scale=1.0) override
Apply the FM to all the particles.
virtual void getInfo(Inform *msg) override
Print info about the field map.
void freeMap() override
Pure virtual method to free the map data.
void readMap() override
Pure virtual method to read the map data. Called by the public static readMap().
Kokkos::DualView< double * > FieldstrengthBz_m
Fieldstrengths.
static KOKKOS_INLINE_FUNCTION void computeField(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B, const ViewType &Bz, const ViewType &Br, double hr, double hz, double zbegin, int num_gridpr, int num_gridpz)
Computes the magnetic field B at the position R by interpolating from the fieldmap specified by Bz,...
FM2DMagnetoStatic(std::string aFilename)
Constructor for 2D magnetostatic field map. Parses the file header to read grid parameters:
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 setFrequency(double freq) override
Set the frequency.
bool isInside(const Vector_t< double, 3 > &r) const override
Checks if the given coordinate is inside the volume covered by the fieldmap.
double zbegin_m
Z Bounds relative to element edge.
double rbegin_m
Radius Bounds.
Kokkos::DualView< double * > FieldstrengthBr_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()
static std::string typeset_msg(const std::string &msg, const std::string &title)
void getLine(std::ifstream &in, std::string &buffer)
std::string toUpper(const std::string &str)