OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
FM3DMagnetoStatic.h
Go to the documentation of this file.
1#ifndef CLASSIC_FIELDMAP3DMAGNETOSTATIC_HH
2#define CLASSIC_FIELDMAP3DMAGNETOSTATIC_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 void getFieldDimensions(double &zBegin, double &zEnd) const;
11 virtual void getFieldDimensions(double &xIni, double &xFinal, double &yIni, double &yFinal, double &zIni, double &zFinal) const;
12 virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) 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 FM3DMagnetoStatic(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, // low X
45 LY = 0, // low Y
46 LZ = 0, // low Z
47 HX = 4, // high X
48 HY = 2, // high Y
49 HZ = 1}; // high Z
50
55 double xbegin_m;
56 double xend_m;
57
58 double ybegin_m;
59 double yend_m;
60
61 double zbegin_m;
62 double zend_m;
63
64 double hx_m;
65 double hy_m;
66 double hz_m;
67 unsigned int num_gridpx_m;
68 unsigned int num_gridpy_m;
69 unsigned int num_gridpz_m;
71 friend class Fieldmap;
72};
73
74inline
76{
77 return ((r(0) >= xbegin_m && r(0) < xend_m)
78 && (r(1) >= ybegin_m && r(1) < yend_m)
79 && (r(2) >= zbegin_m && r(2) < zend_m));
80}
81
82inline
84 return 0.0;
85}
86
87inline
88void FM3DMagnetoStatic::setFrequency(double /*freq*/) { }
89
90inline
91unsigned long FM3DMagnetoStatic::getIndex(unsigned int i, unsigned int j, unsigned int k) const
92{
93 unsigned long result = i + j * num_gridpx_m;
94 result = k + result * num_gridpz_m;
96 return result;
97}
98
99inline
101 IndexTriplet idx;
102 idx.i = std::floor((X(0) - xbegin_m) / hx_m);
103 idx.j = std::floor((X(1) - ybegin_m) / hy_m);
104 idx.k = std::floor((X(2) - zbegin_m)/ hz_m);
105 PAssert_LT(idx.i, num_gridpx_m - 1);
106 PAssert_LT(idx.j, num_gridpy_m - 1);
107 PAssert_LT(idx.k, num_gridpz_m - 1);
108
109 idx.weight(0) = (X(0) - xbegin_m) / hx_m - idx.i;
110 idx.weight(1) = (X(1) - ybegin_m) / hy_m - idx.j;
111 idx.weight(2) = (X(2) - zbegin_m) / hz_m - idx.k;
112
113 return idx;
114}
115
116#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
#define PAssert_LT(a, b)
Definition: PAssert.h:106
unsigned int num_gridpz_m
virtual double getFrequency() const
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
virtual void setFrequency(double freq)
IndexTriplet getIndex(const Vector_t &X) const
virtual bool isInside(const Vector_t &r) const
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
virtual void freeMap()
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
unsigned int num_gridpx_m
virtual void readMap()
Vector_t interpolateTrilinearly(const Vector_t &X) const
virtual void getInfo(Inform *msg)
FM3DMagnetoStatic(std::string aFilename)
unsigned int num_gridpy_m
Definition: Inform.h:42