20 std::string tmpString;
28 bool parsing_passed = true;
30 parsing_passed = interpretLine<std::string>(file, tmpString);
35 if (tmpString !=
"TRUE" && tmpString !=
"FALSE")
37 "FM3DMagnetoStaticExtended::FM3DMagnetoStaticExtended",
38 "The second string on the first line of 3D field "
39 "maps has to be either TRUE or FALSE");
63 if (!parsing_passed) {
67 "FM3DMagnetoStaticExtended::FM3DMagnetoStaticExtended(std::string)",
68 "Format of fieldmap '" +
Filename_m +
"' didn't pass basic test");
90 "FM3DMagnetoStaticExtended::FM3DMagnetoStaticExtended(std::string)",
91 "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));
134 if (std::abs(By) > std::abs(Bymax)) {
142 unsigned long index =
getIndex(i, 0, k);
170 unsigned long index =
getIndex(i, j, k);
180 unsigned long index =
getIndex(i, j, k);
190 unsigned long index =
getIndex(i, j, k);
202 unsigned long index =
getIndex(i, j, k);
216 unsigned long index =
getIndex(i, j, k);
229 unsigned long index =
getIndex(i, j, k);
248 unsigned long index =
getIndex(i, j, k);
256 unsigned int index =
getIndex(i, j, k);
264 unsigned int index =
getIndex(i, j, k);
275 unsigned long index =
getIndex(i, j, k);
287 unsigned int index =
getIndex(i, j, k);
299 unsigned int index =
getIndex(i, j, k);
318 unsigned long index =
getIndex(i, j, k);
332 unsigned long index =
getIndex(i, j, k);
345 unsigned long index =
getIndex(i, j, k);
362 unsigned long index =
getIndex(i, j, k);
377 unsigned long index =
getIndex(i, j, k);
391 unsigned long index =
getIndex(i, j, k);
409 unsigned long index =
getIndex(i, j, k);
424 unsigned long index =
getIndex(i, j, k);
438 unsigned long index =
getIndex(i, j, k);
456 unsigned long index =
getIndex(i, j, k);
472 unsigned long index =
getIndex(i, j, k);
486 unsigned long index =
getIndex(i, j, k);
505 unsigned long index =
getIndex(i, j, k);
522 unsigned long index =
getIndex(i, j, k);
537 unsigned long index =
getIndex(i, j, k);
557 unsigned long index =
getIndex(i, j, k);
574 unsigned long index =
getIndex(i, j, k);
589 unsigned long index =
getIndex(i, j, k);
609 const double offWeight = 0.1, sumWeightInv = 1.0 / (1.0 + 4 * (1 + offWeight) * offWeight);
615 for (
int i2 = -1; i2 < 2; ++i2) {
616 for (
int k2 = -1; k2 < 2; ++k2) {
617 double weight = std::pow(offWeight, std::abs(i2) + std::abs(k2));
618 sum += weight * data[
getIndex(i + i2, j, k + k2)];
622 tmp[
getIndex(i, j, k)] = sum * sumWeightInv;
626 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
630 for (
int i2 = 0; i2 < 2; ++i2) {
631 for (
int k2 = -1; k2 < 2; ++k2) {
632 double weight = std::pow(offWeight, std::abs(i2) + std::abs(k2));
633 sum += weight * data[
getIndex(i + i2, j, k + k2)];
637 tmp[
getIndex(i, j, k)] = sum * sumWeightInv;
641 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
645 for (
int i2 = -1; i2 < 1; ++i2) {
646 for (
int k2 = -1; k2 < 2; ++k2) {
647 double weight = std::pow(offWeight, std::abs(i2) + std::abs(k2));
648 sum += weight * data[
getIndex(i + i2, j, k + k2)];
652 tmp[
getIndex(i, j, k)] = sum * sumWeightInv;
656 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
660 for (
int i2 = -1; i2 < 2; ++i2) {
661 for (
int k2 = 0; k2 < 2; ++k2) {
662 double weight = std::pow(offWeight, std::abs(i2) + std::abs(k2));
663 sum += weight * data[
getIndex(i + i2, j, k + k2)];
667 tmp[
getIndex(i, j, k)] = sum * sumWeightInv;
671 const double sumWeightInv = 1.0 / (1.0 + (3 + 2 * offWeight) * offWeight);
675 for (
int i2 = -1; i2 < 2; ++i2) {
676 for (
int k2 = -1; k2 < 1; ++k2) {
677 double weight = std::pow(offWeight, std::abs(i2) + std::abs(k2));
678 sum += weight * data[
getIndex(i + i2, j, k + k2)];
682 tmp[
getIndex(i, j, k)] = sum * sumWeightInv;
686 unsigned long index =
getIndex(0, j, 0);
687 tmp[index] = data[index];
691 tmp[index] = data[index];
695 tmp[index] = data[index];
699 tmp[index] = data[index];
704 unsigned long index =
getIndex(i, j, k);
705 data[index] = tmp[index];
713 std::ofstream out(fname);
719 unsigned long index =
getIndex(i, j, k);
720 out << std::setw(14) << x << std::setw(14) << y << std::setw(14) << z << std::setw(14)
782 double* data,
const IndexTriplet& idx,
unsigned short corner)
const {
783 unsigned short switchX = ((corner &
HX) >> 2), switchY = ((corner &
HY) >> 1),
784 switchZ = (corner &
HZ);
785 double factorX = 0.5 + (1 - 2 * switchX) * (0.5 - idx.
weight(0));
786 double factorY = 0.5 + (1 - 2 * switchY) * (0.5 - idx.
weight(1));
787 double factorZ = 0.5 + (1 - 2 * switchZ) * (0.5 - idx.
weight(2));
789 unsigned long i = idx.
i + switchX, j = idx.
j + switchY, k = idx.
k + switchZ;
791 return factorX * factorY * factorZ * data[
getIndex(i, j, k)];
798 suppB(0) *= copysign(1, R(1));
799 suppB(2) *= copysign(1, R(1));
819 double& xIni,
double& xFinal,
double& yIni,
double& yFinal,
double& zIni,
820 double& zFinal)
const {
834 <<
" m; zfinal= " <<
zend_m <<
" m;" << endl;
ippl::Vector< T, Dim > Vector_t
std::string toUpper(const std::string &str)
bool interpreteEOF(std::ifstream &in)
void disableFieldmapWarning()
static std::string typeset_msg(const std::string &msg, const std::string &title)
bool interpretLine(std::ifstream &in, S &value, const bool &file_length_known=true)
void getLine(std::ifstream &in, std::string &buffer)
double * FieldstrengthBx_m
void integrateBy(unsigned j)
virtual bool getFieldDerivative(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, const DiffDirection &dir) const
FM3DMagnetoStaticExtended(std::string aFilename)
void smoothData(double *data, unsigned j)
double * FieldstrengthBy_m
virtual bool getFieldstrength(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) const
void integrateBx(unsigned j)
double getWeightedData(double *data, const IndexTriplet &idx, unsigned short corner) const
double * FieldstrengthBz_m
virtual void getInfo(Inform *msg)
unsigned int num_gridpy_m
~FM3DMagnetoStaticExtended()
unsigned int num_gridpz_m
unsigned int num_gridpx_m
virtual bool isInside(const Vector_t< double, 3 > &r) const
virtual void setFrequency(double freq)
virtual void getFieldDimensions(double &zBegin, double &zEnd) const
void saveField(const std::string &fname, unsigned int j) const
virtual double getFrequency() const
IndexTriplet getIndex(const Vector_t< double, 3 > &X) const
Vector_t< double, 3 > interpolateTrilinearly(const Vector_t< double, 3 > &X) const
void integrateBz(unsigned j)
Vector_t< double, 3 > weight