OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
38
39FM3DH5Block _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",
65 &(FieldstrengthEz_m[0]));
66 readField (
67 "Hfield",
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}
std::shared_ptr< _FM3DH5Block > FM3DH5Block
Definition FM3DH5Block.h:55
@ T3DDynamicH5Block
Definition Fieldmap.h:36
Inform & endl(Inform &inf)
Definition Inform.cpp:42
Inform & level3(Inform &inf)
Definition Inform.cpp:47
#define INFOMSG(msg)
Definition IpplInfo.h:348
static std::string typeset_msg(const std::string &msg, const std::string &title)
Definition Fieldmap.cpp:649
std::string Filename_m
Definition Fieldmap.h:118
MapType Type
Definition Fieldmap.h:116
friend class _Fieldmap
Definition FM3DH5Block.h:51
virtual ~_FM3DH5Block()
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
std::vector< double > FieldstrengthHy_m
Definition FM3DH5Block.h:49
_FM3DH5Block(const std::string &filename)
virtual void freeMap()
std::vector< double > FieldstrengthHz_m
Definition FM3DH5Block.h:47
static FM3DH5Block create(const std::string &filename)
std::vector< double > FieldstrengthHx_m
Definition FM3DH5Block.h:48
virtual void readMap()
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)
unsigned int num_gridpx_m
void getFieldInfo(const char *)
void readField(const char *name, double *x, double *y, double *z)
void openFileMPIOCollective(const std::string &filename)
long long getNumSteps(void)
unsigned int num_gridpz_m
unsigned int num_gridpy_m
std::vector< double > FieldstrengthEy_m
std::vector< double > FieldstrengthEx_m
Vektor< double, 3 > Vector_t