Skip to content
Snippets Groups Projects
Commit 771d0330 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

small errors in imagedata writer resolved

parent 5c761404
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,7 @@ public:
}
/// Extract the ordinates from the Coordinates object of the current level
/// Extract the ordinates from the coordinates object of the current level
template <class T>
std::array<std::vector<T>, 3> coordinatesImpl () const
{
......@@ -119,7 +119,6 @@ private:
std::array<int, 6> extent_;
FieldVector<ctype,3> origin_;
FieldVector<ctype,3> spacing_;
std::vector<std::size_t> indexMap_;
int level_;
};
......
......@@ -32,7 +32,7 @@ void VtkImageDataWriter<GV,DC>
std::vector<pos_type> offsets; // pos => offset
out << "<VTKFile"
<< " type=\"StructuredGrid\""
<< " type=\"ImageData\""
<< " version=\"1.0\""
<< " byte_order=\"" << this->getEndian() << "\""
<< " header_type=\"UInt64\""
......@@ -110,7 +110,7 @@ void VtkImageDataWriter<GV,DC>
assert(out.is_open());
out << "<VTKFile"
<< " type=\"StructuredGrid\""
<< " type=\"PImageData\""
<< " version=\"1.0\""
<< " byte_order=\"" << this->getEndian() << "\""
<< " header_type=\"UInt64\""
......
......@@ -51,7 +51,7 @@ void writer_old (GridView const& gridView)
for (auto const& test_case : test_cases_old) {
t.reset();
VTKWriter<GridView> vtkWriter(gridView, std::get<2>(test_case));
vtkWriter.write("/tmp/writer_old_" + std::get<0>(test_case) + ".vtu",
vtkWriter.write("writer_old_" + std::get<0>(test_case) + ".vtu",
std::get<1>(test_case));
std::cout << " time (writer_old_" + std::get<0>(test_case) + ") = " << t.elapsed() << "\n";
}
......@@ -64,7 +64,7 @@ void writer_new (GridView const& gridView)
experimental::VtkUnstructuredGridWriter<GridView> vtkWriter(gridView);
for (auto const& test_case : test_cases_new) {
t.reset();
vtkWriter.write("/tmp/writer_new_" + std::get<0>(test_case) + ".vtu",
vtkWriter.write("writer_new_" + std::get<0>(test_case) + ".vtu",
std::get<1>(test_case), std::get<2>(test_case));
std::cout << " time (writer_new_" + std::get<0>(test_case) + ") = " << t.elapsed() << "\n";
}
......@@ -103,7 +103,7 @@ int main (int argc, char** argv)
using GridType = YaspGrid<dim.value>;
FieldVector<double,dim.value> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim.value,int>(10);
GridType grid(upperRight, numElements);
GridType grid(upperRight, numElements, 0, 0);
std::cout << "DIMENSION " << dim.value << "\n";
writer_old(grid.leafGridView());
......
......@@ -23,6 +23,7 @@
#include <dune/vtk/writers/vtkimagedatawriter.hh>
#include <dune/vtk/writers/vtkrectilineargridwriter.hh>
#include <dune/vtk/writers/vtkstructuredgridwriter.hh>
#include <dune/vtk/writers/vtkunstructuredgridwriter.hh>
#include <dune/vtk/datacollectors/yaspdatacollector.hh>
#include <dune/vtk/datacollectors/spdatacollector.hh>
......@@ -36,7 +37,7 @@ using int_ = std::integral_constant<int,dim>;
template <class GridView>
void write(std::string prefix, GridView const& gridView)
{
auto fct2 = makeAnalyticGridViewFunction([](auto const& x) {
auto fct2 = makeAnalyticGridViewFunction([](auto const& x) -> float {
return std::sin(10*x[0]) * (x.size() > 1 ? std::cos(10*x[1]) : 1) + (x.size() > 2 ? std::sin(10*x[2]) : 0);
}, gridView);
......@@ -44,21 +45,28 @@ void write(std::string prefix, GridView const& gridView)
using Writer = VtkImageDataWriter<GridView>;
Writer vtkWriter(gridView);
vtkWriter.addPointData(fct2, "analytic");
vtkWriter.write(prefix + "id_ascii_float32.vti", Vtk::ASCII);
vtkWriter.write(prefix + "id_ascii_float32.vti", Vtk::ASCII, Vtk::FLOAT32);
}
{
using Writer = VtkRectilinearGridWriter<GridView>;
Writer vtkWriter(gridView);
vtkWriter.addPointData(fct2, "analytic");
vtkWriter.write(prefix + "rg_ascii_float32.vtr", Vtk::ASCII);
vtkWriter.write(prefix + "rg_ascii_float32.vtr", Vtk::ASCII, Vtk::FLOAT32);
}
{
using Writer = VtkStructuredGridWriter<GridView>;
Writer vtkWriter(gridView);
vtkWriter.addPointData(fct2, "analytic");
vtkWriter.write(prefix + "sg_ascii_float32.vts", Vtk::ASCII);
vtkWriter.write(prefix + "sg_ascii_float32.vts", Vtk::ASCII, Vtk::FLOAT32);
}
{
using Writer = VtkUnstructuredGridWriter<GridView>;
Writer vtkWriter(gridView);
vtkWriter.addPointData(fct2, "analytic");
vtkWriter.write(prefix + "ug_ascii_float32.vts", Vtk::ASCII, Vtk::FLOAT32);
}
}
......@@ -67,9 +75,9 @@ void write_yaspgrid(std::integral_constant<int,dim>)
{
using GridType = YaspGrid<dim>;
FieldVector<double,dim> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim,int>(8);
auto numElements = filledArray<dim,int>(16);
GridType grid(upperRight,numElements,0,0);
grid.globalRefine(1);
grid.globalRefine(3);
write("yasp_" + std::to_string(dim) + "d_", grid.leafGridView());
}
......@@ -80,7 +88,7 @@ void write_spgrid(std::integral_constant<int,dim>)
#if HAVE_DUNE_SPGRID
using GridType = SPGrid<double,dim, SPIsotropicRefinement>;
FieldVector<double,dim> upperRight; upperRight = 1.0;
auto numElements = filledArray<dim,int>(8);
auto numElements = filledArray<dim,int>(12);
GridType grid(SPDomain<double,dim>::unitCube(),numElements);
// grid.globalRefine(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment