OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
FM3DH5Block_nonscale.cpp
Go to the documentation of this file.
1 //
2 // Class FM3DH5Block_nonscale
3 // Class for dynamic non-scaled 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 
20 #include "Physics/Physics.h"
22 
24  std::string aFilename
25  ) : Fieldmap (
26  aFilename),
28  ) {
30 
31  openFileMPIOCollective (aFilename);
32  getFieldInfo ("Efield");
34  closeFile ();
35 }
36 
38  ) {
39  freeMap();
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  FieldstrengthHx_m.resize (field_size);
56  FieldstrengthHy_m.resize (field_size);
57  FieldstrengthHz_m.resize (field_size);
58 
59  readField (
60  "Efield",
61  &(FieldstrengthEx_m[0]),
62  &(FieldstrengthEy_m[0]),
63  &(FieldstrengthEz_m[0]));
64  readField (
65  "Hfield",
66  &(FieldstrengthHx_m[0]),
67  &(FieldstrengthHy_m[0]),
68  &(FieldstrengthHz_m[0]));
69 
70  closeFile ();
71 
72  for (long long i = 0; i < num_gridpx_m * num_gridpy_m * num_gridpz_m; i++) {
73  FieldstrengthEz_m[i] *= 1.0e6 ;
74  FieldstrengthEx_m[i] *= 1.0e6 ;
75  FieldstrengthEy_m[i] *= 1.0e6 ;
76  FieldstrengthHx_m[i] *= 1.0e6 * Physics::mu_0 ;
77  FieldstrengthHy_m[i] *= 1.0e6 * Physics::mu_0 ;
78  FieldstrengthHz_m[i] *= 1.0e6 * Physics::mu_0 ;
79  }
81  << typeset_msg("3d dynamic (non-scaled) fieldmap '"
82  + Filename_m + "' (H5hut format) read", "info")
83  << endl);
84 }
85 
87  ) {
88  if(FieldstrengthEz_m.empty ()) {
89  return;
90  }
91  FieldstrengthEx_m.clear ();
92  FieldstrengthEy_m.clear ();
93  FieldstrengthEz_m.clear ();
94  FieldstrengthHx_m.clear ();
95  FieldstrengthHy_m.clear ();
96  FieldstrengthHz_m.clear ();
97 
98  INFOMSG(level3 << typeset_msg("freed fieldmap '" + Filename_m + "'", "info")
99  << endl);
100 }
101 
103  const Vector_t& R,
104  Vector_t& E,
105  Vector_t& B
106  ) const {
107  if (!isInside(R)) {
108  return true;
109  }
114 
115  return false;
116 }
@ 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
constexpr double mu_0
The permeability of vacuum in Vs/Am.
Definition: Physics.h:54
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
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
FM3DH5Block_nonscale(std::string aFilename)
std::vector< double > FieldstrengthHx_m
std::vector< double > FieldstrengthHy_m
std::vector< double > FieldstrengthHz_m
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