diff --git a/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C b/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C index d59fd99ecd..95508b6d82 100644 --- a/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C +++ b/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C @@ -200,13 +200,14 @@ int main(int argc, char *argv[]) << objName << nl << "ASCII\n" << "DATASET POLYDATA\n" - << "POINTS " << points.size() << " float\n"; + << "POINTS " << points.size() << " double\n"; - forAll(points, i) + for (const point& pt : points) { - const point& pt = points[i]; - - outFile << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + outFile + << float(pt.x()) << ' ' + << float(pt.y()) << ' ' + << float(pt.z()) << nl; } outFile @@ -265,7 +266,7 @@ int main(int argc, char *argv[]) outFile << "POINT_DATA " << points.size() << nl - << "SCALARS pointID float 1\n" + << "SCALARS pointID double 1\n" << "LOOKUP_TABLE default\n"; forAll(points, i) @@ -284,13 +285,14 @@ int main(int argc, char *argv[]) if (!pointNormals.empty()) { - outFile << nl << "NORMALS pointNormals float\n"; + outFile << nl << "NORMALS pointNormals double\n"; - forAll(pointNormals, i) + for(const vector& n : pointNormals) { - const vector& n = pointNormals[i]; - - outFile << n.x() << ' ' << n.y() << ' ' << n.z() << nl; + outFile + << float(n.x()) << ' ' + << float(n.y()) << ' ' + << float(n.z()) << nl; } } diff --git a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C index f48080f69d..7c1d26bacd 100644 --- a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C +++ b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C @@ -71,12 +71,13 @@ void Foam::vtkSetWriter::write << points.name() << nl << "ASCII" << nl << "DATASET POLYDATA" << nl - << "POINTS " << points.size() << " float" << nl; + << "POINTS " << points.size() << " double" << nl; - forAll(points, i) + for (const point& pt : points) { - const vector& pt = points[i]; - os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + os << float(pt.x()) << ' ' + << float(pt.y()) << ' ' + << float(pt.z()) << nl; } os << "POINT_DATA " << points.size() << nl @@ -132,15 +133,16 @@ void Foam::vtkSetWriter::write << tracks[0].name() << nl << "ASCII" << nl << "DATASET POLYDATA" << nl - << "POINTS " << nPoints << " float" << nl; + << "POINTS " << nPoints << " double" << nl; forAll(tracks, trackI) { const coordSet& points = tracks[trackI]; - forAll(points, i) + for (const point& pt : points) { - const vector& pt = points[i]; - os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + os << float(pt.x()) << ' ' + << float(pt.y()) << ' ' + << float(pt.z()) << nl; } } diff --git a/src/meshTools/edgeMesh/edgeMeshFormats/vtk/VTKedgeFormat.C b/src/meshTools/edgeMesh/edgeMeshFormats/vtk/VTKedgeFormat.C index fd72bf1b87..9f96dae397 100644 --- a/src/meshTools/edgeMesh/edgeMeshFormats/vtk/VTKedgeFormat.C +++ b/src/meshTools/edgeMesh/edgeMeshFormats/vtk/VTKedgeFormat.C @@ -45,12 +45,12 @@ void Foam::fileFormats::VTKedgeFormat::writeHeader << "DATASET POLYDATA" << nl; // Write vertex coords - os << "POINTS " << pointLst.size() << " float" << nl; - forAll(pointLst, ptI) + os << "POINTS " << pointLst.size() << " double" << nl; + for (const point& pt : pointLst) { - const point& pt = pointLst[ptI]; - - os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + os << float(pt.x()) << ' ' + << float(pt.y()) << ' ' + << float(pt.z()) << nl; } } @@ -63,10 +63,8 @@ void Foam::fileFormats::VTKedgeFormat::writeEdges { os << "LINES " << edgeLst.size() << ' ' << 3*edgeLst.size() << nl; - forAll(edgeLst, edgeI) + for (const edge& e : edgeLst) { - const edge& e = edgeLst[edgeI]; - os << "2 " << e[0] << ' ' << e[1] << nl; } } diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C index 38ee0a1e36..9422040176 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -96,7 +96,7 @@ namespace Foam const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " double" << nl; forAll(values, elemI) { @@ -125,7 +125,7 @@ namespace Foam const Field& values ) { - os << "3 " << values.size() << " float" << nl; + os << "3 " << values.size() << " double" << nl; for (const vector& v : values) { @@ -143,7 +143,7 @@ namespace Foam const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " double" << nl; for (const sphericalTensor& v : values) { @@ -159,7 +159,7 @@ namespace Foam const Field& values ) { - os << "6 " << values.size() << " float" << nl; + os << "6 " << values.size() << " double" << nl; // symmTensor ( XX, XY, XZ, YY, YZ, ZZ ) // VTK order ( XX, YY, ZZ, XY, YZ, XZ ) -> (0, 3, 5, 1, 4, 2) @@ -181,7 +181,7 @@ namespace Foam const Field& values ) { - os << "9 " << values.size() << " float" << nl; + os << "9 " << values.size() << " double" << nl; for (const tensor& v : values) { diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H index b261f5a301..b55289bc34 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,11 @@ Class Description A surfaceWriter for VTK legacy format. +Note + Uses ASCII-only output. + All data are written as \c double due to portability issues + (paraview on window). + SourceFiles vtkSurfaceWriter.C diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterTemplates.C index ee7c129d52..4d3327f8b6 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,9 +35,13 @@ void Foam::vtkSurfaceWriter::writeData const Field& values ) { - os << "1 " << values.size() << " float" << nl; + // Unspecialized (unknown) data type - map as zeros - forAll(values, elemI) + const label len = values.size(); + + os << "1 " << len << " double" << nl; + + for (label i=0; i < len; ++i) { os << float(0) << nl; } diff --git a/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug b/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug index 19c0f2d5c6..27db547823 100644 --- a/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug +++ b/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug @@ -15,6 +15,7 @@ debug sampleScheme cellPoint; interpolationScheme cellPoint; surfaceFormat ensight; + // surfaceFormat vtk; formatOptions {