13 FieldstrengthBz_m(nullptr),
14 FieldstrengthBx_m(nullptr),
15 FieldstrengthBy_m(nullptr) {
16 std::string tmpString;
23 bool parsing_passed =
true;
25 interpretLine<std::string>(file, tmpString);
27 parsing_passed = interpretLine<std::string, std::string>(file, tmpString, tmpString);
30 if (tmpString !=
"TRUE" && tmpString !=
"FALSE")
32 "FM3DMagnetoStatic::FM3DMagnetoStatic",
33 "The second string on the first line of 3D field "
34 "maps has to be either TRUE or FALSE");
49 for (
unsigned long i = 0;
53 parsing_passed && interpretLine<double>(file, tmpDouble, tmpDouble, tmpDouble);
60 if (!parsing_passed) {
62 "FM3DMagnetoStatic::FM3DMagnetoStatic",
63 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
82 "FM3DMagnetoStatic::FM3DMagnetoStatic",
83 "An error occured when reading the fieldmap '" +
Filename_m +
"'");
94 std::string tmpString;
110 interpretLine<double>(
121 unsigned int centerX =
static_cast<unsigned int>(std::round(-
xbegin_m /
hx_m));
122 unsigned int centerY =
static_cast<unsigned int>(std::round(-
ybegin_m /
hy_m));
125 if (std::abs(By) > Bymax) {
126 Bymax = std::abs(By);
131 for (
size_t i = 0; i < totalSize; ++i) {
208 double* data,
const IndexTriplet& idx,
unsigned short corner)
const {
209 unsigned short switchX = ((corner &
HX) >> 2), switchY = ((corner &
HY) >> 1),
210 switchZ = (corner &
HZ);
211 double factorX = 0.5 + (1 - 2 * switchX) * (0.5 - idx.
weight(0));
212 double factorY = 0.5 + (1 - 2 * switchY) * (0.5 - idx.
weight(1));
213 double factorZ = 0.5 + (1 - 2 * switchZ) * (0.5 - idx.
weight(2));
215 unsigned long i = idx.
i + switchX, j = idx.
j + switchY, k = idx.
k + switchZ;
217 return factorX * factorY * factorZ * data[
getIndex(i, j, k)];
231 double& ,
double& ,
double& ,
double& ,
double& ,
239 (*msg) <<
Filename_m <<
" (3D magnetostatic) "
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double e
The value of.
std::string toUpper(const std::string &str)
std::unique_ptr< Inform > Info
bool interpreteEOF(std::ifstream &in)
static std::string typeset_msg(const std::string &msg, const std::string &title)
void getLine(std::ifstream &in, std::string &buffer)
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const
virtual bool isInside(const Vector_t< double, 3 > &r) const
double * FieldstrengthBz_m
3D array with Bz
unsigned int num_gridpz_m
Read in number of points after 0(not counted here) in grid, z-direction.
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
double * FieldstrengthBy_m
3D array with By
double hz_m
length between points in grid, z-direction
IndexTriplet getIndex(const Vector_t< double, 3 > &X) const
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
double * FieldstrengthBx_m
3D array with Bx
unsigned int num_gridpx_m
Read in number of points after 0(not counted here) in grid, r-direction.
Vector_t< double, 3 > interpolateTrilinearly(const Vector_t< double, 3 > &X) const
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const
virtual void getInfo(Inform *msg)
double hx_m
length between points in grid, x-direction
FM3DMagnetoStatic(std::string aFilename)
double hy_m
length between points in grid, y-direction
unsigned int num_gridpy_m
Read in number of points after 0(not counted here) in grid, r-direction.
Vector_t< double, 3 > weight