16 FieldstrengthBx_m(nullptr),
17 FieldstrengthBy_m(nullptr),
18 FieldstrengthBz_m(nullptr) {
20 std::string tmpString;
28 bool parsing_passed =
true;
30 parsing_passed = interpretLine<std::string>(file, tmpString);
32 parsing_passed = interpretLine<std::string, std::string>(file, tmpString, tmpString);
35 if (tmpString !=
"TRUE" &&
38 "The second string on the first line of 3D field "
39 "maps has to be either TRUE or FALSE");
43 parsing_passed = (parsing_passed &&
45 parsing_passed = (parsing_passed &&
47 parsing_passed = (parsing_passed &&
51 parsing_passed = parsing_passed && interpretLine<double>(file, tmpDouble);
54 parsing_passed = parsing_passed &&
64 "Format of fieldmap '" +
Filename_m +
"' didn't pass basic test");
86 "Couldn't read fieldmap '" +
Filename_m +
"'");
103 std::string tmpString;
118 unsigned long index =
getIndex(i,0,k);
131 unsigned int centerX =
static_cast<unsigned int>(std::round(-
xbegin_m /
hx_m));
142 unsigned long index =
getIndex(i,0,k);
169 unsigned long index =
getIndex(i,j,k);
178 unsigned long index =
getIndex(i,j,k);
187 unsigned long index =
getIndex(i,j,k);
198 unsigned long index =
getIndex(i,j,k);
209 unsigned long index =
getIndex(i,j,k);
219 unsigned long index =
getIndex(i,j,k);
235 unsigned long index =
getIndex(i,j,k);
242 unsigned int index =
getIndex(i,j,k);
249 unsigned int index =
getIndex(i,j,k);
259 unsigned long index =
getIndex(i,j,k);
268 unsigned int index =
getIndex(i,j,k);
277 unsigned int index =
getIndex(i,j,k);
293 unsigned long index =
getIndex(i, j, k);
303 unsigned long index =
getIndex(i,j,k);
312 unsigned long index =
getIndex(i, j, k);
325 unsigned long index =
getIndex(i, j, k);
336 unsigned long index =
getIndex(i,j,k);
346 unsigned long index =
getIndex(i, j, k);
360 unsigned long index =
getIndex(i, j, k);
371 unsigned long index =
getIndex(i,j,k);
381 unsigned long index =
getIndex(i, j, k);
395 unsigned long index =
getIndex(i, j, k);
406 unsigned long index =
getIndex(i,j,k);
416 unsigned long index =
getIndex(i, j, k);
430 unsigned long index =
getIndex(i, j, k);
442 unsigned long index =
getIndex(i,j,k);
453 unsigned long index =
getIndex(i, j, k);
468 unsigned long index =
getIndex(i, j, k);
480 unsigned long index =
getIndex(i,j,k);
491 unsigned long index =
getIndex(i, j, k);
507 const double offWeight = 0.1, sumWeightInv = 1.0 / (1.0 + 4 * (1 + offWeight) * offWeight);
513 for (
int i2 = -1; i2 < 2; ++ i2) {
514 for (
int k2 = -1; k2 < 2; ++ k2) {
524 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
528 for (
int i2 = 0; i2 < 2; ++ i2) {
529 for (
int k2 = -1; k2 < 2; ++ k2) {
539 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
543 for (
int i2 = -1; i2 < 1; ++ i2) {
544 for (
int k2 = -1; k2 < 2; ++ k2) {
554 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
558 for (
int i2 = -1; i2 < 2; ++ i2) {
559 for (
int k2 = 0; k2 < 2; ++ k2) {
569 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
573 for (
int i2 = -1; i2 < 2; ++ i2) {
574 for (
int k2 = -1; k2 < 1; ++ k2) {
584 unsigned long index =
getIndex(0, j, 0);
585 tmp[index] = data[index];
589 tmp[index] = data[index];
593 tmp[index] = data[index];
597 tmp[index] = data[index];
602 unsigned long index =
getIndex(i, j, k);
603 data[index] = tmp[index];
612 std::ofstream out(fname);
618 unsigned long index =
getIndex(i, j, k);
619 out << std::setw(14) << x
620 << std::setw(14) << y
621 << std::setw(14) << z
679 unsigned short switchX = ((corner &
HX) >> 2), switchY = ((corner &
HY) >> 1), switchZ = (corner &
HZ);
680 double factorX = 0.5 + (1 - 2 * switchX) * (0.5 - idx.
weight(0));
681 double factorY = 0.5 + (1 - 2 * switchY) * (0.5 - idx.
weight(1));
682 double factorZ = 0.5 + (1 - 2 * switchZ) * (0.5 - idx.
weight(2));
684 unsigned long i = idx.
i + switchX, j = idx.
j + switchY, k = idx.
k + switchZ;
686 return factorX * factorY * factorZ * data[
getIndex(i, j, k)];
std::shared_ptr< _FM3DMagnetoStaticExtended > FM3DMagnetoStaticExtended
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
PETE_TBTree< FnCopysign, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > copysign(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double e
The value of.
std::string toUpper(const std::string &str)
bool interpreteEOF(std::ifstream &in)
static std::string typeset_msg(const std::string &msg, const std::string &title)
void disableFieldmapWarning()
void getLine(std::ifstream &in, std::string &buffer)
virtual bool isInside(const Vector_t &r) const
double hy_m
length between points in grid, y-direction, m
double hz_m
length between points in grid, z-direction, m
void integrateBx(unsigned j)
virtual void setFrequency(double freq)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
unsigned int num_gridpx_m
Read in number of points after 0(not counted here) in grid, x-direction.
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
double * FieldstrengthBz_m
3D array with Bz, read in like Bx
IndexTriplet getIndex(const Vector_t &X) const
void smoothData(double *data, unsigned j)
void saveField(const std::string &fname, unsigned int j) const
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
virtual void getInfo(Inform *msg)
void integrateBz(unsigned j)
double * FieldstrengthBx_m
3D array with Bx, read in first along z0 - r0 to rN then z1 - r0 to rN until zN - r0 to rN
virtual double getFrequency() const
double hx_m
length between points in grid, x-direction, m
unsigned int num_gridpz_m
Read in number of points after 0(not counted here) in grid, z-direction.
void integrateBy(unsigned j)
double * FieldstrengthBy_m
3D array with By, read in like Bx
virtual bool getFieldDerivative(const Vector_t &R, Vector_t &E, Vector_t &B, const DiffDirection &dir) const
Vector_t interpolateTrilinearly(const Vector_t &X) const
_FM3DMagnetoStaticExtended(const std::string &filename)
virtual ~_FM3DMagnetoStaticExtended()
unsigned int num_gridpy_m
Read in number of points after 0(not counted here) in grid, y-direction.
static FM3DMagnetoStaticExtended create(const std::string &filename)