OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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:
9  virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const;
10  virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const;
11  virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const;
12  virtual void getFieldDimensions(double &xIni, double &xFinal, double &yIni, double &yFinal, double &zIni, double &zFinal) const;
13  virtual void swap();
14  virtual void getInfo(Inform *msg);
15  virtual double getFrequency() const;
16  virtual void setFrequency(double freq);
17 
18  virtual bool isInside(const Vector_t &r) const;
19 private:
20  FM3DMagnetoStaticExtended(std::string aFilename);
22 
23  virtual void readMap();
24  virtual void freeMap();
25 
26  struct IndexTriplet {
27  unsigned int i;
28  unsigned int j;
29  unsigned int k;
32  i(0),
33  j(0),
34  k(0),
35  weight(0.0)
36  { }
37  };
38 
39  IndexTriplet getIndex(const Vector_t &X) const;
40  unsigned long getIndex(unsigned int i, unsigned int j, unsigned int k) const;
42  double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const;
43 
44  enum { LX = 0,
45  LY = 0,
46  LZ = 0,
47  HX = 4,
48  HY = 2,
49  HZ = 1};
50 
51  void integrateBx(unsigned j);
52  void integrateBz(unsigned j);
53  void integrateBy(unsigned j);
54 
55  void smoothData(double * data, unsigned j);
56 
57  void saveField(const std::string &fname, unsigned int j) const;
58 
63  double xbegin_m;
64  double xend_m;
65  double ybegin_m;
66  double yend_m;
67  double zbegin_m;
68  double zend_m;
69  double length_m;
70  double hx_m;
71  double hy_m;
72  double hz_m;
73  unsigned int num_gridpx_m;
74  unsigned int num_gridpy_m;
75  unsigned int num_gridpz_m;
77  friend class Fieldmap;
78 };
79 
80 inline
82 {
83  return r(2) >= 0.0 && r(2) < length_m && r(0) >= xbegin_m && r(0) < xend_m && std::abs(r(1)) < yend_m;
84  // return r(2) >= zbegin_m && r(2) < zend_m && r(0) >= xbegin_m && r(0) < xend_m && std::abs(r(1)) < yend_m;
85 }
86 
87 inline
88 unsigned long FM3DMagnetoStaticExtended::getIndex(unsigned int i, unsigned int j, unsigned int k) const
89 {
90  unsigned long result = i + j * num_gridpx_m;
91  result = k + result * num_gridpz_m;
92  PAssert_LT(result, num_gridpx_m * num_gridpy_m * num_gridpz_m);
93  return result;
94 }
95 
96 inline
98  IndexTriplet idx;
99  idx.i = std::floor((X(0) - xbegin_m) / hx_m);
100  idx.j = std::floor(std::abs(X(1)) / hy_m);
101  idx.k = std::floor((X(2)) / hz_m);
102  // idx.k = std::floor((X(2) - zbegin_m) / hz_m);
103 
104  idx.weight(0) = (X(0) - xbegin_m) / hx_m - idx.i;
105  idx.weight(1) = std::abs(X(1)) / hy_m - idx.j;
106  idx.weight(2) = X(2) / hz_m - idx.k;
107 
108  return idx;
109 }
110 
111 #endif
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
IndexTriplet getIndex(const Vector_t &X) const
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Vector_t interpolateTrilinearly(const Vector_t &X) const
DiffDirection
Definition: Fieldmap.h:54
Definition: rbendmap.h:8
virtual bool isInside(const Vector_t &r) const
virtual void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
#define PAssert_LT(a, b)
Definition: PAssert.h:121
void saveField(const std::string &fname, unsigned int j) const
virtual void getInfo(Inform *msg)
virtual double getFrequency() const
FM3DMagnetoStaticExtended(std::string aFilename)
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
Definition: Inform.h:41
virtual void setFrequency(double freq)
void smoothData(double *data, unsigned j)
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Definition: PETE.h:816