ENH: use double for VTK legacy output (issue #891)
- some paraview versions (eg, on windows) don't support float, only double. This mostly affected the vtkSurfaceWriter. The foamToVTK is also affected, but since it also supports the XML output formats (vtp, vtu) these can be used instead.
This commit is contained in:
parent
813a0500e2
commit
1f953b807c
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,13 @@ void Foam::vtkSetWriter<Type>::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<Type>::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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<scalar>& values
|
||||
)
|
||||
{
|
||||
os << "1 " << values.size() << " float" << nl;
|
||||
os << "1 " << values.size() << " double" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
@ -125,7 +125,7 @@ namespace Foam
|
||||
const Field<vector>& 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<sphericalTensor>& 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<symmTensor>& 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<tensor>& values
|
||||
)
|
||||
{
|
||||
os << "9 " << values.size() << " float" << nl;
|
||||
os << "9 " << values.size() << " double" << nl;
|
||||
|
||||
for (const tensor& v : values)
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<Type>& 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;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ debug
|
||||
sampleScheme cellPoint;
|
||||
interpolationScheme cellPoint;
|
||||
surfaceFormat ensight;
|
||||
// surfaceFormat vtk;
|
||||
|
||||
formatOptions
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user