OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
DumpEMFields.h
Go to the documentation of this file.
1 //
2 // Class DumpEMFields
3 // DumpEMFields dumps the dynamically changing fields of a Ring in a user-
4 // defined grid.
5 //
6 // Copyright (c) 2017, Chris Rogers
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
19 #ifndef OPAL_BASICACTIONS_DUMPEMFIELDS_HH
20 #define OPAL_BASICACTIONS_DUMPEMFIELDS_HH
21 
22 #include "AbsBeamline/Component.h"
23 #include "AbstractObjects/Action.h"
24 
25 #include <string>
26 #include <unordered_set>
27 #include <vector>
28 
29 namespace interpolation {
30  class NDGrid;
31 }
32 class Component;
33 
54 class DumpEMFields: public Action {
55 
56 public:
58  enum {
62  DX,
65  DY,
68  DZ,
71  DT,
74  DR,
79  SIZE
80  };
81 
83  DumpEMFields();
84 
86  DumpEMFields(const std::string& name, DumpEMFields* parent);
87 
89  virtual ~DumpEMFields();
90 
96  virtual DumpEMFields* clone(const std::string& name);
97 
104  virtual void execute();
105 
121  static void writeFields(Component* field);
122 
124  void print(std::ostream& os) const;
125 
126 private:
127 
128  enum class CoordinateSystem {
129  CARTESIAN,
131  };
132 
133  virtual void writeFieldThis(Component* field);
134  virtual void buildGrid();
135  void parseCoordinateSystem();
136  static void checkInt(double value, std::string name, double tolerance = 1e-9);
137  void writeHeader(std::ofstream& fout) const;
138  void writeFieldLine(Component* field,
139  const Vector_t& point,
140  const double& time,
141  std::ofstream& fout) const;
142 
144  std::string filename_m;
146 
147  static std::unordered_set<DumpEMFields*> dumpsSet_m;
148 
149  DumpEMFields(const DumpEMFields& dump); // disabled
150  DumpEMFields& operator=(const DumpEMFields& dump); // disabled
151 };
152 
153 inline std::ostream& operator<<(std::ostream& os, const DumpEMFields& b) {
154  b.print(os);
155  return os;
156 }
157 
158 #endif // ifdef OPAL_DUMPFIELDS_HH
std::ostream & operator<<(std::ostream &os, const DumpEMFields &b)
Definition: DumpEMFields.h:153
const std::string name
constexpr double e
The value of.
Definition: Physics.h:39
The base class for all OPAL actions.
Definition: Action.h:30
virtual void writeFieldThis(Component *field)
virtual void buildGrid()
void print(std::ostream &os) const
static std::unordered_set< DumpEMFields * > dumpsSet_m
Definition: DumpEMFields.h:147
void parseCoordinateSystem()
std::string filename_m
Definition: DumpEMFields.h:144
static void writeFields(Component *field)
DumpEMFields & operator=(const DumpEMFields &dump)
interpolation::NDGrid * grid_m
Definition: DumpEMFields.h:143
CoordinateSystem coordinates_m
Definition: DumpEMFields.h:145
void writeHeader(std::ofstream &fout) const
virtual void execute()
static void checkInt(double value, std::string name, double tolerance=1e-9)
virtual DumpEMFields * clone(const std::string &name)
void writeFieldLine(Component *field, const Vector_t &point, const double &time, std::ofstream &fout) const
virtual ~DumpEMFields()
DumpEMFields(const DumpEMFields &dump)
Interface for a single beam element.
Definition: Component.h:50