OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ElementPositionWriter.cpp
Go to the documentation of this file.
2
3#include "Ippl.h"
5
7 : SDDSWriter(fname, false)
8{ }
9
10
12
13 if (this->hasColumns()) {
14 return;
15 }
16
17 this->addDescription("Element positions '" + OpalData::getInstance()->getInputFn() + "'",
18 "element positions");
20
22 "double",
23 "m",
24 "longitudinal position",
25 std::ios_base::fixed,
26 10);
27 columns_m.addColumn("dipole",
28 "float",
29 "1",
30 "dipole field present",
31 std::ios_base::fixed,
32 4);
33 columns_m.addColumn("quadrupole",
34 "float",
35 "1",
36 "quadrupole field present",
37 std::ios_base::fixed,
38 0);
39 columns_m.addColumn("sextupole",
40 "float",
41 "1",
42 "sextupole field present",
43 std::ios_base::fixed,
44 1);
45 columns_m.addColumn("octupole",
46 "float",
47 "1",
48 "octupole field present",
49 std::ios_base::fixed,
50 2);
51 columns_m.addColumn("decapole",
52 "float",
53 "1",
54 "decapole field present",
55 std::ios_base::fixed,
56 0);
57 columns_m.addColumn("multipole",
58 "float",
59 "1",
60 "higher multipole field present",
61 std::ios_base::fixed,
62 0);
63 columns_m.addColumn("solenoid",
64 "float",
65 "1",
66 "solenoid field present",
67 std::ios_base::fixed,
68 0);
69 columns_m.addColumn("rfcavity",
70 "float",
71 "1",
72 "RF field present",
73 std::ios_base::fixed,
74 4);
75 columns_m.addColumn("monitor",
76 "float",
77 "1",
78 "monitor present",
79 std::ios_base::fixed,
80 0);
81 columns_m.addColumn("other",
82 "float",
83 "1",
84 "other element present",
85 std::ios_base::fixed,
86 0);
87 columns_m.addColumn("element_names",
88 "string",
89 "",
90 "names of elements");
91
92 this->addInfo("ascii", 1);
93}
94
95
97 const std::vector<double> &row,
98 const std::string &elements) {
99
100 if ( Ippl::myNode() != 0 )
101 return;
102
103
104 this->fillHeader();
105
106 this->open();
107
108 this->writeHeader();
109
110 static const std::vector<double> typeMultipliers = {3.3333e-1,
111 1.0,
112 0.5,
113 0.25,
114 1.0,
115 1.0,
116 1.0,
117 1.0,
118 1.0,
119 1.0};
120
121 static const std::vector<std::string> columnNames = {"dipole",
122 "quadrupole",
123 "sextupole",
124 "octupole",
125 "decapole",
126 "multipole",
127 "solenoid",
128 "rfcavity",
129 "monitor",
130 "other"};
131
132 columns_m.addColumnValue("s", spos);
133 for (unsigned int i = 0; i < columnNames.size(); ++ i) {
134 columns_m.addColumnValue(columnNames[i], row[i] * typeMultipliers[i]);
135 }
136 columns_m.addColumnValue("element_names", elements);
137
138 this->writeRow();
139
140 this->close();
141}
elements
Definition: IndexMap.cpp:163
static OpalData * getInstance()
Definition: OpalData.cpp:196
void addRow(double spos, const std::vector< double > &row, const std::string &elements)
ElementPositionWriter(const std::string &fname)
void addColumn(const std::string &name, const std::string &type, const std::string &unit, const std::string &desc, std::ios_base::fmtflags flags=std::ios_base::scientific, unsigned short precision=15)
void addColumnValue(const std::string &name, const T &val)
Definition: SDDSColumnSet.h:63
SDDSColumnSet columns_m
Definition: SDDSWriter.h:126
bool hasColumns() const
Definition: SDDSWriter.h:207
void addDefaultParameters()
Definition: SDDSWriter.cpp:211
void addDescription(const std::string &text, const std::string &content)
Definition: SDDSWriter.h:164
void open()
Definition: SDDSWriter.cpp:134
void writeHeader()
Write SDDS header.
Definition: SDDSWriter.cpp:151
void close()
Definition: SDDSWriter.cpp:144
void writeRow()
Definition: SDDSWriter.h:192
void addInfo(const std::string &mode, const size_t &no_row_counts)
Definition: SDDSWriter.h:185
static int myNode()
Definition: IpplInfo.cpp:691