OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
H5Writer.cpp
Go to the documentation of this file.
1 #include "H5Writer.h"
2 
3 H5Writer::H5Writer(H5PartWrapper* h5wrapper, bool restart)
4  : H5PartTimer_m(IpplTimings::getTimer("Write H5-File"))
5  , h5wrapper_m(h5wrapper)
6  , H5call_m(0)
7 {
8  if ( !restart ) {
9  h5wrapper->writeHeader();
10  }
11  h5wrapper->close();
12 }
13 
14 
17  std::map<std::string, double> additionalAttributes = {
18  std::make_pair("B-ref_x", FDext[0](0)),
19  std::make_pair("B-ref_z", FDext[0](1)),
20  std::make_pair("B-ref_y", FDext[0](2)),
21  std::make_pair("E-ref_x", FDext[1](0)),
22  std::make_pair("E-ref_z", FDext[1](1)),
23  std::make_pair("E-ref_y", FDext[1](2))};
24 
25  h5wrapper_m->writeStep(beam, additionalAttributes);
27 }
28 
29 
30 int H5Writer::writePhaseSpace(PartBunchBase<double, 3> *beam, Vector_t FDext[], double meanEnergy,
31  double refPr, double refPt, double refPz,
32  double refR, double refTheta, double refZ,
33  double azimuth, double elevation, bool local) {
34 
35  if (beam->getTotalNum() < 3) return -1; // in single particle mode and tune calculation (2 particles) we do not need h5 data
36 
38  std::map<std::string, double> additionalAttributes = {
39  std::make_pair("REFPR", refPr),
40  std::make_pair("REFPT", refPt),
41  std::make_pair("REFPZ", refPz),
42  std::make_pair("REFR", refR),
43  std::make_pair("REFTHETA", refTheta),
44  std::make_pair("REFZ", refZ),
45  std::make_pair("AZIMUTH", azimuth),
46  std::make_pair("ELEVATION", elevation),
47  std::make_pair("B-head_x", FDext[0](0)),
48  std::make_pair("B-head_z", FDext[0](1)),
49  std::make_pair("B-head_y", FDext[0](2)),
50  std::make_pair("E-head_x", FDext[1](0)),
51  std::make_pair("E-head_z", FDext[1](1)),
52  std::make_pair("E-head_y", FDext[1](2)),
53  std::make_pair("B-ref_x", FDext[2](0)),
54  std::make_pair("B-ref_z", FDext[2](1)),
55  std::make_pair("B-ref_y", FDext[2](2)),
56  std::make_pair("E-ref_x", FDext[3](0)),
57  std::make_pair("E-ref_z", FDext[3](1)),
58  std::make_pair("E-ref_y", FDext[3](2)),
59  std::make_pair("B-tail_x", FDext[4](0)),
60  std::make_pair("B-tail_z", FDext[4](1)),
61  std::make_pair("B-tail_y", FDext[4](2)),
62  std::make_pair("E-tail_x", FDext[5](0)),
63  std::make_pair("E-tail_z", FDext[5](1)),
64  std::make_pair("E-tail_y", FDext[5](2))};
65 
66  h5wrapper_m->writeStep(beam, additionalAttributes);
68 
69  ++ H5call_m;
70  return H5call_m - 1;
71 }
72 
73 
75  double sposHead, double sposRef,
76  double sposTail)
77 {
78  // FIXME https://gitlab.psi.ch/OPAL/src/issues/245
79 
81  std::map<std::string, double> additionalAttributes = {
82  std::make_pair("sposHead", sposHead),
83  std::make_pair("sposRef", sposRef),
84  std::make_pair("sposTail", sposTail),
85  std::make_pair("B-head_x", FDext[0](0)),
86  std::make_pair("B-head_z", FDext[0](1)),
87  std::make_pair("B-head_y", FDext[0](2)),
88  std::make_pair("E-head_x", FDext[1](0)),
89  std::make_pair("E-head_z", FDext[1](1)),
90  std::make_pair("E-head_y", FDext[1](2)),
91  std::make_pair("B-ref_x", FDext[2](0)),
92  std::make_pair("B-ref_z", FDext[2](1)),
93  std::make_pair("B-ref_y", FDext[2](2)),
94  std::make_pair("E-ref_x", FDext[3](0)),
95  std::make_pair("E-ref_z", FDext[3](1)),
96  std::make_pair("E-ref_y", FDext[3](2)),
97  std::make_pair("B-tail_x", FDext[4](0)),
98  std::make_pair("B-tail_z", FDext[4](1)),
99  std::make_pair("B-tail_y", FDext[4](2)),
100  std::make_pair("E-tail_x", FDext[5](0)),
101  std::make_pair("E-tail_z", FDext[5](1)),
102  std::make_pair("E-tail_y", FDext[5](2))};
103 
104  // does not compile with that line --> should be fixed with https://gitlab.psi.ch/OPAL/src/issues/245
105 // h5wrapper_m->writeStep(&beam, additionalAttributes);
107 }
108 
109 
110 //FIXME https://gitlab.psi.ch/OPAL/src/issues/245
111 // void H5Writer::stashPhaseSpaceEnvelope(EnvelopeBunch &beam, Vector_t FDext[], double sposHead, double sposRef, double sposTail) {
112 //
113 // if (!doHDF5_m) return;
114 //
115 // /// Start timer.
116 // IpplTimings::startTimer(H5PartTimer_m);
117 //
118 // static_cast<H5PartWrapperForPS*>(h5wrapper_m)->stashPhaseSpaceEnvelope(beam,
119 // FDext,
120 // sposHead,
121 // sposRef,
122 // sposTail);
123 // H5call_m++;
124 //
125 // /// %Stop timer.
126 // IpplTimings::stopTimer(H5PartTimer_m);
127 // }
128 //
129 // void H5Writer::dumpStashedPhaseSpaceEnvelope() {
130 //
131 // if (!doHDF5_m) return;
132 //
133 // static_cast<H5PartWrapperForPS*>(h5wrapper_m)->dumpStashedPhaseSpaceEnvelope();
134 //
135 // /// %Stop timer.
136 // IpplTimings::stopTimer(H5PartTimer_m);
137 // }
virtual void writeStep(PartBunchBase< double, 3 > *, const std::map< std::string, double > &)=0
core of the envelope tracker based on Rene Bakkers BET implementation
Definition: EnvelopeBunch.h:60
H5PartWrapper * h5wrapper_m
Definition: H5Writer.h:81
size_t getTotalNum() const
static void startTimer(TimerRef t)
Definition: IpplTimings.h:187
virtual void writeHeader()=0
IpplTimings::TimerRef H5PartTimer_m
Timer to track particle data/H5 file write time.
Definition: H5Writer.h:79
H5Writer(H5PartWrapper *h5wrapper, bool restart)
Definition: H5Writer.cpp:3
static void stopTimer(TimerRef t)
Definition: IpplTimings.h:192
int H5call_m
Current record, or time step, of H5 file.
Definition: H5Writer.h:84
void writePhaseSpace(PartBunchBase< double, 3 > *beam, Vector_t FDext[])
Dumps Phase Space to H5 file.
Definition: H5Writer.cpp:15