14 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
15 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
16 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
19 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
20 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
21 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
22 inFile >> BasicDistance1[0][0] >> BasicDistance1[1][0] >> BasicDistance1[2][0];
23 inFile >> BasicDistance1[0][1] >> BasicDistance1[1][1] >> BasicDistance1[2][1];
24 inFile >> BasicDistance1[0][2] >> BasicDistance1[1][2] >> BasicDistance1[2][2];
25 inFile >> BasicDistance2[0][0] >> BasicDistance2[1][0] >> BasicDistance2[2][0];
26 inFile >> BasicDistance2[0][1] >> BasicDistance2[1][1] >> BasicDistance2[2][1];
27 inFile >> BasicDistance2[0][2] >> BasicDistance2[1][2] >> BasicDistance2[2][2];
28 inFile >> EasyCoordinate[0] >> EasyCoordinate[1] >> EasyCoordinate[2];
31 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
32 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
33 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
36 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
37 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
38 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
39 inFile >> BasicDistance1[0][0] >> BasicDistance1[1][0] >> BasicDistance1[2][0];
40 inFile >> BasicDistance1[0][1] >> BasicDistance1[1][1] >> BasicDistance1[2][1];
41 inFile >> BasicDistance1[0][2] >> BasicDistance1[1][2] >> BasicDistance1[2][2];
42 inFile >> BasicDistance2[0][0] >> BasicDistance2[1][0] >> BasicDistance2[2][0];
43 inFile >> BasicDistance2[0][1] >> BasicDistance2[1][1] >> BasicDistance2[2][1];
44 inFile >> BasicDistance2[0][2] >> BasicDistance2[1][2] >> BasicDistance2[2][2];
45 inFile >> EasyCoordinate[0] >> EasyCoordinate[1] >> EasyCoordinate[2];
48 inFile >> NumberOfPoints[0] >> NumberOfPoints[1] >> NumberOfPoints[2];
49 inFile >> ReferencePoint[0] >> ReferencePoint[1] >> ReferencePoint[2];
50 inFile >> BasicDistance0[0] >> BasicDistance0[1] >> BasicDistance0[2];
51 inFile >> RParAsFunOfPhi[0] >> RParAsFunOfPhi[1] >> RParAsFunOfPhi[2] >> RParAsFunOfPhi[3];
59 int nLines = NumberOfPoints[0] * NumberOfPoints[1] * NumberOfPoints[2];
60 FieldValues.reserve(
nLines);
62 for (
int iLine = 0; iLine <
nLines; ++iLine) {
64 FieldEntry.
putB3(Bx, By, Bz);
65 FieldValues.push_back(FieldEntry);
71 if (lastEntry !=
"complete") {
73 cout <<
"error during file reading: file is not complete" << endl;
83 cout <<
" grid type = " <<
type <<
" --> not determined" << endl;
85 cout <<
" grid type = " <<
type <<
" --> (x,y,z) cube" << endl;
87 cout <<
" grid type = " <<
type <<
" --> (x,y,z) trapezoid" << endl;
89 cout <<
" grid type = " <<
type <<
" --> (r,phi,z) cube" << endl;
91 cout <<
" grid type = " <<
type <<
" --> (r,phi,z) trapezoid" << endl;
93 cout <<
" grid type = " <<
type <<
" --> (r,phi,z) 1/sin(phi)" << endl;
99 double dB[3] = {0., 0., 0.};
105 int index0[3] = {0, 0, 0};
106 int index1[3] = {0, 0, 0};
107 for (
int i = 0;
i < 3; ++
i) {
108 if (NumberOfPoints[
i] > 1) {
110 if (index0[
i] > NumberOfPoints[
i] - 2)
111 index0[
i] = NumberOfPoints[
i] - 2;
113 if (index1[
i] > NumberOfPoints[
i] - 1)
114 index1[
i] = NumberOfPoints[
i] - 1;
121 putIndicesGetB(index0[0], index0[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
122 putIndGetCoord(index0[0], index0[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
123 MagInterpol.
defineCellPoint000(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
124 putIndicesGetB(index1[0], index0[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
125 putIndGetCoord(index1[0], index0[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
126 MagInterpol.
defineCellPoint100(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
127 putIndicesGetB(index0[0], index1[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
128 putIndGetCoord(index0[0], index1[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
129 MagInterpol.
defineCellPoint010(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
130 putIndicesGetB(index1[0], index1[1], index0[2], tmpB[0], tmpB[1], tmpB[2]);
131 putIndGetCoord(index1[0], index1[1], index0[2], tmpX[0], tmpX[1], tmpX[2]);
132 MagInterpol.
defineCellPoint110(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
133 putIndicesGetB(index0[0], index0[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
134 putIndGetCoord(index0[0], index0[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
135 MagInterpol.
defineCellPoint001(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
136 putIndicesGetB(index1[0], index0[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
137 putIndGetCoord(index1[0], index0[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
138 MagInterpol.
defineCellPoint101(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
139 putIndicesGetB(index0[0], index1[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
140 putIndGetCoord(index0[0], index1[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
141 MagInterpol.
defineCellPoint011(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
142 putIndicesGetB(index1[0], index1[1], index1[2], tmpB[0], tmpB[1], tmpB[2]);
143 putIndGetCoord(index1[0], index1[1], index1[2], tmpX[0], tmpX[1], tmpX[2]);
144 MagInterpol.
defineCellPoint111(tmpX[0], tmpX[1], tmpX[2],
double(tmpB[0]),
double(tmpB[1]),
double(tmpB[2]));
158 double pnt[3] = {X1, X2, X3};
162 for (
int i = 0;
i < 3; ++
i) {
163 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
169 for (
int i = 0;
i < 3; ++
i) {
170 if (EasyCoordinate[
i]) {
171 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
175 for (
int i = 0;
i < 3; ++
i) {
176 if (!EasyCoordinate[
i]) {
177 double stepSize = BasicDistance0[
i];
179 for (
int j = 0;
j < 3; ++
j) {
180 stepSize += BasicDistance1[
i][
j] *
index[
j];
189 for (
int i = 0;
i < 3; ++
i) {
190 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
196 for (
int i = 0;
i < 3; ++
i) {
197 if (EasyCoordinate[
i]) {
198 index[
i] =
int((pnt[
i] - ReferencePoint[
i]) / BasicDistance0[
i]);
202 for (
int i = 0;
i < 3; ++
i) {
203 if (!EasyCoordinate[
i]) {
204 double stepSize = BasicDistance0[
i];
206 for (
int j = 0;
j < 3; ++
j) {
207 stepSize += BasicDistance1[
i][
j] *
index[
j];
217 double stepSize = RParAsFunOfPhi[0] + RParAsFunOfPhi[1] /
sinPhi - RParAsFunOfPhi[2] - RParAsFunOfPhi[3] /
sinPhi;
218 stepSize = stepSize / (NumberOfPoints[0] - 1);
219 double startingPoint = RParAsFunOfPhi[2] + RParAsFunOfPhi[3] /
sinPhi;
220 index[0] =
int((pnt[0] - startingPoint) / stepSize);
221 index[1] =
int((pnt[1] - ReferencePoint[1]) / BasicDistance0[1]);
222 index[2] =
int((pnt[2] - ReferencePoint[2]) / BasicDistance0[2]);
236 FieldEntry = FieldValues.operator[](lineNumber(Index1, Index2, Index3));
237 Bx = FieldEntry.
bx();
238 By = FieldEntry.
by();
239 Bz = FieldEntry.
bz();
245 int index[3] = {Index1, Index2, Index3};
249 for (
int i = 0;
i < 3; ++
i) {
250 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
255 for (
int i = 0;
i < 3; ++
i) {
256 if (EasyCoordinate[
i]) {
257 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
259 double stepSize = BasicDistance0[
i];
261 for (
int j = 0;
j < 3; ++
j) {
262 stepSize += BasicDistance1[
i][
j] *
index[
j];
271 for (
int i = 0;
i < 3; ++
i) {
272 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
277 for (
int i = 0;
i < 3; ++
i) {
278 if (EasyCoordinate[
i]) {
279 pnt[
i] = ReferencePoint[
i] + BasicDistance0[
i] *
index[
i];
281 double stepSize = BasicDistance0[
i];
283 for (
int j = 0;
j < 3; ++
j) {
284 stepSize += BasicDistance1[
i][
j] *
index[
j];
293 pnt[2] = ReferencePoint[2] + BasicDistance0[2] *
index[2];
294 pnt[1] = ReferencePoint[1] + BasicDistance0[1] *
index[1];
296 double stepSize = RParAsFunOfPhi[0] + RParAsFunOfPhi[1] /
sinPhi - RParAsFunOfPhi[2] - RParAsFunOfPhi[3] /
sinPhi;
297 stepSize = stepSize / (NumberOfPoints[0] - 1);
298 double startingPoint = RParAsFunOfPhi[2] + RParAsFunOfPhi[3] /
sinPhi;
299 pnt[0] = startingPoint + stepSize *
index[0];
312 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 ...