OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
FM3DH5Block.cpp
Go to the documentation of this file.
1 //
2 // Class FM3DH5Block
3 // Class for dynamic 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 
19 #include "Fields/FM3DH5Block.h"
20 
22  std::string aFilename
23  ) : Fieldmap (
24  aFilename
25  ) {
27 
28  openFileMPIOCollective (aFilename);
29  getFieldInfo ("Efield");
31  closeFile ();
32 }
33 
35  ) {
36  freeMap ();
37 }
38 
40  ) {
41  if (!FieldstrengthEz_m.empty()) {
42  return;
43  }
45  long long last_step = getNumSteps () - 1;
46  setStep (last_step);
47 
48  size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
49  FieldstrengthEx_m.resize (field_size);
50  FieldstrengthEy_m.resize (field_size);
51  FieldstrengthEz_m.resize (field_size);
52  FieldstrengthHx_m.resize (field_size);
53  FieldstrengthHy_m.resize (field_size);
54  FieldstrengthHz_m.resize (field_size);
55 
56  readField (
57  "Efield",
58  &(FieldstrengthEx_m[0]),
59  &(FieldstrengthEy_m[0]),
60  &(FieldstrengthEz_m[0]));
61  readField (
62  "Hfield",
63  &(FieldstrengthHx_m[0]),
64  &(FieldstrengthHy_m[0]),
65  &(FieldstrengthHz_m[0]));
66 
67  closeFile ();
69  << typeset_msg("3d dynamic fieldmap '"
70  + Filename_m + "' (H5hut format) read", "info")
71  << endl);
72 }
73 
75  ) {
76  if(FieldstrengthEz_m.empty ()) {
77  return;
78  }
79  FieldstrengthEx_m.clear ();
80  FieldstrengthEy_m.clear ();
81  FieldstrengthEz_m.clear ();
82  FieldstrengthHx_m.clear ();
83  FieldstrengthHy_m.clear ();
84  FieldstrengthHz_m.clear ();
85 
87  << typeset_msg ("freed fieldmap '" + Filename_m + "'", "info")
88  << endl);
89 }
90 
92  const Vector_t& R,
93  Vector_t& E,
94  Vector_t& B
95  ) const {
96  if (!isInside(R)) {
97  return true;
98  }
101  return false;
102 }
@ T3DDynamicH5Block
Definition: Fieldmap.h:35
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
std::vector< double > FieldstrengthHy_m
Definition: FM3DH5Block.h:47
std::vector< double > FieldstrengthHx_m
Definition: FM3DH5Block.h:46
virtual ~FM3DH5Block()
Definition: FM3DH5Block.cpp:34
virtual void readMap()
Definition: FM3DH5Block.cpp:39
FM3DH5Block(std::string aFilename)
Definition: FM3DH5Block.cpp:21
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
Definition: FM3DH5Block.cpp:91
virtual void freeMap()
Definition: FM3DH5Block.cpp:74
std::vector< double > FieldstrengthHz_m
Definition: FM3DH5Block.h:45
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