13 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
14 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
15 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
18 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
19 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
20 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
21 inFile >> BasicDistance1[0][0] >> BasicDistance1[1][0] >> BasicDistance1[2][0];
22 inFile >> BasicDistance1[0][1] >> BasicDistance1[1][1] >> BasicDistance1[2][1];
23 inFile >> BasicDistance1[0][2] >> BasicDistance1[1][2] >> BasicDistance1[2][2];
24 inFile >> BasicDistance2[0][0] >> BasicDistance2[1][0] >> BasicDistance2[2][0];
25 inFile >> BasicDistance2[0][1] >> BasicDistance2[1][1] >> BasicDistance2[2][1];
26 inFile >> BasicDistance2[0][2] >> BasicDistance2[1][2] >> BasicDistance2[2][2];
27 inFile >> EasyCoordinate[0] >> EasyCoordinate[1] >> EasyCoordinate[2];
30 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
31 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
32 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
35 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
36 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
37 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
38 inFile >> BasicDistance1[0][0] >> BasicDistance1[1][0] >> BasicDistance1[2][0];
39 inFile >> BasicDistance1[0][1] >> BasicDistance1[1][1] >> BasicDistance1[2][1];
40 inFile >> BasicDistance1[0][2] >> BasicDistance1[1][2] >> BasicDistance1[2][2];
41 inFile >> BasicDistance2[0][0] >> BasicDistance2[1][0] >> BasicDistance2[2][0];
42 inFile >> BasicDistance2[0][1] >> BasicDistance2[1][1] >> BasicDistance2[2][1];
43 inFile >> BasicDistance2[0][2] >> BasicDistance2[1][2] >> BasicDistance2[2][2];
44 inFile >> EasyCoordinate[0] >> EasyCoordinate[1] >> EasyCoordinate[2];
47 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
48 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
49 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
50 inFile >> RParAsFunOfPhi[0] >> RParAsFunOfPhi[1] >> RParAsFunOfPhi[2] >> RParAsFunOfPhi[3];
58 int nLines = NumberOfPoints[0] * NumberOfPoints[1] * NumberOfPoints[2];
59 FieldValues.reserve(
nLines);
61 for (
int iLine = 0; iLine <
nLines; ++iLine) {
62 inFile >> Bx >> By >> Bz;
63 FieldEntry.
putB3(Bx, By, Bz);
64 FieldValues.push_back(FieldEntry);
70 if (lastEntry !=
"complete") {
72 cout <<
"error during file reading: file is not complete" << endl;
82 cout <<
" grid type = " <<
type <<
" --> not determined" << endl;
84 cout <<
" grid type = " <<
type <<
" --> (x,y,z) cube" << endl;
86 cout <<
" grid type = " <<
type <<
" --> (x,y,z) trapezoid" << endl;
88 cout <<
" grid type = " <<
type <<
" --> (r,phi,z) cube" << endl;
90 cout <<
" grid type = " <<
type <<
" --> (r,phi,z) trapezoid" << endl;
92 cout <<
" grid type = " <<
type <<
" --> (r,phi,z) 1/sin(phi)" << endl;
98 double dB[3] = {0., 0., 0.};
104 int index0[3] = {0, 0, 0};
105 int index1[3] = {0, 0, 0};
106 for (
int i = 0;
i < 3; ++
i) {
107 if (NumberOfPoints[
i] > 1) {
109 if (index0[
i] > NumberOfPoints[
i] - 2)
110 index0[
i] = NumberOfPoints[
i] - 2;
112 if (index1[
i] > NumberOfPoints[
i] - 1)
113 index1[
i] = NumberOfPoints[
i] - 1;
120 putIndicesGetB(index0[0], index0[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
121 putIndGetCoord(index0[0], index0[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
122 MagInterpol.
defineCellPoint000(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
123 putIndicesGetB(index1[0], index0[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
124 putIndGetCoord(index1[0], index0[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
125 MagInterpol.
defineCellPoint100(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
126 putIndicesGetB(index0[0], index1[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
127 putIndGetCoord(index0[0], index1[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
128 MagInterpol.
defineCellPoint010(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
129 putIndicesGetB(index1[0], index1[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
130 putIndGetCoord(index1[0], index1[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
131 MagInterpol.
defineCellPoint110(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
132 putIndicesGetB(index0[0], index0[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
133 putIndGetCoord(index0[0], index0[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
134 MagInterpol.
defineCellPoint001(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
135 putIndicesGetB(index1[0], index0[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
136 putIndGetCoord(index1[0], index0[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
137 MagInterpol.
defineCellPoint101(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
138 putIndicesGetB(index0[0], index1[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
139 putIndGetCoord(index0[0], index1[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
140 MagInterpol.
defineCellPoint011(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
141 putIndicesGetB(index1[0], index1[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
142 putIndGetCoord(index1[0], index1[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
143 MagInterpol.
defineCellPoint111(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
157 double pnt[3] = {X1, X2, X3};
161 for (
int i = 0;
i < 3; ++
i) {
162 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
168 for (
int i = 0;
i < 3; ++
i) {
169 if (EasyCoordinate[
i]) {
170 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
174 for (
int i = 0;
i < 3; ++
i) {
175 if (!EasyCoordinate[
i]) {
176 double stepSize = BasicDistance0[
i];
178 for (
int j = 0;
j < 3; ++
j) {
179 stepSize += BasicDistance1[
i][
j] *
index[
j];
188 for (
int i = 0;
i < 3; ++
i) {
189 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
195 for (
int i = 0;
i < 3; ++
i) {
196 if (EasyCoordinate[
i]) {
197 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
201 for (
int i = 0;
i < 3; ++
i) {
202 if (!EasyCoordinate[
i]) {
203 double stepSize = BasicDistance0[
i];
205 for (
int j = 0;
j < 3; ++
j) {
206 stepSize += BasicDistance1[
i][
j] *
index[
j];
216 double stepSize = RParAsFunOfPhi[0] + RParAsFunOfPhi[1] /
sinPhi - RParAsFunOfPhi[2] - RParAsFunOfPhi[3] /
sinPhi;
217 stepSize = stepSize / (NumberOfPoints[0] - 1);
218 double startingPoint = RParAsFunOfPhi[2] + RParAsFunOfPhi[3] /
sinPhi;
219 index[0] =
int((pnt[0] - startingPoint) / stepSize);
220 index[1] =
int((pnt[1] - ReferencePoint[1]) / BasicDistance0[1]);
221 index[2] =
int((pnt[2] - ReferencePoint[2]) / BasicDistance0[2]);
235 FieldEntry = FieldValues.operator[](lineNumber(Index1, Index2, Index3));
236 Bx = FieldEntry.
bx();
237 By = FieldEntry.
by();
238 Bz = FieldEntry.
bz();
244 int index[3] = {Index1, Index2, Index3};
248 for (
int i = 0;
i < 3; ++
i) {
249 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
254 for (
int i = 0;
i < 3; ++
i) {
255 if (EasyCoordinate[
i]) {
256 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
258 double stepSize = BasicDistance0[
i];
260 for (
int j = 0;
j < 3; ++
j) {
261 stepSize += BasicDistance1[
i][
j] *
index[
j];
270 for (
int i = 0;
i < 3; ++
i) {
271 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
276 for (
int i = 0;
i < 3; ++
i) {
277 if (EasyCoordinate[
i]) {
278 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
280 double stepSize = BasicDistance0[
i];
282 for (
int j = 0;
j < 3; ++
j) {
283 stepSize += BasicDistance1[
i][
j] *
index[
j];
292 pnt[2] = ReferencePoint[2] + BasicDistance0[2] *
index[2];
293 pnt[1] = ReferencePoint[1] + BasicDistance0[1] *
index[1];
295 double stepSize = RParAsFunOfPhi[0] + RParAsFunOfPhi[1] /
sinPhi - RParAsFunOfPhi[2] - RParAsFunOfPhi[3] /
sinPhi;
296 stepSize = stepSize / (NumberOfPoints[0] - 1);
297 double startingPoint = RParAsFunOfPhi[2] + RParAsFunOfPhi[3] /
sinPhi;
298 pnt[0] = startingPoint + stepSize *
index[0];
311 return Index1 * NumberOfPoints[1] * NumberOfPoints[2] + Index2 * NumberOfPoints[2] + Index3;
void load(const std::string &name)
load grid binary file
void putCoordGetInd(double X1, double X2, double X3, int &Index1, int &Index2, int &Index3)
void defineCellPoint100(double X1, double X2, double X3, double F1, double F2, double F3)
void putB3(float Bx, float By, float Bz)
Sin< T >::type sin(const T &t)
int gridType()
returns value of GridType (and eventually prints the type + short description)
void defineCellPoint110(double X1, double X2, double X3, double F1, double F2, double F3)
void putIndGetCoord(int Index1, int Index2, int Index3, double &X1, double &X2, double &X3)
void defineCellPoint101(double X1, double X2, double X3, double F1, double F2, double F3)
void putSCoordGetVField(double X1, double X2, double X3, double &F1, double &F2, double &F3)
receive the interpolated field (out) at any point in space (in)
void defineCellPoint010(double X1, double X2, double X3, double F1, double F2, double F3)
int lineNumber(int Index1, int Index2, int Index3)
void defineCellPoint111(double X1, double X2, double X3, double F1, double F2, double F3)
void defineCellPoint000(double X1, double X2, double X3, double F1, double F2, double F3)
provide the interpolation algorithm with 8 points, where the field is known (in)
void putIndicesGetB(int Index1, int Index2, int Index3, float &Bx, float &By, float &Bz)
void defineCellPoint001(double X1, double X2, double X3, double F1, double F2, double F3)
void defineCellPoint011(double X1, double X2, double X3, double F1, double F2, double F3)
void interpolateAtPoint(double X1, double X2, double X3, float &Bx, float &By, float &Bz)
interpolates the magnetic field at input coordinate point and returns field values ...