From a88ace33b472610c09d51d87b42b5ff056b6c2e4 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Sat, 25 Oct 2014 12:01:42 +0000 Subject: [PATCH] Allow to write one set of scalar cell data [[Imported from SVN: r9930]] --- dune/gfe/vtkfile.hh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/dune/gfe/vtkfile.hh b/dune/gfe/vtkfile.hh index 56a6cb19..71a59dbd 100644 --- a/dune/gfe/vtkfile.hh +++ b/dune/gfe/vtkfile.hh @@ -59,6 +59,10 @@ namespace Dune { writer.addArray<float>("zCoord", 1); writer.endPointData(); + writer.beginCellData(); + writer.addArray<float>("mycelldata", 1); + writer.endCellData(); + // dump point coordinates writer.beginPoints(); writer.addArray<float>("Coordinates", 3); @@ -112,7 +116,9 @@ namespace Dune { outFile << " </Cells>" << std::endl; - // Point data + ////////////////////////////////////////////////// + // Point data + ////////////////////////////////////////////////// outFile << " <PointData Scalars=\"zCoord\" Vectors=\"director0\">" << std::endl; // Z coordinate for better visualization of wrinkles @@ -132,7 +138,25 @@ namespace Dune { outFile << " </PointData>" << std::endl; - // Write footer + ////////////////////////////////////////////////// + // Cell data + ////////////////////////////////////////////////// + + if (cellData_.size() > 0) + { + outFile << " <CellData>" << std::endl; + + outFile << " <DataArray type=\"Float32\" Name=\"mycelldata\" NumberOfComponents=\"1\" format=\"ascii\">" << std::endl; + for (size_t i=0; i<cellData_.size(); i++) + outFile << " " << cellData_[i] << std::endl; + outFile << " </DataArray>" << std::endl; + + outFile << " </CellData>" << std::endl; + } + + ////////////////////////////////////////////////// + // Write footer + ////////////////////////////////////////////////// outFile << " </Piece>" << std::endl; outFile << " </UnstructuredGrid>" << std::endl; outFile << "</VTKFile>" << std::endl; @@ -270,6 +294,8 @@ namespace Dune { std::vector<double> zCoord_; + std::vector<double> cellData_; + std::array<std::vector<Dune::FieldVector<double,3> >, 3 > directors_; private: -- GitLab