OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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"
21 #include "Physics/Units.h"
23 
25  const std::string& filename
26  ) : _Fieldmap (
27  filename),
29  ) {
31 
32  openFileMPIOCollective (filename);
33  getFieldInfo ("Efield");
35  closeFile ();
36 }
37 
39  ) {
40  freeMap();
41 }
42 
44 {
45  return FM3DH5Block_nonscale(new _FM3DH5Block_nonscale(filename));
46 }
47 
49  ) {
50  if (!FieldstrengthEz_m.empty()) {
51  return;
52  }
54  long long last_step = getNumSteps () - 1;
55  setStep (last_step);
56 
57  size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
58  FieldstrengthEx_m.resize (field_size);
59  FieldstrengthEy_m.resize (field_size);
60  FieldstrengthEz_m.resize (field_size);
61  FieldstrengthHx_m.resize (field_size);
62  FieldstrengthHy_m.resize (field_size);
63  FieldstrengthHz_m.resize (field_size);
64 
65  readField (
66  "Efield",
67  &(FieldstrengthEx_m[0]),
68  &(FieldstrengthEy_m[0]),
69  &(FieldstrengthEz_m[0]));
70  readField (
71  "Hfield",
72  &(FieldstrengthHx_m[0]),
73  &(FieldstrengthHy_m[0]),
74  &(FieldstrengthHz_m[0]));
75 
76  closeFile ();
77 
78  for (long long unsigned i = 0; i < num_gridpx_m * num_gridpy_m * num_gridpz_m; i++) {
82  FieldstrengthHx_m[i] *= 1.0e6 * Physics::mu_0 ;
83  FieldstrengthHy_m[i] *= 1.0e6 * Physics::mu_0 ;
84  FieldstrengthHz_m[i] *= 1.0e6 * Physics::mu_0 ;
85  }
87  << typeset_msg("3d dynamic (non-scaled) fieldmap '"
88  + Filename_m + "' (H5hut format) read", "info")
89  << endl);
90 }
91 
93  ) {
94  if(FieldstrengthEz_m.empty ()) {
95  return;
96  }
97  FieldstrengthEx_m.clear ();
98  FieldstrengthEy_m.clear ();
99  FieldstrengthEz_m.clear ();
100  FieldstrengthHx_m.clear ();
101  FieldstrengthHy_m.clear ();
102  FieldstrengthHz_m.clear ();
103 }
104 
106  const Vector_t& R,
107  Vector_t& E,
108  Vector_t& B
109  ) const {
110  if (!isInside(R)) {
111  return true;
112  }
117 
118  return false;
119 }
MapType Type
Definition: Fieldmap.h:115
constexpr double MVpm2Vpm
Definition: Units.h:128
virtual bool isInside(const Vector_t &r) const
void getFieldInfo(const char *)
unsigned int num_gridpz_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
std::shared_ptr< _FM3DH5Block_nonscale > FM3DH5Block_nonscale
Definition: Definitions.h:66
void readField(const char *name, double *x, double *y, double *z)
long long getNumSteps(void)
unsigned int num_gridpy_m
void openFileMPIOCollective(const std::string &filename)
constexpr double mu_0
The permeability of vacuum in Vs/Am.
Definition: Physics.h:48
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
std::vector< double > FieldstrengthHz_m
void setStep(const long long)
std::vector< double > FieldstrengthEy_m
unsigned int num_gridpx_m
Inform & level3(Inform &inf)
Definition: Inform.cpp:47
_FM3DH5Block_nonscale(const std::string &filename)
std::vector< double > FieldstrengthHx_m
std::string Filename_m
Definition: Fieldmap.h:118
std::vector< double > FieldstrengthHy_m
Vector_t interpolateTrilinearly(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &, const Vector_t &X) const
static FM3DH5Block_nonscale create(const std::string &filename)
std::vector< double > FieldstrengthEx_m
std::vector< double > FieldstrengthEz_m