40 std::string(
"The \"DUMPFIELDS\" statement dumps a field map to a user-defined")+
41 std::string(
" field file, for checking that fields are read in correctly")+
42 std::string(
" from disk. The fields are written out on a Cartesian grid.");
45 Action(10,
"DUMPFIELDS", dumpfields_docstring.c_str()) {
48 (
"X_START",
"Start point in the grid in x [m]");
50 (
"DX",
"Grid step size in x [m]");
52 (
"X_STEPS",
"Number of steps in x");
54 (
"Y_START",
"Start point in the grid in y [m]");
56 (
"DY",
"Grid step size in y [m]");
58 (
"Y_STEPS",
"Number of steps in y");
60 (
"Z_START",
"Start point in the grid in z [m]");
62 (
"DZ",
"Grid step size in z [m]");
64 (
"Z_STEPS",
"Number of steps in z");
66 (
"FILE_NAME",
"Name of the file to which field data is dumped");
129 (*it)->writeFieldThis(field);
134 if (
fabs(
floor(real) - real) > tolerance) {
137 " should be an integer but a real value was found");
139 if (
floor(real) < 0.5) {
141 "Value for "+name+
" should be 1 or more");
148 "The grid was NULL; there was a problem with the DumpFields initialisation.");
152 "The field to be written was NULL.");
157 std::ofstream fout(
filename_m.c_str(), std::ofstream::out);
160 "Failed to open DumpFields file "+
filename_m);
164 fout << 1 <<
" x [m]\n";
165 fout << 2 <<
" y [m]\n";
166 fout << 3 <<
" z [m]\n";
167 fout << 4 <<
" Bx [kGauss]\n";
168 fout << 5 <<
" By [kGauss]\n";
169 fout << 6 <<
" Bz [kGauss]\n";
176 it.getPosition(&point[0]);
177 field->
apply(point, centroid, time, E, B);
178 fout << point[0] <<
" " << point[1] <<
" " << point[2] <<
" ";
179 fout << B[0] <<
" " << B[1] <<
" " << B[2] <<
"\n";
183 "Something went wrong during writing "+
filename_m);
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
Mesh::Iterator end() const
The base class for all OPAL actions.
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
The base class for all OPAL exceptions.
virtual void writeFieldThis(Component *field)
static std::string dumpfields_docstring
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
static void checkInt(double value, std::string name, double tolerance=1e-9)
static void writeFields(Component *field)
virtual DumpFields * clone(const std::string &name)
interpolation::ThreeDGrid * grid_m
Mesh::Iterator begin() const
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
std::string::iterator iterator
Interface for a single beam element.
double getReal(const Attribute &attr)
Return real value.
static std::unordered_set< DumpFields * > dumpsSet_m
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
std::string getString(const Attribute &attr)
Get string value.