OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
DumpFields.h
Go to the documentation of this file.
1 //
2 // Class DumpFields
3 // DumpFields dumps the static magnetic field of a Ring in a user-defined grid
4 //
5 // Copyright (c) 2016, Chris Rogers
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 #ifndef OPAL_DUMPFIELDS_HH
19 #define OPAL_DUMPFIELDS_HH
20 
21 #include "AbsBeamline/Component.h"
22 #include "AbstractObjects/Action.h"
23 
24 #include <string>
25 #include <unordered_set>
26 
27 namespace interpolation {
28  class ThreeDGrid;
29 }
30 
31 class Component;
32 
54 class DumpFields: public Action {
55 
56 public:
58  enum {
61  DX,
64  DY,
67  DZ,
69  SIZE
70  };
71 
73  DumpFields();
74 
76  DumpFields(const std::string& name, DumpFields* parent);
77 
79  virtual ~DumpFields();
80 
86  virtual DumpFields* clone(const std::string& name);
87 
94  virtual void execute();
95 
111  static void writeFields(Component* field);
112 
114  void print(std::ostream& os) const;
115 
116 private:
117  virtual void writeFieldThis(Component* field);
118  virtual void buildGrid();
119  static void checkInt(double value, std::string name, double tolerance = 1e-9);
120 
122 
123  std::string filename_m;
124 
125  static std::unordered_set<DumpFields*> dumpsSet_m;
126 
127  DumpFields(const DumpFields& dump); // disabled
128  DumpFields& operator=(const DumpFields& dump); // disabled
129 };
130 
131 inline std::ostream& operator<<(std::ostream& os, const DumpFields& b) {
132  b.print(os);
133  return os;
134 }
135 
136 #endif // ifdef OPAL_DUMPFIELDS_HH
std::ostream & operator<<(std::ostream &os, const DumpFields &b)
Definition: DumpFields.h:131
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
static void checkInt(double value, std::string name, double tolerance=1e-9)
Definition: DumpFields.cpp:136
DumpFields & operator=(const DumpFields &dump)
virtual void writeFieldThis(Component *field)
Definition: DumpFields.cpp:148
std::string filename_m
Definition: DumpFields.h:123
DumpFields(const DumpFields &dump)
void print(std::ostream &os) const
Definition: DumpFields.cpp:204
virtual void buildGrid()
Definition: DumpFields.cpp:104
static void writeFields(Component *field)
Definition: DumpFields.cpp:129
static std::unordered_set< DumpFields * > dumpsSet_m
Definition: DumpFields.h:125
interpolation::ThreeDGrid * grid_m
Definition: DumpFields.h:121
virtual void execute()
Definition: DumpFields.cpp:95
virtual DumpFields * clone(const std::string &name)
Definition: DumpFields.cpp:83
virtual ~DumpFields()
Definition: DumpFields.cpp:78
Interface for a single beam element.
Definition: Component.h:50