ENH: vtkSurfaceWriter: user-specifiable precision.

Partly solves #65. Ensight writer is fixed but all the other ones probably
need doing as well.
This commit is contained in:
mattijs
2016-06-01 17:43:14 +01:00
parent 8a7880af2e
commit 2a07e34fb0
5 changed files with 37 additions and 6 deletions

View File

@ -74,6 +74,11 @@ formatOptions
//collateTimes true; // write single file containing multiple timesteps
// (only for static surfaces)
}
vtk
{
// Non-default write precision for floating point numbers
writePrecision 10;
}
nastran
{
// From OpenFOAM field name to Nastran field name

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -122,7 +122,7 @@ void Foam::functionObjectFile::resetFile(const word& fileName)
Foam::Omanip<int> Foam::functionObjectFile::valueWidth(const label offset) const
{
return setw(IOstream::defaultPrecision() + addChars + offset);
return setw(writePrecision_ + addChars + offset);
}
@ -211,7 +211,7 @@ bool Foam::functionObjectFile::writeToFile() const
Foam::label Foam::functionObjectFile::charWidth() const
{
return IOstream::defaultPrecision() + addChars;
return writePrecision_ + addChars;
}

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 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
namespace Foam
{
makeSurfaceWriterType(vtkSurfaceWriter);
addToRunTimeSelectionTable(surfaceWriter, vtkSurfaceWriter, wordDict);
}
@ -202,7 +203,22 @@ namespace Foam
Foam::vtkSurfaceWriter::vtkSurfaceWriter()
:
surfaceWriter()
surfaceWriter(),
writePrecision_(IOstream::defaultPrecision())
{}
Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& dict)
:
surfaceWriter(),
writePrecision_
(
dict.lookupOrDefault
(
"writePrecision",
IOstream::defaultPrecision()
)
)
{}
@ -229,6 +245,7 @@ Foam::fileName Foam::vtkSurfaceWriter::write
}
OFstream os(outputDir/surfaceName + ".vtk");
os.precision(writePrecision_);
if (verbose)
{

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 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,6 +50,11 @@ class vtkSurfaceWriter
:
public surfaceWriter
{
// Private data
const unsigned int writePrecision_;
// Private Member Functions
static void writeGeometry(Ostream&, const pointField&, const faceList&);
@ -84,6 +89,9 @@ public:
//- Construct null
vtkSurfaceWriter();
//- Construct with some output options
vtkSurfaceWriter(const dictionary& options);
//- Destructor
virtual ~vtkSurfaceWriter();

View File

@ -63,6 +63,7 @@ Foam::fileName Foam::vtkSurfaceWriter::writeTemplate
}
OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk");
os.precision(writePrecision_);
if (verbose)
{