OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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  const std::string& filename
23  ) : _Fieldmap(
24  filename
25  ) {
27 
28  openFileMPIOCollective (filename);
29  getFieldInfo ("Efield");
31  closeFile ();
32 }
33 
35  ) {
36  freeMap ();
37 }
38 
39 FM3DH5Block _FM3DH5Block::create(const std::string& filename)
40 {
41  return FM3DH5Block(new _FM3DH5Block(filename));
42 }
43 
45  ) {
46  if (!FieldstrengthEz_m.empty()) {
47  return;
48  }
50  long long last_step = getNumSteps () - 1;
51  setStep (last_step);
52 
53  size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
54  FieldstrengthEx_m.resize (field_size);
55  FieldstrengthEy_m.resize (field_size);
56  FieldstrengthEz_m.resize (field_size);
57  FieldstrengthHx_m.resize (field_size);
58  FieldstrengthHy_m.resize (field_size);
59  FieldstrengthHz_m.resize (field_size);
60 
61  readField (
62  "Efield",
63  &(FieldstrengthEx_m[0]),
64  &(FieldstrengthEy_m[0]),
65  &(FieldstrengthEz_m[0]));
66  readField (
67  "Hfield",
68  &(FieldstrengthHx_m[0]),
69  &(FieldstrengthHy_m[0]),
70  &(FieldstrengthHz_m[0]));
71 
72  closeFile ();
74  << typeset_msg("3d dynamic fieldmap '"
75  + Filename_m + "' (H5hut format) read", "info")
76  << endl);
77 }
78 
80  ) {
81  if(FieldstrengthEz_m.empty ()) {
82  return;
83  }
84  FieldstrengthEx_m.clear ();
85  FieldstrengthEy_m.clear ();
86  FieldstrengthEz_m.clear ();
87  FieldstrengthHx_m.clear ();
88  FieldstrengthHy_m.clear ();
89  FieldstrengthHz_m.clear ();
90 }
91 
93  const Vector_t& R,
94  Vector_t& E,
95  Vector_t& B
96  ) const {
97  if (!isInside(R)) {
98  return true;
99  }
102  return false;
103 }
virtual ~_FM3DH5Block()
Definition: FM3DH5Block.cpp:34
MapType Type
Definition: Fieldmap.h:115
virtual bool isInside(const Vector_t &r) const
_FM3DH5Block(const std::string &filename)
Definition: FM3DH5Block.cpp:21
void getFieldInfo(const char *)
std::vector< double > FieldstrengthHy_m
Definition: FM3DH5Block.h:49
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
void readField(const char *name, double *x, double *y, double *z)
long long getNumSteps(void)
static FM3DH5Block create(const std::string &filename)
Definition: FM3DH5Block.cpp:39
unsigned int num_gridpy_m
virtual void readMap()
Definition: FM3DH5Block.cpp:44
void openFileMPIOCollective(const std::string &filename)
void setStep(const long long)
std::vector< double > FieldstrengthEy_m
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
Definition: FM3DH5Block.cpp:92
unsigned int num_gridpx_m
std::shared_ptr< _FM3DH5Block > FM3DH5Block
Definition: Definitions.h:63
Inform & level3(Inform &inf)
Definition: Inform.cpp:47
virtual void freeMap()
Definition: FM3DH5Block.cpp:79
std::string Filename_m
Definition: Fieldmap.h:118
std::vector< double > FieldstrengthHx_m
Definition: FM3DH5Block.h:48
Vector_t interpolateTrilinearly(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &, const Vector_t &X) const
std::vector< double > FieldstrengthHz_m
Definition: FM3DH5Block.h:47
std::vector< double > FieldstrengthEx_m
std::vector< double > FieldstrengthEz_m