22 #include <boost/filesystem.hpp>
23 #include <boost/format.hpp>
29 template<
typename FieldType>
31 std::string unit,
long long step,
38 constexpr
bool isVectorField = std::is_same<VField_t, FieldType>::value;
39 std::string
type = (isVectorField) ?
"field" :
"scalar";
58 boost::filesystem::path file(dirname);
59 boost::format filename(
"%1%-%2%-%|3$06|.dat");
61 filename % basename % (
name + std::string(
"_") +
type) % step;
62 file /= filename.str();
64 std::ofstream fout(file.string(), std::ios::out);
69 << std::setw(4) <<
"i"
70 << std::setw(5) <<
"j"
71 << std::setw(5) <<
"k"
72 << std::setw(17) <<
"x [m]"
73 << std::setw(17) <<
"y [m]"
74 << std::setw(17) <<
"z [m]";
76 fout << std::setw(10) <<
name <<
"x [" << unit <<
"]"
77 << std::setw(10) <<
name <<
"y [" << unit <<
"]"
78 << std::setw(10) <<
name <<
"z [" << unit <<
"]";
80 fout << std::setw(13) <<
name <<
" [" << unit <<
"]";
84 fout << std::setw(13) <<
name <<
" image [" << unit <<
"]";
89 Vector_t origin = field.get_mesh().get_origin();
90 Vector_t spacing(field.get_mesh().get_meshSpacing(0),
91 field.get_mesh().get_meshSpacing(1),
92 field.get_mesh().get_meshSpacing(2));
94 NDIndex<3> localIdx = field.getLayout().getLocalNDIndex();
95 for (
int x = localIdx[0].first(); x <= localIdx[0].last(); x++) {
96 for (
int y = localIdx[1].first(); y <= localIdx[1].last(); y++) {
97 for (
int z = localIdx[2].first(); z <= localIdx[2].last(); z++) {
99 fout << std::setw(5) << x + 1
100 << std::setw(5) << y + 1
101 << std::setw(5) << z + 1
102 << std::setw(17) << origin(0) + x * spacing(0)
103 << std::setw(17) << origin(1) + y * spacing(1)
104 << std::setw(17) << origin(2) + z * spacing(2);
106 Vector_t vfield = field.localElement(idx);
107 fout << std::setw(17) << vfield[0]
108 << std::setw(17) << vfield[1]
109 << std::setw(17) << vfield[2];
111 fout << std::setw(17) << field.localElement(idx);
115 fout << std::setw(17) << image->localElement(idx);
Inform & endl(Inform &inf)
std::string toUpper(const std::string &str)
boost::function< boost::tuple< double, bool >arguments_t)> type
std::string getInputBasename()
get input file name without extension
static OpalData * getInstance()
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
void dumpField(FieldType &field, std::string name, std::string unit, long long step, FieldType *image=nullptr)
Dump a scalar or vector field to a file.