OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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  : _Fieldmap(filename)
24  , _FM3DH5BlockBase () {
26 
27  openFileMPIOCollective (filename);
28  getFieldInfo ("Efield");
30  closeFile ();
31 }
32 
34  freeMap ();
35 }
36 
38 {
40 }
41 
43  ) {
44  if (!FieldstrengthEz_m.empty()) {
45  return;
46  }
48  long long last_step = getNumSteps () - 1;
49  setStep (last_step);
50 
51  size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
52  FieldstrengthEx_m.resize (field_size);
53  FieldstrengthEy_m.resize (field_size);
54  FieldstrengthEz_m.resize (field_size);
55  FieldstrengthBx_m.resize (field_size);
56  FieldstrengthBy_m.resize (field_size);
57  FieldstrengthBz_m.resize (field_size);
58 
59  readField (
60  "Efield",
61  &(FieldstrengthEx_m[0]),
62  &(FieldstrengthEy_m[0]),
63  &(FieldstrengthEz_m[0]));
64  readField (
65  "Bfield",
66  &(FieldstrengthBx_m[0]),
67  &(FieldstrengthBy_m[0]),
68  &(FieldstrengthBz_m[0]));
69 
70  closeFile ();
72  << typeset_msg("3d magneto static fieldmap '"
73  + Filename_m + "' (H5hut format) read", "info")
74  << endl);
75 }
77  ) {
78  if(FieldstrengthEz_m.empty()) {
79  return;
80  }
81  FieldstrengthEx_m.clear();
82  FieldstrengthEy_m.clear();
83  FieldstrengthEz_m.clear();
84  FieldstrengthBx_m.clear();
85  FieldstrengthBy_m.clear();
86  FieldstrengthBz_m.clear();
87 }
88 
90  const Vector_t& R,
91  Vector_t& E,
92  Vector_t& B
93  ) const {
94  if (!isInside(R)) {
95  return true;
96  }
101 
102  return false;
103 }
104 
106  ) const {
107  return 0.0;
108 }
MapType Type
Definition: Fieldmap.h:115
virtual bool isInside(const Vector_t &r) const
void getFieldInfo(const char *)
unsigned int num_gridpz_m
std::vector< double > FieldstrengthBz_m
void getResonanceFrequency(void)
static std::string typeset_msg(const std::string &msg, const std::string &title)
Definition: Fieldmap.cpp:649
#define INFOMSG(msg)
Definition: IpplInfo.h:348
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
void readField(const char *name, double *x, double *y, double *z)
long long getNumSteps(void)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
unsigned int num_gridpy_m
static FM3DMagnetoStaticH5Block create(const std::string &filename)
void openFileMPIOCollective(const std::string &filename)
std::vector< double > FieldstrengthBx_m
void setStep(const long long)
std::vector< double > FieldstrengthEy_m
std::shared_ptr< _FM3DMagnetoStaticH5Block > FM3DMagnetoStaticH5Block
Definition: Definitions.h:75
unsigned int num_gridpx_m
Inform & level3(Inform &inf)
Definition: Inform.cpp:47
std::string Filename_m
Definition: Fieldmap.h:118
_FM3DMagnetoStaticH5Block(const std::string &filename)
Vector_t interpolateTrilinearly(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &, const Vector_t &X) const
std::vector< double > FieldstrengthBy_m
std::vector< double > FieldstrengthEx_m
virtual double getFrequency() const
std::vector< double > FieldstrengthEz_m