Commit 6b3b6bb9 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add stream format options for surface writers (#1595)

- additional boundaryData options (header, binary, compression)

- remove vtkSurfaceWriter "writePrecision" keyword (1806 compatibilty)
  and use "precision" in format option sub-dictionary.
parent 514751dc
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -111,10 +111,11 @@ void Foam::MeshedSurface<Face>::write ...@@ -111,10 +111,11 @@ void Foam::MeshedSurface<Face>::write
( (
const fileName& name, const fileName& name,
const MeshedSurface<Face>& surf, const MeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) )
{ {
write(name, name.ext(), surf, options); write(name, name.ext(), surf, streamOpt, options);
} }
...@@ -124,6 +125,7 @@ void Foam::MeshedSurface<Face>::write ...@@ -124,6 +125,7 @@ void Foam::MeshedSurface<Face>::write
const fileName& name, const fileName& name,
const word& ext, const word& ext,
const MeshedSurface<Face>& surf, const MeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) )
{ {
...@@ -141,7 +143,7 @@ void Foam::MeshedSurface<Face>::write ...@@ -141,7 +143,7 @@ void Foam::MeshedSurface<Face>::write
if (delegate.found(ext)) if (delegate.found(ext))
{ {
MeshedSurfaceProxy<Face>(surf).write(name, ext, options); MeshedSurfaceProxy<Face>(surf).write(name, ext, streamOpt, options);
} }
else else
{ {
...@@ -154,7 +156,7 @@ void Foam::MeshedSurface<Face>::write ...@@ -154,7 +156,7 @@ void Foam::MeshedSurface<Face>::write
} }
else else
{ {
mfIter()(name, surf, options); mfIter()(name, surf, streamOpt, options);
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -67,7 +67,7 @@ SourceFiles ...@@ -67,7 +67,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations // Forward Declarations
class Time; class Time;
class surfMesh; class surfMesh;
...@@ -104,7 +104,7 @@ class MeshedSurface ...@@ -104,7 +104,7 @@ class MeshedSurface
private: private:
// Private typedefs for convenience // Private Typedefs (convenience)
typedef PrimitivePatch typedef PrimitivePatch
< <
...@@ -119,7 +119,7 @@ private: ...@@ -119,7 +119,7 @@ private:
typedef MeshedSurfaceProxy<Face> ProxyType; typedef MeshedSurfaceProxy<Face> ProxyType;
// Private Member Data // Private Data
//- Zone information //- Zone information
// (face ordering nFaces/startFace only used during reading/writing) // (face ordering nFaces/startFace only used during reading/writing)
...@@ -137,7 +137,7 @@ private: ...@@ -137,7 +137,7 @@ private:
protected: protected:
// Protected Member functions // Protected Member Functions
//- Transfer points/zones from 'face' to other other shapes. //- Transfer points/zones from 'face' to other other shapes.
// Eg, transcribe face to triFace, or face -> labelledTri, including // Eg, transcribe face to triFace, or face -> labelledTri, including
...@@ -180,16 +180,17 @@ protected: ...@@ -180,16 +180,17 @@ protected:
public: public:
// Public typedefs // Public Typedefs
//- Face type used //- Face type used
typedef Face FaceType; typedef Face FaceType;
//- Runtime type information
ClassName("MeshedSurface");
//- Declare type-name (with debug switch)
ClassName("MeshedSurface");
// Static
// Static Functions
//- Can we read this file format? //- Can we read this file format?
static bool canRead(const fileName& name, bool verbose=false); static bool canRead(const fileName& name, bool verbose=false);
...@@ -209,7 +210,7 @@ public: ...@@ -209,7 +210,7 @@ public:
// Constructors // Constructors
//- Construct null, an empty surface //- Default construct, an empty surface
MeshedSurface(); MeshedSurface();
//- Copy construct //- Copy construct
...@@ -326,9 +327,10 @@ public: ...@@ -326,9 +327,10 @@ public:
( (
const fileName& name, const fileName& name,
const MeshedSurface<Face>& surf, const MeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
), ),
(name, surf, options) (name, surf, streamOpt, options)
); );
//- Write to file, selecting writer based on its extension //- Write to file, selecting writer based on its extension
...@@ -336,6 +338,7 @@ public: ...@@ -336,6 +338,7 @@ public:
( (
const fileName& name, const fileName& name,
const MeshedSurface<Face>& surf, const MeshedSurface<Face>& surf,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
); );
...@@ -345,6 +348,7 @@ public: ...@@ -345,6 +348,7 @@ public:
const fileName& name, const fileName& name,
const word& ext, const word& ext,
const MeshedSurface<Face>& surf, const MeshedSurface<Face>& surf,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
); );
...@@ -526,10 +530,11 @@ public: ...@@ -526,10 +530,11 @@ public:
virtual void write virtual void write
( (
const fileName& name, const fileName& name,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
) const ) const
{ {
write(name, *this, options); write(name, *this, streamOpt, options);
} }
//- Write to database //- Write to database
...@@ -540,7 +545,7 @@ public: ...@@ -540,7 +545,7 @@ public:
) const; ) const;
// Member operators // Member Operators
//- Copy assignment //- Copy assignment
void operator=(const MeshedSurface<Face>& surf); void operator=(const MeshedSurface<Face>& surf);
...@@ -570,7 +575,6 @@ public: ...@@ -570,7 +575,6 @@ public:
Ostream& os, Ostream& os,
const MeshedSurface<Face>& surf const MeshedSurface<Face>& surf
); );
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -62,10 +62,11 @@ void Foam::MeshedSurfaceProxy<Face>::write ...@@ -62,10 +62,11 @@ void Foam::MeshedSurfaceProxy<Face>::write
( (
const fileName& name, const fileName& name,
const MeshedSurfaceProxy& surf, const MeshedSurfaceProxy& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) )
{ {
write(name, name.ext(), surf, options); write(name, name.ext(), surf, streamOpt, options);
} }
...@@ -75,6 +76,7 @@ void Foam::MeshedSurfaceProxy<Face>::write ...@@ -75,6 +76,7 @@ void Foam::MeshedSurfaceProxy<Face>::write
const fileName& name, const fileName& name,
const word& ext, const word& ext,
const MeshedSurfaceProxy& surf, const MeshedSurfaceProxy& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) )
{ {
...@@ -94,7 +96,7 @@ void Foam::MeshedSurfaceProxy<Face>::write ...@@ -94,7 +96,7 @@ void Foam::MeshedSurfaceProxy<Face>::write
<< exit(FatalError); << exit(FatalError);
} }
mfIter()(name, surf, options); mfIter()(name, surf, streamOpt, options);
} }
...@@ -210,7 +212,6 @@ void Foam::MeshedSurfaceProxy<Face>::write ...@@ -210,7 +212,6 @@ void Foam::MeshedSurfaceProxy<Face>::write
io.writeEndDivider(os); io.writeEndDivider(os);
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -54,7 +54,7 @@ SourceFiles ...@@ -54,7 +54,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations // Forward Declarations
template<class Face> class MeshedSurface; template<class Face> class MeshedSurface;
...@@ -67,7 +67,7 @@ class MeshedSurfaceProxy ...@@ -67,7 +67,7 @@ class MeshedSurfaceProxy
: :
public fileFormats::surfaceFormatsCore public fileFormats::surfaceFormatsCore
{ {
// Private Member Data // Private Data
const pointField& points_; const pointField& points_;
...@@ -79,16 +79,17 @@ class MeshedSurfaceProxy ...@@ -79,16 +79,17 @@ class MeshedSurfaceProxy
public: public:
// Public typedefs // Public Typedefs
//- Face type used //- Face type used
typedef Face FaceType; typedef Face FaceType;
// Static //- Declare type-name (with debug switch)
ClassName("MeshedSurfaceProxy");
//- Runtime type information
ClassName("MeshedSurfaceProxy"); // Static Functions
//- The file format types that can be written via MeshedSurfaceProxy //- The file format types that can be written via MeshedSurfaceProxy
static wordHashSet writeTypes(); static wordHashSet writeTypes();
...@@ -124,9 +125,10 @@ public: ...@@ -124,9 +125,10 @@ public:
( (
const fileName& name, const fileName& name,
const MeshedSurfaceProxy<Face>& surf, const MeshedSurfaceProxy<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
), ),
(name, surf, options) (name, surf, streamOpt, options)
); );
//- Write to file, select based on its extension //- Write to file, select based on its extension
...@@ -134,7 +136,8 @@ public: ...@@ -134,7 +136,8 @@ public:
( (
const fileName& name, const fileName& name,
const MeshedSurfaceProxy& surf, const MeshedSurfaceProxy& surf,
const dictionary& options IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
); );
//- Write to file, selected based on given extension //- Write to file, selected based on given extension
...@@ -143,7 +146,8 @@ public: ...@@ -143,7 +146,8 @@ public:
const fileName& name, const fileName& name,
const word& ext, const word& ext,
const MeshedSurfaceProxy& surf, const MeshedSurfaceProxy& surf,
const dictionary& options IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
); );
...@@ -199,10 +203,11 @@ public: ...@@ -199,10 +203,11 @@ public:
virtual void write virtual void write
( (
const fileName& name, const fileName& name,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
) const ) const
{ {
write(name, *this, options); write(name, *this, streamOpt, options);
} }
//- Generic write routine. Chooses writer based on extension. //- Generic write routine. Chooses writer based on extension.
...@@ -210,10 +215,11 @@ public: ...@@ -210,10 +215,11 @@ public:
( (
const fileName& name, const fileName& name,
const word& ext, const word& ext,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
) const ) const
{ {
write(name, ext, *this, options); write(name, ext, *this, streamOpt, options);
} }
//- Write to database //- Write to database
......
...@@ -106,10 +106,11 @@ void Foam::UnsortedMeshedSurface<Face>::write ...@@ -106,10 +106,11 @@ void Foam::UnsortedMeshedSurface<Face>::write
( (
const fileName& name, const fileName& name,
const UnsortedMeshedSurface<Face>& surf, const UnsortedMeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) )
{ {
write(name, name.ext(), surf, options); write(name, name.ext(), surf, streamOpt, options);
} }
...@@ -119,6 +120,7 @@ void Foam::UnsortedMeshedSurface<Face>::write ...@@ -119,6 +120,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
const fileName& name, const fileName& name,
const word& ext, const word& ext,
const UnsortedMeshedSurface<Face>& surf, const UnsortedMeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) )
{ {
...@@ -136,7 +138,7 @@ void Foam::UnsortedMeshedSurface<Face>::write ...@@ -136,7 +138,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
if (delegate.found(ext)) if (delegate.found(ext))
{ {
MeshedSurfaceProxy<Face>(surf).write(name, ext, options); MeshedSurfaceProxy<Face>(surf).write(name, ext, streamOpt, options);
} }
else else
{ {
...@@ -149,7 +151,7 @@ void Foam::UnsortedMeshedSurface<Face>::write ...@@ -149,7 +151,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
} }
else else
{ {
mfIter()(name, surf, options); mfIter()(name, surf, streamOpt, options);
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -62,8 +62,7 @@ SourceFiles ...@@ -62,8 +62,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations // Forward Declarations
//
class Time; class Time;
class Istream; class Istream;
class Ostream; class Ostream;
...@@ -95,14 +94,14 @@ class UnsortedMeshedSurface ...@@ -95,14 +94,14 @@ class UnsortedMeshedSurface
private: private:
// Private typedefs for convenience // Private Typedefs (convenience)
typedef MeshedSurface<Face> ParentType; typedef MeshedSurface<Face> ParentType;
typedef MeshedSurface<Face> FriendType; typedef MeshedSurface<Face> FriendType;
typedef MeshedSurfaceProxy<Face> ProxyType; typedef MeshedSurfaceProxy<Face> ProxyType;