sampledSurface: Added support for writing surfaces in binary format

by specifying

    writeFormat binary;

in the sampledSurface dictionary.
This commit is contained in:
Henry Weller
2020-01-29 12:42:05 +00:00
parent 3631f13a98
commit 84759ee0b8
23 changed files with 154 additions and 88 deletions

View File

@ -286,7 +286,10 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
faces[fI] = surface_.triSurface::operator[](fI).triFaceFace(); faces[fI] = surface_.triSurface::operator[](fI).triFaceFace();
} }
vtkSurfaceWriter().write vtkSurfaceWriter
(
surface_.searchableSurface::time().writeFormat()
).write
( (
surface_.searchableSurface::time().constant()/"triSurface", surface_.searchableSurface::time().constant()/"triSurface",
surfaceName_.lessExt().name(), surfaceName_.lessExt().name(),

View File

@ -523,7 +523,7 @@ void Foam::writeAMIWeightsSum
// Write the surface // Write the surface
if (Pstream::master()) if (Pstream::master())
{ {
vtkSurfaceWriter().write vtkSurfaceWriter(mesh.time().writeFormat()).write
( (
file.path(), file.path(),
file.name(), file.name(),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -163,7 +163,11 @@ int main(int argc, char *argv[])
autoPtr<writer<scalar>> setWriter; autoPtr<writer<scalar>> setWriter;
if (writeSets) if (writeSets)
{ {
surfWriter = surfaceWriter::New(surfaceFormat); surfWriter = surfaceWriter::New
(
surfaceFormat,
mesh.time().writeFormat()
);
setWriter = writer<scalar>::New(vtkSetWriter<scalar>::typeName); setWriter = writer<scalar>::New(vtkSetWriter<scalar>::typeName);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -629,7 +629,7 @@ int main(int argc, char *argv[])
faces[i] = surf[i].triFaceFace(); faces[i] = surf[i].triFaceFace();
} }
vtkSurfaceWriter().write vtkSurfaceWriter(IOstream::ASCII).write
( (
surfFileName.path(), surfFileName.path(),
surfFileNameBase, surfFileNameBase,

View File

@ -463,7 +463,7 @@ namespace Foam
{ {
const faceList faces(searchSurf.faces()); const faceList faces(searchSurf.faces());
vtkSurfaceWriter().write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath()/"triSurface",// outputDir runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName searchSurf.objectRegistry::name(), // surfaceName
@ -474,7 +474,7 @@ namespace Foam
false // isNodeValues false // isNodeValues
); );
vtkSurfaceWriter().write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath()/"triSurface",// outputDir runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName searchSurf.objectRegistry::name(), // surfaceName
@ -525,7 +525,7 @@ namespace Foam
externalClosenessPointField[meshPointMap[pi]]; externalClosenessPointField[meshPointMap[pi]];
} }
vtkSurfaceWriter().write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath()/"triSurface",// outputDir runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName searchSurf.objectRegistry::name(), // surfaceName
@ -536,7 +536,7 @@ namespace Foam
true // isNodeValues true // isNodeValues
); );
vtkSurfaceWriter().write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath()/"triSurface",// outputDir runTime.constantPath()/"triSurface",// outputDir
searchSurf.objectRegistry::name(), // surfaceName searchSurf.objectRegistry::name(), // surfaceName
@ -574,7 +574,7 @@ namespace Foam
if (writeVTK) if (writeVTK)
{ {
vtkSurfaceWriter().write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath()/"triSurface",// outputDir runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName sFeatFileName, // surfaceName
@ -646,7 +646,7 @@ namespace Foam
if (writeVTK) if (writeVTK)
{ {
vtkSurfaceWriter().write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath()/"triSurface",// outputDir runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName sFeatFileName, // surfaceName

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -449,7 +449,10 @@ void Foam::ParticleCollector<CloudType>::write()
{ {
if (Pstream::master()) if (Pstream::master())
{ {
autoPtr<surfaceWriter> writer(surfaceWriter::New(surfaceFormat_)); autoPtr<surfaceWriter> writer
(
surfaceWriter::New(surfaceFormat_, time.writeFormat())
);
writer->write writer->write
( (

View File

@ -112,24 +112,19 @@ void Foam::ensightSurfaceWriter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightSurfaceWriter::ensightSurfaceWriter() Foam::ensightSurfaceWriter::ensightSurfaceWriter
(
const IOstream::streamFormat writeFormat
)
: :
surfaceWriter(), surfaceWriter(writeFormat)
writeFormat_(IOstream::ASCII)
{} {}
Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options) Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& optDict)
: :
surfaceWriter(), surfaceWriter(optDict)
writeFormat_(IOstream::ASCII) {}
{
// choose ascii or binary format
if (options.found("format"))
{
writeFormat_ = IOstream::formatEnum(options.lookup("format"));
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -50,12 +50,6 @@ class ensightSurfaceWriter
: :
public surfaceWriter public surfaceWriter
{ {
// Private Data
//- Write option (default is IOstream::ASCII
IOstream::streamFormat writeFormat_;
// Private Member Functions // Private Member Functions
//- Templated write operation //- Templated write operation
@ -80,11 +74,11 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
ensightSurfaceWriter(); ensightSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Construct with some output options //- Construct with some output options
ensightSurfaceWriter(const dictionary& options); ensightSurfaceWriter(const dictionary& optDict);
//- Destructor //- Destructor

View File

@ -80,9 +80,12 @@ void Foam::foamSurfaceWriter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamSurfaceWriter::foamSurfaceWriter() Foam::foamSurfaceWriter::foamSurfaceWriter
(
const IOstream::streamFormat writeFormat
)
: :
surfaceWriter() surfaceWriter(writeFormat)
{} {}

View File

@ -74,8 +74,8 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
foamSurfaceWriter(); foamSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Destructor //- Destructor

View File

@ -316,28 +316,31 @@ void Foam::nastranSurfaceWriter::writeGeometry
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::nastranSurfaceWriter::nastranSurfaceWriter() Foam::nastranSurfaceWriter::nastranSurfaceWriter
(
const IOstream::streamFormat writeFormat
)
: :
surfaceWriter(), surfaceWriter(writeFormat),
writeFormat_(wfShort), writeFormat_(wfShort),
fieldMap_(), fieldMap_(),
scale_(1.0) scale_(1.0)
{} {}
Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options) Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& optDict)
: :
surfaceWriter(), surfaceWriter(optDict),
writeFormat_(wfLong), writeFormat_(wfLong),
fieldMap_(), fieldMap_(),
scale_(options.lookupOrDefault("scale", 1.0)) scale_(optDict.lookupOrDefault("scale", 1.0))
{ {
if (options.found("format")) if (optDict.found("format"))
{ {
writeFormat_ = writeFormatNames_.read(options.lookup("format")); writeFormat_ = writeFormatNames_.read(optDict.lookup("format"));
} }
List<Tuple2<word, word>> fieldSet(options.lookup("fields")); List<Tuple2<word, word>> fieldSet(optDict.lookup("fields"));
forAll(fieldSet, i) forAll(fieldSet, i)
{ {

View File

@ -155,11 +155,11 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
nastranSurfaceWriter(); nastranSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Construct with some output options //- Construct with some output options
nastranSurfaceWriter(const dictionary& options); nastranSurfaceWriter(const dictionary& optDict);
//- Destructor //- Destructor

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,9 +36,9 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::noSurfaceWriter::noSurfaceWriter() Foam::noSurfaceWriter::noSurfaceWriter(const IOstream::streamFormat writeFormat)
: :
surfaceWriter() surfaceWriter(writeFormat)
{} {}

View File

@ -59,8 +59,8 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
noSurfaceWriter(); noSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Destructor //- Destructor

View File

@ -39,7 +39,7 @@ namespace Foam
Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext) Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext)
: :
surfaceWriter(), surfaceWriter(IOstream::ASCII),
ext_(ext) ext_(ext)
{} {}

View File

@ -273,22 +273,25 @@ void Foam::rawSurfaceWriter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::rawSurfaceWriter::rawSurfaceWriter() Foam::rawSurfaceWriter::rawSurfaceWriter
(
const IOstream::streamFormat writeFormat
)
: :
surfaceWriter(), surfaceWriter(writeFormat),
writeCompression_(IOstream::UNCOMPRESSED) writeCompression_(IOstream::UNCOMPRESSED)
{} {}
Foam::rawSurfaceWriter::rawSurfaceWriter(const dictionary& options) Foam::rawSurfaceWriter::rawSurfaceWriter(const dictionary& optDict)
: :
surfaceWriter(), surfaceWriter(optDict),
writeCompression_(IOstream::UNCOMPRESSED) writeCompression_(IOstream::UNCOMPRESSED)
{ {
if (options.found("compression")) if (optDict.found("compression"))
{ {
writeCompression_ = writeCompression_ =
IOstream::compressionEnum(options.lookup("compression")); IOstream::compressionEnum(optDict.lookup("compression"));
} }
} }

View File

@ -108,11 +108,11 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
rawSurfaceWriter(); rawSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Construct with some output options //- Construct with output options
rawSurfaceWriter(const dictionary& options); rawSurfaceWriter(const dictionary& optDict);
//- Destructor //- Destructor

View File

@ -119,9 +119,12 @@ void Foam::starcdSurfaceWriter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::starcdSurfaceWriter::starcdSurfaceWriter() Foam::starcdSurfaceWriter::starcdSurfaceWriter
(
const IOstream::streamFormat writeFormat
)
: :
surfaceWriter() surfaceWriter(writeFormat)
{} {}

View File

@ -97,8 +97,8 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
starcdSurfaceWriter(); starcdSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Destructor //- Destructor

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,7 +41,11 @@ namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceWriter> Foam::autoPtr<Foam::surfaceWriter>
Foam::surfaceWriter::New(const word& writeType) Foam::surfaceWriter::New
(
const word& writeType,
const IOstream::streamFormat format
)
{ {
wordConstructorTable::iterator cstrIter = wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(writeType); wordConstructorTablePtr_->find(writeType);
@ -67,12 +71,16 @@ Foam::surfaceWriter::New(const word& writeType)
} }
} }
return autoPtr<surfaceWriter>(cstrIter()()); return autoPtr<surfaceWriter>(cstrIter()(format));
} }
Foam::autoPtr<Foam::surfaceWriter> Foam::autoPtr<Foam::surfaceWriter>
Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict) Foam::surfaceWriter::New
(
const word& writeType,
const dictionary& optDict
)
{ {
// find constructors with dictionary options // find constructors with dictionary options
wordDictConstructorTable::iterator cstrIter = wordDictConstructorTable::iterator cstrIter =
@ -80,8 +88,18 @@ Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
if (cstrIter == wordDictConstructorTablePtr_->end()) if (cstrIter == wordDictConstructorTablePtr_->end())
{ {
// revert to versions without options IOstream::streamFormat writeFormat = IOstream::ASCII;
return Foam::surfaceWriter::New(writeType);
if (optDict.found("writeFormat"))
{
writeFormat = IOstream::formatEnum
(
optDict.lookup("writeFormat")
);
}
// Revert to versions without options
return Foam::surfaceWriter::New(writeType, writeFormat);
} }
return autoPtr<surfaceWriter>(cstrIter()(optDict)); return autoPtr<surfaceWriter>(cstrIter()(optDict));
@ -90,10 +108,26 @@ Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceWriter::surfaceWriter() Foam::surfaceWriter::surfaceWriter(const IOstream::streamFormat writeFormat)
:
writeFormat_(writeFormat)
{} {}
Foam::surfaceWriter::surfaceWriter(const dictionary& optDict)
:
writeFormat_(IOstream::ASCII)
{
if (optDict.found("writeFormat"))
{
writeFormat_ = IOstream::formatEnum
(
optDict.lookup("writeFormat")
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceWriter::~surfaceWriter() Foam::surfaceWriter::~surfaceWriter()

View File

@ -54,6 +54,15 @@ namespace Foam
class surfaceWriter class surfaceWriter
{ {
protected:
// Protected Data
//- Write format
IOstream::streamFormat writeFormat_;
public: public:
//- Runtime type information //- Runtime type information
@ -66,8 +75,10 @@ public:
autoPtr, autoPtr,
surfaceWriter, surfaceWriter,
word, word,
(), (
() const IOstream::streamFormat writeFormat
),
(writeFormat)
); );
declareRunTimeSelectionTable declareRunTimeSelectionTable
@ -85,21 +96,28 @@ public:
// Selectors // Selectors
//- Return a reference to the selected surfaceWriter //- Return a reference to the selected surfaceWriter
static autoPtr<surfaceWriter> New(const word& writeType); static autoPtr<surfaceWriter> New
(
const word& writeType,
const IOstream::streamFormat writeFormat
);
//- Return a reference to the selected surfaceWriter //- Return a reference to the selected surfaceWriter
// Select with extra write option // Select with extra write option
static autoPtr<surfaceWriter> New static autoPtr<surfaceWriter> New
( (
const word& writeType, const word& writeType,
const dictionary& writeOptions const dictionary& optDict
); );
// Constructors // Constructors
//- Construct null //- Construct given write format
surfaceWriter(); surfaceWriter(const IOstream::streamFormat writeFormat);
//- Construct with output options
surfaceWriter(const dictionary& optDict);
//- Destructor //- Destructor

View File

@ -153,9 +153,12 @@ void Foam::vtkSurfaceWriter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkSurfaceWriter::vtkSurfaceWriter() Foam::vtkSurfaceWriter::vtkSurfaceWriter
(
const IOstream::streamFormat writeFormat
)
: :
surfaceWriter() surfaceWriter(writeFormat)
{} {}

View File

@ -81,8 +81,8 @@ public:
// Constructors // Constructors
//- Construct null //- Construct given write format
vtkSurfaceWriter(); vtkSurfaceWriter(const IOstream::streamFormat writeFormat);
//- Destructor //- Destructor