OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
FM3DMagnetoStaticExtended.h
Go to the documentation of this file.
1 #ifndef CLASSIC_FM2DMAGNETOSTATICEXTENDED_HH
2 #define CLASSIC_FM2DMAGNETOSTATICEXTENDED_HH
3 
4 #include "Fields/Fieldmap.h"
5 
7 
8 public:
10 
11  virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const;
12  virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const;
13  virtual void getFieldDimensions(double &zBegin, double &zEnd) const;
14  virtual void getFieldDimensions(double &xIni, double &xFinal, double &yIni, double &yFinal, double &zIni, double &zFinal) const;
15  virtual void swap();
16  virtual void getInfo(Inform *msg);
17  virtual double getFrequency() const;
18  virtual void setFrequency(double freq);
19 
20  virtual bool isInside(const Vector_t &r) const;
21 private:
22  _FM3DMagnetoStaticExtended(const std::string& filename);
23 
24  static FM3DMagnetoStaticExtended create(const std::string& filename);
25 
26  virtual void readMap();
27  virtual void freeMap();
28 
29  struct IndexTriplet {
30  unsigned int i;
31  unsigned int j;
32  unsigned int k;
35  i(0),
36  j(0),
37  k(0),
38  weight(0.0)
39  { }
40  };
41 
42  IndexTriplet getIndex(const Vector_t &X) const;
43  unsigned long getIndex(unsigned int i, unsigned int j, unsigned int k) const;
45  double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const;
46 
47  enum { LX = 0,
48  LY = 0,
49  LZ = 0,
50  HX = 4,
51  HY = 2,
52  HZ = 1};
53 
54  void integrateBx(unsigned j);
55  void integrateBz(unsigned j);
56  void integrateBy(unsigned j);
57 
58  void smoothData(double * data, unsigned j);
59 
60  void saveField(const std::string &fname, unsigned int j) const;
61 
66  double xbegin_m;
67  double xend_m;
68  double ybegin_m;
69  double yend_m;
70  double zbegin_m;
71  double zend_m;
72  double length_m;
73  double hx_m;
74  double hy_m;
75  double hz_m;
76  unsigned int num_gridpx_m;
77  unsigned int num_gridpy_m;
78  unsigned int num_gridpz_m;
80  friend class _Fieldmap;
81 };
82 
83 inline
85 {
86  return r(2) >= 0.0 && r(2) < length_m && r(0) >= xbegin_m && r(0) < xend_m && std::abs(r(1)) < yend_m;
87 }
88 
89 inline
90 unsigned long _FM3DMagnetoStaticExtended::getIndex(unsigned int i, unsigned int j, unsigned int k) const
91 {
92  unsigned long result = i + j * num_gridpx_m;
93  result = k + result * num_gridpz_m;
94  PAssert_LT(result, num_gridpx_m * num_gridpy_m * num_gridpz_m);
95  return result;
96 }
97 
98 inline
100  IndexTriplet idx;
101  idx.i = std::floor((X(0) - xbegin_m) / hx_m);
102  idx.j = std::floor(std::abs(X(1)) / hy_m);
103  idx.k = std::floor((X(2) - zbegin_m) / hz_m);
104  PAssert_LT(idx.i, num_gridpx_m - 1);
105  PAssert_LT(idx.j, num_gridpy_m - 1);
106  PAssert_LT(idx.k, num_gridpz_m - 1);
107 
108  idx.weight(0) = (X(0) - xbegin_m) / hx_m - idx.i;
109  idx.weight(1) = std::abs(X(1)) / hy_m - idx.j;
110  idx.weight(2) = (X(2) - zbegin_m) / hz_m - idx.k;
111 
112  return idx;
113 }
114 
115 using FM3DMagnetoStaticExtended = std::shared_ptr<_FM3DMagnetoStaticExtended>;
116 
117 #endif
void saveField(const std::string &fname, unsigned int j) const
DiffDirection
Definition: Fieldmap.h:55
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Vector_t interpolateTrilinearly(const Vector_t &X) const
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
IndexTriplet getIndex(const Vector_t &X) const
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
#define PAssert_LT(a, b)
Definition: PAssert.h:106
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
Definition: Inform.h:42
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
std::shared_ptr< _FM3DMagnetoStaticExtended > FM3DMagnetoStaticExtended
Definition: Definitions.h:72
#define X(arg)
Definition: fftpack.cpp:112
float result
Definition: test.py:2
virtual bool isInside(const Vector_t &r) const
virtual void setFrequency(double freq)
void smoothData(double *data, unsigned j)
_FM3DMagnetoStaticExtended(const std::string &filename)
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Definition: PETE.h:733
static FM3DMagnetoStaticExtended create(const std::string &filename)