OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
FM3DMagnetoStaticH5Block.cpp
Go to the documentation of this file.
1 //
2 // Class FM3DMagnetoStaticH5Block
3 // Class for magneto-static 3D field-maps stored in H5hut files.
4 //
5 // Copyright (c) 2020, Achim Gsell, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved.
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 
21 
23  std::string aFilename
24  ) : Fieldmap (
25  aFilename),
27  ) {
29 
30  openFileMPIOCollective (aFilename);
31  getFieldInfo ("Efield");
33  closeFile ();
34 }
35 
37  ) {
38  freeMap ();
39 }
40 
42  ) {
43  if (!FieldstrengthEz_m.empty()) {
44  return;
45  }
47  long long last_step = getNumSteps () - 1;
48  setStep (last_step);
49 
50  size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
51  FieldstrengthEx_m.resize (field_size);
52  FieldstrengthEy_m.resize (field_size);
53  FieldstrengthEz_m.resize (field_size);
54  FieldstrengthBx_m.resize (field_size);
55  FieldstrengthBy_m.resize (field_size);
56  FieldstrengthBz_m.resize (field_size);
57 
58  readField (
59  "Efield",
60  &(FieldstrengthEx_m[0]),
61  &(FieldstrengthEy_m[0]),
62  &(FieldstrengthEz_m[0]));
63  readField (
64  "Bfield",
65  &(FieldstrengthBx_m[0]),
66  &(FieldstrengthBy_m[0]),
67  &(FieldstrengthBz_m[0]));
68 
69  closeFile ();
71  << typeset_msg("3d magneto static fieldmap '"
72  + Filename_m + "' (H5hut format) read", "info")
73  << endl);
74 }
76  ) {
77  if(FieldstrengthEz_m.empty()) {
78  return;
79  }
80  FieldstrengthEx_m.clear();
81  FieldstrengthEy_m.clear();
82  FieldstrengthEz_m.clear();
83  FieldstrengthBx_m.clear();
84  FieldstrengthBy_m.clear();
85  FieldstrengthBz_m.clear();
86  INFOMSG(level3 << typeset_msg("freed fieldmap '" + Filename_m + "'", "info")
87  << endl);
88 }
89 
91  const Vector_t& R,
92  Vector_t& E,
93  Vector_t& B
94  ) const {
95  if (!isInside(R)) {
96  return true;
97  }
102 
103  return false;
104 }
105 
107  ) const {
108  return 0.0;
109 }
@ T3DMagnetoStaticH5Block
Definition: Fieldmap.h:34
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
Inform & level3(Inform &inf)
Definition: Inform.cpp:47
#define INFOMSG(msg)
Definition: IpplInfo.h:348
MapType Type
Definition: Fieldmap.h:114
static std::string typeset_msg(const std::string &msg, const std::string &title)
Definition: Fieldmap.cpp:652
std::string Filename_m
Definition: Fieldmap.h:117
void getFieldInfo(const char *)
long long getNumSteps(void)
void openFileMPIOCollective(const std::string aFilename)
std::vector< double > FieldstrengthEz_m
virtual bool isInside(const Vector_t &r) const
void setStep(const long long)
Vector_t interpolateTrilinearly(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &, const Vector_t &X) const
void getResonanceFrequency(void)
std::vector< double > FieldstrengthEx_m
void readField(const char *name, double *x, double *y, double *z)
std::vector< double > FieldstrengthEy_m
FM3DMagnetoStaticH5Block(std::string aFilename)
std::vector< double > FieldstrengthBz_m
virtual double getFrequency() const
std::vector< double > FieldstrengthBy_m
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
std::vector< double > FieldstrengthBx_m