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:
Mark Olesen
2018-06-21 10:24:04 +02:00
parent 813a0500e2
commit 1f953b807c
7 changed files with 49 additions and 37 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -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;
}