OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Fieldmap.cpp
Go to the documentation of this file.
1#include "Fields/Fieldmap.h"
2
3#include "Utility/PAssert.h"
4
6/* To be ported from OPAL
7#include "Fields/Astra1DElectroStatic.h"
8#include "Fields/Astra1DElectroStatic_fast.h"
9#include "Fields/Astra1DMagnetoStatic_fast.h"
10#include "Fields/Astra1DDynamic_fast.h"
11#include "Fields/FM1DDynamic.h"
12#include "Fields/FM1DDynamic_fast.h"
13#include "Fields/FM1DElectroStatic.h"
14#include "Fields/FM1DElectroStatic_fast.h"
15#include "Fields/FM1DMagnetoStatic.h"
16#include "Fields/FM1DMagnetoStatic_fast.h"
17#include "Fields/FM1DProfile1.h"
18#include "Fields/FM1DProfile2.h"
19#include "Fields/FM2DElectroStatic.h"
20#include "Fields/FM3DDynamic.h"
21#include "Fields/FM3DH5Block.h"
22#include "Fields/FM3DH5BlockBase.h"
23#include "Fields/FM3DH5Block_nonscale.h"
24#include "Fields/FM3DMagnetoStatic.h"
25#include "Fields/FM3DMagnetoStaticExtended.h"
26#include "Fields/FM3DMagnetoStaticH5Block.h"
27#include "Fields/FMDummy.h"
28*/
29
32#include "Fields/FM2DDynamic.h"
34
35#include "Physics/Physics.h"
37#include "Utilities/Util.h"
38
39#include "H5hut.h"
40
41#include <filesystem>
42
43#include <cctype>
44#include <cmath>
45#include <cstring>
46#include <fstream>
47#include <iomanip>
48#include <ios>
49#include <iostream>
50#include <sstream>
51
52namespace fs = std::filesystem;
53
54#define REGISTER_PARSE_TYPE(X) \
55 template <> \
56 struct Fieldmap::TypeParseTraits<X> { \
57 static const char* name; \
58 }; \
59 const char* Fieldmap::TypeParseTraits<X>::name = #X
60
72Fieldmap* Fieldmap::getFieldmap(std::string Filename, bool /*fast*/) {
73 std::map<std::string, FieldmapDescription>::iterator position =
74 FieldmapDictionary.find(Filename);
76 if (position != FieldmapDictionary.end()) {
77 (*position).second.RefCounter++;
79 return (*position).second.Map;
80 } else {
81 MapType type;
82 std::pair<std::map<std::string, FieldmapDescription>::iterator, bool> position;
84 type = readHeader(Filename);
92 switch (type) {
94 position = FieldmapDictionary.insert(
95 std::make_pair(
96 Filename,
98 T2DMagnetoStatic, new FM2DMagnetoStatic(Filename))));
99 return (*position.first).second.Map;
100 break;
101
102 case T2DDynamic:
103 position = FieldmapDictionary.insert(
104 std::make_pair(
105 Filename,
107 return (*position.first).second.Map;
108 break;
109
110 case TAstraDynamic:
111 // if (fast) {
112 // position = FieldmapDictionary.insert(std::make_pair(
113 // Filename,
114 // FieldmapDescription(TAstraDynamic, new Astra1DDynamic_fast(Filename))));
115 // } else {
116 position = FieldmapDictionary.insert(
117 std::make_pair(
118 Filename,
120 // }
121 return (*position.first).second.Map;
122 break;
123
125 // if (fast) {
126 // position = FieldmapDictionary.insert(
127 // std::make_pair(
128 // Filename,
129 // FieldmapDescription(TAstraMagnetoStatic,
130 // Astra1DMagnetoStatic_fast(Filename))));
131 // } else {
132 position = FieldmapDictionary.insert(
133 std::make_pair(
134 Filename,
137 // }
138 return (*position.first).second.Map;
139 break;
140
141 default:
143 "Fieldmap::getFieldmap()",
144 "Couldn't determine type of fieldmap in file \"" + Filename + "\"");
145 }
146 }
147}
148
149std::vector<std::string> Fieldmap::getListFieldmapNames() {
150 std::vector<std::string> name_list;
151 for (std::map<std::string, FieldmapDescription>::const_iterator it = FieldmapDictionary.begin();
152 it != FieldmapDictionary.end(); ++it) {
153 name_list.push_back((*it).first);
154 }
155 return name_list;
156}
157
158void Fieldmap::deleteFieldmap(std::string Filename) { freeMap(Filename); }
159
161 std::map<std::string, FieldmapDescription>::iterator it = FieldmapDictionary.begin();
162 for (; it != FieldmapDictionary.end(); ++it) {
163 delete it->second.Map;
164 it->second.Map = nullptr;
165 }
166 FieldmapDictionary.clear();
167}
168
174MapType Fieldmap::readHeader(std::string Filename) {
175 char magicnumber[5] = " ";
176 std::string buffer;
177 int lines_read_m = 0;
178
179 // Check for default map(s).
180 if (Filename == "1DPROFILE1-DEFAULT") return T1DProfile1;
181
182 if (Filename.empty())
183 throw GeneralOpalException("Fieldmap::readHeader()", "No field map file specified");
184
185 if (!fs::exists(Filename))
187 "Fieldmap::readHeader()", "File '" + Filename + "' doesn't exist");
188
189 std::ifstream File(Filename.c_str());
190 if (!File.good()) {
191 std::cerr << "could not open file " << Filename << std::endl;
192 return UNKNOWN;
193 }
194
195 getLine(File, lines_read_m, buffer);
196 std::istringstream interpreter(buffer, std::istringstream::in);
197
198 interpreter.read(magicnumber, 4);
199
200 if (std::strcmp(magicnumber, "3DDy") == 0) return T3DDynamic;
201
202 if (std::strcmp(magicnumber, "3DMa") == 0) {
203 char tmpString[21] = " ";
204 interpreter.read(tmpString, 20);
205
206 if (std::strcmp(tmpString, "gnetoStatic_Extended") == 0)
208 else
209 return T3DMagnetoStatic;
210 }
211
212 if (std::strcmp(magicnumber, "3DEl") == 0) return T3DElectroStatic;
213
214 if (std::strcmp(magicnumber, "2DDy") == 0) {
215 // char tmpString[14] = " ";
216 // interpreter.read(tmpString, 13);
217 return T2DDynamic;
218 }
219
220 if (std::strcmp(magicnumber, "2DMa") == 0) {
221 // char tmpString[20] = " ";
222 // interpreter.read(tmpString, 19);
223 return T2DMagnetoStatic;
224 }
225
226 if (std::strcmp(magicnumber, "2DEl") == 0) {
227 // char tmpString[20] = " ";
228 // interpreter.read(tmpString, 19);
229 return T2DElectroStatic;
230 }
231
232 if (std::strcmp(magicnumber, "1DDy") == 0) return T1DDynamic;
233
234 if (std::strcmp(magicnumber, "1DMa") == 0) return T1DMagnetoStatic;
235
236 if (std::strcmp(magicnumber, "1DPr") == 0) {
237 // char tmpString[7] = " ";
238 // interpreter.read(tmpString, 6);
239 // if (strcmp(tmpString, "ofile1") == 0)
240 return T1DProfile1;
241 // if (strcmp(tmpString, "ofile2") == 0)
242 // return T1DProfile2;
243 }
244
245 if (std::strcmp(magicnumber, "1DEl") == 0) return T1DElectroStatic;
246
247 if (std::strcmp(magicnumber, "\211HDF") == 0) {
248 h5_err_t h5err [[maybe_unused]] = 0;
249 char name[20];
250 h5_size_t len_name = sizeof(name);
251 h5_prop_t props = H5CreateFileProp();
252 MPI_Comm comm = ippl::Comm->getCommunicator();
253 h5err = H5SetPropFileMPIOCollective(props, &comm);
254 PAssert(h5err != H5_ERR);
255 h5_file_t file = H5OpenFile(Filename.c_str(), H5_O_RDONLY, props);
256 PAssert(file != (h5_file_t)H5_ERR);
257 H5CloseProp(props);
258
259 h5err = H5SetStep(file, 0);
260 PAssert(h5err != H5_ERR);
261
262 h5_int64_t num_fields = H5BlockGetNumFields(file);
263 PAssert(num_fields != H5_ERR);
264 MapType maptype = UNKNOWN;
265
266 for (h5_ssize_t i = 0; i < num_fields; ++i) {
267 h5err = H5BlockGetFieldInfo(
268 file, (h5_size_t)i, name, len_name, nullptr, nullptr, nullptr, nullptr);
269 PAssert(h5err != H5_ERR);
270 // using field name "Bfield" and "Hfield" to distinguish the type
271 if (std::strcmp(name, "Bfield") == 0) {
272 maptype = T3DMagnetoStaticH5Block;
273 break;
274 } else if (std::strcmp(name, "Hfield") == 0) {
275 maptype = T3DDynamicH5Block;
276 break;
277 }
278 }
279 h5err = H5CloseFile(file);
280 PAssert(h5err != H5_ERR);
281 if (maptype != UNKNOWN) return maptype;
282 }
283
284 if (std::strcmp(magicnumber, "Astr") == 0) {
285 char tmpString[3] = " ";
286 interpreter.read(tmpString, 2);
287 if (std::strcmp(tmpString, "aE") == 0) {
288 return TAstraElectroStatic;
289 }
290 if (std::strcmp(tmpString, "aM") == 0) {
291 return TAstraMagnetoStatic;
292 }
293 if (std::strcmp(tmpString, "aD") == 0) {
294 return TAstraDynamic;
295 }
296 }
297
298 return UNKNOWN;
299}
300
301void Fieldmap::readMap(std::string Filename) {
302 std::map<std::string, FieldmapDescription>::iterator position =
303 FieldmapDictionary.find(Filename);
304 if (position != FieldmapDictionary.end())
305 if (!(*position).second.read) {
306 (*position).second.Map->readMap();
307 (*position).second.read = true;
308 }
309}
310
311void Fieldmap::freeMap(std::string Filename) {
312 std::map<std::string, FieldmapDescription>::iterator position =
313 FieldmapDictionary.find(Filename);
314 /*
315 FIXME: find( ) make problem, crashes
316 */
317 if (position != FieldmapDictionary.end()) {
318 if ((*position).second.RefCounter > 0) {
319 (*position).second.RefCounter--;
320 }
321
322 if ((*position).second.RefCounter == 0) {
323 delete (*position).second.Map;
324 (*position).second.Map = nullptr;
325 FieldmapDictionary.erase(position);
326 }
327 }
328}
329
331 unsigned int accuracy, std::pair<double, double> fieldDimensions, double deltaZ,
332 const std::vector<double>& fourierCoefficients, gsl_spline* splineCoefficients,
333 gsl_interp_accel* splineAccelerator) {
334 double length = fieldDimensions.second - fieldDimensions.first;
335 unsigned int sizeSampling = std::round(length / deltaZ);
336 std::vector<double> zSampling(sizeSampling);
337 zSampling[0] = fieldDimensions.first;
338 for (unsigned int i = 1; i < sizeSampling; ++i) {
339 zSampling[i] = zSampling[i - 1] + deltaZ;
340 }
341 checkMap(
342 accuracy, length, zSampling, fourierCoefficients, splineCoefficients,
343 splineAccelerator);
344}
345
347 unsigned int accuracy, double length, const std::vector<double>& zSampling,
348 const std::vector<double>& fourierCoefficients, gsl_spline* splineCoefficients,
349 gsl_interp_accel* splineAccelerator) {
350 double error = 0.0;
351 double maxDiff = 0.0;
352 double ezMax = 0.0;
353 double ezSquare = 0.0;
354 size_t lastDot = Filename_m.find_last_of(".");
355 size_t lastSlash = Filename_m.find_last_of("/");
356 lastSlash = (lastSlash == std::string::npos) ? 0 : lastSlash + 1;
357
358 auto opal = OpalData::getInstance();
359 std::ofstream out;
360 if (ippl::Comm->rank() == 0 && !opal->isOptimizerRun()) {
361 std::string fname = Util::combineFilePath(
362 {opal->getAuxiliaryOutputDirectory(),
363 Filename_m.substr(lastSlash, lastDot) + ".check"});
364 out.open(fname);
365 out << "# z original reproduced\n";
366 }
367 auto it = zSampling.begin();
368 auto end = zSampling.end();
369 for (; it != end; ++it) {
370 const double kz = Physics::two_pi * (*it / length + 0.5);
371 double onAxisFieldCheck = fourierCoefficients[0];
372 unsigned int n = 1;
373 for (unsigned int l = 1; l < accuracy; ++l, n += 2) {
374 double coskzl = std::cos(kz * l);
375 double sinkzl = std::sin(kz * l);
376
377 onAxisFieldCheck +=
378 (fourierCoefficients[n] * coskzl - fourierCoefficients[n + 1] * sinkzl);
379 }
380 double ez = gsl_spline_eval(splineCoefficients, *it, splineAccelerator);
381 double difference = std::abs(ez - onAxisFieldCheck);
382 maxDiff = difference > maxDiff ? difference : maxDiff;
383 ezMax = std::abs(ez) > ezMax ? std::abs(ez) : ezMax;
384 error += std::pow(difference, 2.0);
385 ezSquare += std::pow(ez, 2.0);
386
387 if (ippl::Comm->rank() == 0 && !opal->isOptimizerRun()) {
388 out << std::setw(16) << std::setprecision(8) << *it << std::setw(16)
389 << std::setprecision(8) << ez << std::setw(16) << std::setprecision(8)
390 << onAxisFieldCheck << std::endl;
391 }
392 }
393 out.close();
394
395 if (std::sqrt(error / ezSquare) > 1e-1 || maxDiff > 1e-1 * ezMax) {
396 lowResolutionWarning(std::sqrt(error / ezSquare), maxDiff / ezMax);
397
399 "Fieldmap::checkMap",
400 "Field map can't be reproduced properly with the given number of fourier "
401 "components");
402 }
403 if (std::sqrt(error / ezSquare) > 1e-2 || maxDiff > 1e-2 * ezMax) {
404 lowResolutionWarning(std::sqrt(error / ezSquare), maxDiff / ezMax);
405 }
406}
407
409 const double& /*bendAngle*/, const double& /*entranceAngle*/, const double& /*exitAngle*/) {
410};
411
412void Fieldmap::setFieldLength(const double&) {};
413
414void Fieldmap::getLine(std::ifstream& in, int& lines_read, std::string& buffer) {
415 size_t firstof = 0;
416 size_t lastof;
417
418 do {
419 ++lines_read;
420 in.getline(buffer_m, READ_BUFFER_LENGTH);
421
422 buffer = std::string(buffer_m);
423
424 size_t comment = buffer.find("#");
425 buffer = buffer.substr(0, comment);
426
427 lastof = buffer.find_last_of(alpha_numeric);
428 firstof = buffer.find_first_of(alpha_numeric);
429 } while (!in.eof() && lastof == std::string::npos);
430
431 if (firstof != std::string::npos) {
432 buffer = buffer.substr(firstof, lastof - firstof + 1);
433 }
434}
435
436bool Fieldmap::interpreteEOF(std::ifstream& in) {
437 while (!in.eof()) {
438 ++lines_read_m;
439 in.getline(buffer_m, READ_BUFFER_LENGTH);
440 std::string buffer(buffer_m);
441 size_t comment = buffer.find_first_of("#");
442 buffer = buffer.substr(0, comment);
443 size_t lasto = buffer.find_first_of(alpha_numeric);
444 if (lasto != std::string::npos) {
446 return false;
447 }
448 }
449 return true;
450}
451
453 const std::ios_base::iostate& state, const bool& read_all, const std::string& expecting,
454 const std::string& found) {
455 std::stringstream errormsg;
456 errormsg << "THERE SEEMS TO BE SOMETHING WRONG WITH YOUR FIELD MAP '" << Filename_m << "'.\n";
457 if (!read_all) {
458 errormsg << "Didn't find enough values!" << std::endl;
459 } else if (state & std::ios_base::eofbit) {
460 errormsg << "Found more values than expected!" << std::endl;
461 } else if (state & std::ios_base::failbit) {
462 errormsg << "Found wrong type of values!"
463 << "\n"
464 << "expecting: '" << expecting << "' on line " << lines_read_m << ",\n"
465 << "instead found: '" << found << "'." << std::endl;
466 }
467 throw GeneralOpalException("Fieldmap::interpretWarning()", errormsg.str());
468}
469
471 std::stringstream errormsg;
472 errormsg << "THERE SEEMS TO BE SOMETHING WRONG WITH YOUR FIELD MAP '" << Filename_m << "'.\n"
473 << "There are only " << lines_read_m - 1 << " lines in the file, expecting more.\n"
474 << "Please check the section about field maps in the user manual.";
475
476 throw GeneralOpalException("Fieldmap::missingValuesWarning()", errormsg.str());
477}
478
480 std::stringstream errormsg;
481 errormsg << "THERE SEEMS TO BE SOMETHING WRONG WITH YOUR FIELD MAP '" << Filename_m << "'.\n"
482 << "There are too many lines in the file, expecting only " << lines_read_m
483 << " lines.\n"
484 << "Please check the section about field maps in the user manual.";
485
486 throw GeneralOpalException("Fieldmap::exceedingValuesWarning()", errormsg.str());
487}
488
490 std::stringstream errormsg;
491 errormsg << "DISABLING FIELD MAP '" + Filename_m + "' DUE TO PARSING ERRORS.";
492
493 throw GeneralOpalException("Fieldmap::disableFieldmapsWarning()", errormsg.str());
494}
495
497 std::stringstream errormsg;
498 errormsg << "DISABLING FIELD MAP '" << Filename_m << "' SINCE FILE COULDN'T BE FOUND!";
499
500 throw GeneralOpalException("Fieldmap::noFieldmapsWarning()", errormsg.str());
501}
502
503void Fieldmap::lowResolutionWarning(double squareError, double maxError) {
504 std::stringstream errormsg;
505 errormsg << "IT SEEMS THAT YOU USE TOO FEW FOURIER COMPONENTS TO SUFFICIENTLY WELL\n"
506 << "RESOLVE THE FIELD MAP '" << Filename_m << "'.\n"
507 << "PLEASE INCREASE THE NUMBER OF FOURIER COMPONENTS!\n"
508 << "The ratio (e_i - E_i)^2 / E_i^2 is " << std::to_string(squareError) << " and\n"
509 << "the ratio (max_i(|e_i - E_i|) / max_i(|E_i|) is " << std::to_string(maxError)
510 << ".\n"
511 << "Here E_i is the field as in the field map and e_i is the reconstructed field.\n"
512 << "The lower limit for the two ratios is 1e-2\n"
513 << "Have a look into the directory "
515 << " for a reconstruction of the field map.\n";
516 std::string errormsg_str = typeset_msg(errormsg.str(), "warning");
517
518 *ippl::Error << errormsg_str << "\n" << endl;
519
520 if (ippl::Comm->rank() == 0) {
521 std::ofstream omsg("errormsg.txt", std::ios_base::app);
522 omsg << errormsg.str() << std::endl;
523 omsg.close();
524 }
525}
526
527std::string Fieldmap::typeset_msg(const std::string& msg, const std::string& title) {
528 static std::string frame(
529 "* ******************************************************************************\n");
530 static unsigned int frame_width = frame.length() - 5;
531 static std::string closure(
532 " *\n");
533
534 std::string return_string("\n" + frame);
535
536 int remaining_length = msg.length();
537 unsigned int current_position = 0;
538
539 unsigned int ii = 0;
540 for (; ii < title.length(); ++ii) {
541 char c = title[ii];
542 c = std::toupper(c);
543 return_string.replace(15 + 2 * ii, 1, " ");
544 return_string.replace(16 + 2 * ii, 1, &c, 1);
545 }
546 return_string.replace(15 + 2 * ii, 1, " ");
547
548 while (remaining_length > 0) {
549 size_t eol = msg.find("\n", current_position);
550 std::string next_to_process;
551 if (eol != std::string::npos) {
552 next_to_process = msg.substr(current_position, eol - current_position);
553 } else {
554 next_to_process = msg.substr(current_position);
555 eol = msg.length();
556 }
557
558 if (eol - current_position < frame_width) {
559 return_string += "* " + next_to_process + closure.substr(eol - current_position + 2);
560 } else {
561 unsigned int last_space = next_to_process.rfind(" ", frame_width);
562 if (last_space > 0) {
563 if (last_space < frame_width) {
564 return_string += "* " + next_to_process.substr(0, last_space)
565 + closure.substr(last_space + 2);
566 } else {
567 return_string += "* " + next_to_process.substr(0, last_space) + " *\n";
568 }
569 if (next_to_process.length() - last_space + 1 < frame_width) {
570 return_string += "* " + next_to_process.substr(last_space + 1)
571 + closure.substr(next_to_process.length() - last_space + 1);
572 } else {
573 return_string += "* " + next_to_process.substr(last_space + 1) + " *\n";
574 }
575 } else {
576 return_string += "* " + next_to_process + " *\n";
577 }
578 }
579
580 current_position = eol + 1;
581 remaining_length = msg.length() - current_position;
582 }
583 return_string += frame;
584
585 return return_string;
586}
587
588void Fieldmap::getOnaxisEz(std::vector<std::pair<double, double>>& /*onaxis*/) {}
589
591 std::vector<double>& /*engeCoeffsEntry*/, std::vector<double>& /*engeCoeffsExit*/) {}
592
594 double& /*entranceParameter1*/, double& /*entranceParameter2*/,
595 double& /*entranceParameter3*/) {}
596
598 double& /*exitParameter1*/, double& /*exitParameter2*/, double& /*exitParameter3*/) {}
599
600double Fieldmap::getFieldGap() { return 0.0; }
601
602void Fieldmap::setFieldGap(double /*gap*/) {}
603
605 unsigned int nx, unsigned int ny, unsigned int nz, const std::pair<double, double>& xrange,
606 const std::pair<double, double>& yrange, const std::pair<double, double>& zrange,
607 const std::vector<Vector_t<double, 3>>& ef, const std::vector<Vector_t<double, 3>>& bf) {
608 const size_t numpoints = nx * ny * nz;
609 if (ippl::Comm->rank() != 0 || (ef.size() != numpoints && bf.size() != numpoints)) return;
610
611 std::filesystem::path p(Filename_m);
612 std::string fname = Util::combineFilePath(
613 {OpalData::getInstance()->getAuxiliaryOutputDirectory(), p.stem().string() + ".vtk"});
614 std::ofstream of;
615 of.open(fname);
616 PAssert(of.is_open());
617 of.precision(6);
618
619 const double hx = (xrange.second - xrange.first) / (nx - 1);
620 const double hy = (yrange.second - yrange.first) / (ny - 1);
621 const double hz = (zrange.second - zrange.first) / (nz - 1);
622
623 of << "# vtk DataFile Version 2.0" << std::endl;
624 of << "generated by 3D fieldmaps" << std::endl;
625 of << "ASCII" << std::endl << std::endl;
626 of << "DATASET RECTILINEAR_GRID" << std::endl;
627 of << "DIMENSIONS " << nx << " " << ny << " " << nz << std::endl;
628
629 of << "X_COORDINATES " << nx << " float" << std::endl;
630 of << xrange.first;
631 for (unsigned int i = 1; i < nx - 1; ++i) {
632 of << " " << xrange.first + i * hx;
633 }
634 of << " " << xrange.second << std::endl;
635
636 of << "Y_COORDINATES " << ny << " float" << std::endl;
637 of << yrange.first;
638 for (unsigned int i = 1; i < ny - 1; ++i) {
639 of << " " << yrange.first + i * hy;
640 }
641 of << " " << yrange.second << std::endl;
642
643 of << "Z_COORDINATES " << nz << " float" << std::endl;
644 of << zrange.first;
645 for (unsigned int i = 1; i < nz - 1; ++i) {
646 of << " " << zrange.first + i * hz;
647 }
648 of << " " << zrange.second << std::endl;
649
650 of << "POINT_DATA " << numpoints << std::endl;
651
652 if (ef.size() == numpoints) {
653 of << "VECTORS EField float" << std::endl;
654 // of << "LOOKUP_TABLE default" << std::endl;
655 for (size_t i = 0; i < numpoints; ++i) {
656 of << ef[i](0) << " " << ef[i](1) << " " << ef[i](2) << std::endl;
657 }
658 // of << std::endl;
659 }
660
661 if (bf.size() == numpoints) {
662 of << "VECTORS BField float" << std::endl;
663 // of << "LOOKUP_TABLE default" << std::endl;
664 for (size_t i = 0; i < numpoints; ++i) {
665 of << bf[i](0) << " " << bf[i](1) << " " << bf[i](2) << std::endl;
666 }
667 // of << std::endl;
668 }
669}
670
675
676std::string Fieldmap::alpha_numeric(
677 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+\211");
678std::map<std::string, Fieldmap::FieldmapDescription> Fieldmap::FieldmapDictionary =
679 std::map<std::string, Fieldmap::FieldmapDescription>();
ippl::Vector< T, Dim > Vector_t
#define REGISTER_PARSE_TYPE(X)
Definition Fieldmap.cpp:54
#define READ_BUFFER_LENGTH
Definition Fieldmap.h:4
MapType
Definition Fieldmap.h:14
@ TAstraElectroStatic
Definition Fieldmap.h:19
@ T3DElectroStatic
Definition Fieldmap.h:31
@ T3DDynamic
Definition Fieldmap.h:30
@ T2DDynamic
Definition Fieldmap.h:24
@ T2DMagnetoStatic
Definition Fieldmap.h:28
@ T3DMagnetoStatic
Definition Fieldmap.h:32
@ T1DDynamic
Definition Fieldmap.h:16
@ UNKNOWN
Definition Fieldmap.h:15
@ TAstraMagnetoStatic
Definition Fieldmap.h:21
@ T3DMagnetoStatic_Extended
Definition Fieldmap.h:33
@ T1DProfile1
Definition Fieldmap.h:22
@ T3DMagnetoStaticH5Block
Definition Fieldmap.h:34
@ T3DDynamicH5Block
Definition Fieldmap.h:35
@ T1DElectroStatic
Definition Fieldmap.h:18
@ T1DMagnetoStatic
Definition Fieldmap.h:20
@ T2DElectroStatic
Definition Fieldmap.h:26
@ TAstraDynamic
Definition Fieldmap.h:17
double gsl_spline_eval(const gsl_spline *spline, const double x, gsl_interp_accel *accel)
Evaluate a spline at x using an accelerator.
Definition GSLSpline.h:66
Accelerator caching last interval indices.
Base class for the linear and cubic interpolation spline classes.
Abstract base class for all field maps. It acts as a factory for creating specific field map types ba...
Definition Fieldmap.h:62
static Fieldmap * getFieldmap(std::string Filename, bool fast=false)
Get a field map instance. Use this factory method to obtain a field map. It checks the cache (Fieldma...
Definition Fieldmap.cpp:72
static void deleteFieldmap(std::string Filename)
Delete a specific field map from the cache and memory.
Definition Fieldmap.cpp:158
static std::string alpha_numeric
Definition Fieldmap.h:302
static std::map< std::string, FieldmapDescription > FieldmapDictionary
Definition Fieldmap.h:313
static MapType readHeader(std::string Filename)
Read the header of a field map file to determine its type.
Definition Fieldmap.cpp:174
bool interpreteEOF(std::ifstream &in)
Definition Fieldmap.cpp:436
virtual void setFieldLength(const double &)
Definition Fieldmap.cpp:412
virtual void freeMap()=0
Pure virtual method to free the map data.
void missingValuesWarning()
Definition Fieldmap.cpp:470
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &onaxis)
Definition Fieldmap.cpp:588
virtual void get1DProfile1EntranceParam(double &entranceParameter1, double &entranceParameter2, double &entranceParameter3)
Definition Fieldmap.cpp:593
void checkMap(unsigned int accuracy, std::pair< double, double > fieldDimensions, double deltaZ, const std::vector< double > &fourierCoefficients, gsl_spline *splineCoefficients, gsl_interp_accel *splineAccelerator)
Definition Fieldmap.cpp:330
void lowResolutionWarning(double squareError, double maxError)
Definition Fieldmap.cpp:503
void interpretWarning(const std::ios_base::iostate &state, const bool &read_all, const std::string &error_msg, const std::string &found)
Definition Fieldmap.cpp:452
void disableFieldmapWarning()
Definition Fieldmap.cpp:489
static char buffer_m[256]
Definition Fieldmap.h:301
int lines_read_m
Definition Fieldmap.h:234
static std::vector< std::string > getListFieldmapNames()
Get a list of all loaded field map names.
Definition Fieldmap.cpp:149
static std::string typeset_msg(const std::string &msg, const std::string &title)
Definition Fieldmap.cpp:527
static void clearDictionary()
Clear the entire field map cache.
Definition Fieldmap.cpp:160
static void freeMap(std::string Filename)
Decrease reference count or delete field map if unused.
Definition Fieldmap.cpp:311
virtual double getFieldGap()
Definition Fieldmap.cpp:600
virtual void setEdgeConstants(const double &bendAngle, const double &entranceAngle, const double &exitAngle)
Definition Fieldmap.cpp:408
std::string Filename_m
Definition Fieldmap.h:233
virtual void setFieldGap(double gap)
Definition Fieldmap.cpp:602
void exceedingValuesWarning()
Definition Fieldmap.cpp:479
virtual void get1DProfile1EngeCoeffs(std::vector< double > &engeCoeffsEntry, std::vector< double > &engeCoeffsExit)
Definition Fieldmap.cpp:590
void getLine(std::ifstream &in, std::string &buffer)
Definition Fieldmap.h:237
void noFieldmapWarning()
Definition Fieldmap.cpp:496
virtual void get1DProfile1ExitParam(double &exitParameter1, double &exitParameter2, double &exitParameter3)
Definition Fieldmap.cpp:597
static void readMap(std::string Filename)
Trigger the actual reading of the field map data.
Definition Fieldmap.cpp:301
void write3DField(unsigned int nx, unsigned int ny, unsigned int nz, const std::pair< double, double > &xrange, const std::pair< double, double > &yrange, const std::pair< double, double > &zrange, const std::vector< Vector_t< double, 3 > > &ef, const std::vector< Vector_t< double, 3 > > &bf)
Definition Fieldmap.cpp:604
static OpalData * getInstance()
Definition OpalData.cpp:193
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
Definition OpalData.cpp:567
constexpr double two_pi
The value of.
Definition Physics.h:40
std::string combineFilePath(std::initializer_list< std::string > ilist)
Definition Util.cpp:193