1#ifndef OPALX_FIELDMAP_HH
2#define OPALX_FIELDMAP_HH
4#define READ_BUFFER_LENGTH 256
105 static void readMap(std::string Filename);
111 static void freeMap(std::string Filename);
113 static std::string
typeset_msg(
const std::string& msg,
const std::string& title);
123 virtual void applyField(std::shared_ptr<ParticleContainer_t> pc,
double scale = 1.0) = 0;
167 double& xIni,
double& xFinal,
double& yIni,
double& yFinal,
double& zIni,
168 double& zFinal)
const = 0;
189 const double& bendAngle,
const double& entranceAngle,
const double& exitAngle);
194 std::vector<double>& engeCoeffsEntry, std::vector<double>& engeCoeffsExit);
197 double& entranceParameter1,
double& entranceParameter2,
double& entranceParameter3);
200 double& exitParameter1,
double& exitParameter2,
double& exitParameter3);
208 virtual void getOnaxisEz(std::vector<std::pair<double, double>>& onaxis);
239 static void getLine(std::ifstream& in,
int& lines_read, std::string& buffer);
242 bool interpretLine(std::ifstream& in, S& value,
const bool& file_length_known =
true);
244 template <
class S,
class T>
246 std::ifstream& in, S& value1,
T& value2,
const bool& file_length_known =
true);
248 template <
class S,
class T,
class U>
250 std::ifstream& in, S& value1,
T& value2, U& value3,
251 const bool& file_length_known =
true);
253 template <
class S,
class T,
class U,
class V>
255 std::ifstream& in, S& value1,
T& value2, U& value3, V& value4,
256 const bool& file_length_known =
true);
260 std::ifstream& in, S& value1, S& value2, S& value3, S& value4, S& value5, S& value6,
261 const bool& file_length_known =
true);
266 const std::ios_base::iostate& state,
const bool& read_all,
const std::string& error_msg,
267 const std::string& found);
280 unsigned int accuracy, std::pair<double, double> fieldDimensions,
double deltaZ,
281 const std::vector<double>& fourierCoefficients,
gsl_spline* splineCoefficients,
285 unsigned int accuracy,
double length,
const std::vector<double>& zSampling,
286 const std::vector<double>& fourierCoefficients,
gsl_spline* splineCoefficients,
290 unsigned int nx,
unsigned int ny,
unsigned int nz,
291 const std::pair<double, double>& xrange,
const std::pair<double, double>& yrange,
296 template <
typename T>
310 : Type(aType), Map(aMap), RefCounter(1), read(false) {}
ippl::Vector< T, Dim > Vector_t
#define READ_BUFFER_LENGTH
@ T2DElectroStatic_cspline
@ T2DMagnetoStatic_cspline
@ T3DMagnetoStatic_Extended
@ T3DMagnetoStaticH5Block
Accelerator caching last interval indices.
Base class for the linear and cubic interpolation spline classes.
Abstract base class for all field maps. It acts as a factory for creating specific field map types ba...
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const =0
Get the field strength at a given point.
virtual void getInfo(Inform *msg)=0
Print info about the field map.
virtual void getFieldDimensions(double &zBegin, double &zEnd) const =0
Get the longitudinal dimensions of the field.
static Fieldmap * getFieldmap(std::string Filename, bool fast=false)
Get a field map instance. Use this factory method to obtain a field map. It checks the cache (Fieldma...
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const =0
Get the field derivative with respect to a direction.
static void deleteFieldmap(std::string Filename)
Delete a specific field map from the cache and memory.
static std::string alpha_numeric
static std::map< std::string, FieldmapDescription > FieldmapDictionary
static MapType readHeader(std::string Filename)
Read the header of a field map file to determine its type.
virtual void setFrequency(double freq)=0
Set the frequency.
bool interpreteEOF(std::ifstream &in)
virtual void setFieldLength(const double &)
virtual void freeMap()=0
Pure virtual method to free the map data.
void missingValuesWarning()
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &onaxis)
virtual void swap()=0
Swap coordinates (implementation dependent).
virtual void get1DProfile1EntranceParam(double &entranceParameter1, double &entranceParameter2, double &entranceParameter3)
virtual void applyField(std::shared_ptr< ParticleContainer_t > pc, double scale=1.0)=0
Apply the FM to all the particles.
void checkMap(unsigned int accuracy, std::pair< double, double > fieldDimensions, double deltaZ, const std::vector< double > &fourierCoefficients, gsl_spline *splineCoefficients, gsl_interp_accel *splineAccelerator)
void lowResolutionWarning(double squareError, double maxError)
void interpretWarning(const std::ios_base::iostate &state, const bool &read_all, const std::string &error_msg, const std::string &found)
virtual void getFieldDimensions(double &xIni, double &xFinal, double &yIni, double &yFinal, double &zIni, double &zFinal) const =0
Get the full 3D bounding box of the field.
Fieldmap(const std::string &aFilename)
void disableFieldmapWarning()
virtual double getFrequency() const =0
Get the frequency.
static char buffer_m[256]
static std::vector< std::string > getListFieldmapNames()
Get a list of all loaded field map names.
static std::string typeset_msg(const std::string &msg, const std::string &title)
static void clearDictionary()
Clear the entire field map cache.
virtual double getFieldGap()
virtual void setEdgeConstants(const double &bendAngle, const double &entranceAngle, const double &exitAngle)
virtual void setFieldGap(double gap)
bool interpretLine(std::ifstream &in, S &value, const bool &file_length_known=true)
virtual bool isInside(const Vector_t< double, 3 > &) const =0
Check if a point is inside the field map.
void exceedingValuesWarning()
virtual void get1DProfile1EngeCoeffs(std::vector< double > &engeCoeffsEntry, std::vector< double > &engeCoeffsExit)
void getLine(std::ifstream &in, std::string &buffer)
virtual void get1DProfile1ExitParam(double &exitParameter1, double &exitParameter2, double &exitParameter3)
virtual void readMap()=0
Pure virtual method to read the map data. Called by the public static readMap().
void write3DField(unsigned int nx, unsigned int ny, unsigned int nz, const std::pair< double, double > &xrange, const std::pair< double, double > &yrange, const std::pair< double, double > &zrange, const std::vector< Vector_t< double, 3 > > &ef, const std::vector< Vector_t< double, 3 > > &bf)
FieldmapDescription(MapType aType, Fieldmap *aMap)