Commit 28428f2f authored by frey_m's avatar frey_m
Browse files

FieldWriter: fix field access

parent 000ae465
......@@ -21,6 +21,8 @@
#include <string>
#include "Algorithms/PBunchDefs.h"
class FieldWriter
{
public:
......@@ -37,7 +39,6 @@ public:
void dumpField(FieldType& field, std::string name,
std::string unit, long long step,
FieldType* image = nullptr);
};
#include "FieldWriter.hpp"
......
......@@ -4,9 +4,9 @@
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include "Algorithms/PBunchDefs.h"
#include "Utilities/Util.h"
#include "AbstractObjects/OpalData.h"
#include "Algorithms/PBunchDefs.h"
template<typename FieldType>
void FieldWriter::dumpField(FieldType& field, std::string name,
......@@ -58,6 +58,7 @@ void FieldWriter::dumpField(FieldType& field, std::string name,
for (int x = localIdx[0].first(); x <= localIdx[0].last(); x++) {
for (int y = localIdx[1].first(); y <= localIdx[1].last(); y++) {
for (int z = localIdx[2].first(); z <= localIdx[2].last(); z++) {
NDIndex<3> idx(Index(x, x), Index(y, y), Index(z, z));
fout << std::setw(5) << x + 1
<< std::setw(5) << y + 1
<< std::setw(5) << z + 1
......@@ -65,16 +66,16 @@ void FieldWriter::dumpField(FieldType& field, std::string name,
<< std::setw(17) << origin(1) + y * spacing(1)
<< std::setw(17) << origin(2) + z * spacing(2);
if (isVectorField) {
Vector_t vfield = field[x][y][z].get();
Vector_t vfield = field.localElement(idx);
fout << std::setw(17) << vfield[0]
<< std::setw(17) << vfield[1]
<< std::setw(17) << vfield[2];
} else {
fout << std::setw(17) << field[x][y][z].get();
fout << std::setw(17) << field.localElement(idx);
}
if (image) {
fout << std::setw(17) << image[x][y][z].get();
fout << std::setw(17) << image->localElement(idx);
}
fout << std::endl;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment