OPAL (Object Oriented Parallel Accelerator Library) 2022.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
8public:
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) 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;
19private:
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
80inline
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}
85
86inline
87unsigned long FM3DMagnetoStaticExtended::getIndex(unsigned int i, unsigned int j, unsigned int k) const
88{
89 unsigned long result = i + j * num_gridpx_m;
90 result = k + result * num_gridpz_m;
92 return result;
93}
94
95inline
97 IndexTriplet idx;
98 idx.i = std::floor((X(0) - xbegin_m) / hx_m);
99 idx.j = std::floor(std::abs(X(1)) / hy_m);
100 idx.k = std::floor((X(2) - zbegin_m) / hz_m);
101 PAssert_LT(idx.i, num_gridpx_m - 1);
102 PAssert_LT(idx.j, num_gridpy_m - 1);
103 PAssert_LT(idx.k, num_gridpz_m - 1);
104
105 idx.weight(0) = (X(0) - xbegin_m) / hx_m - idx.i;
106 idx.weight(1) = std::abs(X(1)) / hy_m - idx.j;
107 idx.weight(2) = (X(2) - zbegin_m) / hz_m - idx.k;
108
109 return idx;
110}
111
112#endif
DiffDirection
Definition: Fieldmap.h:54
#define X(arg)
Definition: fftpack.cpp:112
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Definition: PETE.h:733
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
#define PAssert_LT(a, b)
Definition: PAssert.h:106
FM3DMagnetoStaticExtended(std::string aFilename)
Vector_t interpolateTrilinearly(const Vector_t &X) const
void smoothData(double *data, unsigned j)
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
virtual void getInfo(Inform *msg)
IndexTriplet getIndex(const Vector_t &X) const
virtual bool isInside(const Vector_t &r) const
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual void setFrequency(double freq)
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
void saveField(const std::string &fname, unsigned int j) const
Definition: Inform.h:42