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 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -111,10 +111,11 @@ void Foam::MeshedSurface<Face>::write
(
const fileName& name,
const MeshedSurface<Face>& surf,
IOstreamOption streamOpt,
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
const fileName& name,
const word& ext,
const MeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options
)
{
......@@ -141,7 +143,7 @@ void Foam::MeshedSurface<Face>::write
if (delegate.found(ext))
{
MeshedSurfaceProxy<Face>(surf).write(name, ext, options);
MeshedSurfaceProxy<Face>(surf).write(name, ext, streamOpt, options);
}
else
{
......@@ -154,7 +156,7 @@ void Foam::MeshedSurface<Face>::write
}
else
{
mfIter()(name, surf, options);
mfIter()(name, surf, streamOpt, options);
}
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -67,7 +67,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class Time;
class surfMesh;
......@@ -104,7 +104,7 @@ class MeshedSurface
private:
// Private typedefs for convenience
// Private Typedefs (convenience)
typedef PrimitivePatch
<
......@@ -119,7 +119,7 @@ private:
typedef MeshedSurfaceProxy<Face> ProxyType;
// Private Member Data
// Private Data
//- Zone information
// (face ordering nFaces/startFace only used during reading/writing)
......@@ -137,7 +137,7 @@ private:
protected:
// Protected Member functions
// Protected Member Functions
//- Transfer points/zones from 'face' to other other shapes.
// Eg, transcribe face to triFace, or face -> labelledTri, including
......@@ -180,16 +180,17 @@ protected:
public:
// Public typedefs
// Public Typedefs
//- Face type used
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?
static bool canRead(const fileName& name, bool verbose=false);
......@@ -209,7 +210,7 @@ public:
// Constructors
//- Construct null, an empty surface
//- Default construct, an empty surface
MeshedSurface();
//- Copy construct
......@@ -326,9 +327,10 @@ public:
(
const fileName& name,
const MeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options
),
(name, surf, options)
(name, surf, streamOpt, options)
);
//- Write to file, selecting writer based on its extension
......@@ -336,6 +338,7 @@ public:
(
const fileName& name,
const MeshedSurface<Face>& surf,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
);
......@@ -345,6 +348,7 @@ public:
const fileName& name,
const word& ext,
const MeshedSurface<Face>& surf,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
);
......@@ -526,10 +530,11 @@ public:
virtual void write
(
const fileName& name,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
) const
{
write(name, *this, options);
write(name, *this, streamOpt, options);
}
//- Write to database
......@@ -540,7 +545,7 @@ public:
) const;
// Member operators
// Member Operators
//- Copy assignment
void operator=(const MeshedSurface<Face>& surf);
......@@ -570,7 +575,6 @@ public:
Ostream& os,
const MeshedSurface<Face>& surf
);
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -62,10 +62,11 @@ void Foam::MeshedSurfaceProxy<Face>::write
(
const fileName& name,
const MeshedSurfaceProxy& surf,
IOstreamOption streamOpt,
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
const fileName& name,
const word& ext,
const MeshedSurfaceProxy& surf,
IOstreamOption streamOpt,
const dictionary& options
)
{
......@@ -94,7 +96,7 @@ void Foam::MeshedSurfaceProxy<Face>::write
<< exit(FatalError);
}
mfIter()(name, surf, options);
mfIter()(name, surf, streamOpt, options);
}
......@@ -210,7 +212,6 @@ void Foam::MeshedSurfaceProxy<Face>::write
io.writeEndDivider(os);
}
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -54,7 +54,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
template<class Face> class MeshedSurface;
......@@ -67,7 +67,7 @@ class MeshedSurfaceProxy
:
public fileFormats::surfaceFormatsCore
{
// Private Member Data
// Private Data
const pointField& points_;
......@@ -79,16 +79,17 @@ class MeshedSurfaceProxy
public:
// Public typedefs
// Public Typedefs
//- Face type used
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
static wordHashSet writeTypes();
......@@ -124,9 +125,10 @@ public:
(
const fileName& name,
const MeshedSurfaceProxy<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options
),
(name, surf, options)
(name, surf, streamOpt, options)
);
//- Write to file, select based on its extension
......@@ -134,7 +136,8 @@ public:
(
const fileName& name,
const MeshedSurfaceProxy& surf,
const dictionary& options
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
);
//- Write to file, selected based on given extension
......@@ -143,7 +146,8 @@ public:
const fileName& name,
const word& ext,
const MeshedSurfaceProxy& surf,
const dictionary& options
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
);
......@@ -199,10 +203,11 @@ public:
virtual void write
(
const fileName& name,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
) const
{
write(name, *this, options);
write(name, *this, streamOpt, options);
}
//- Generic write routine. Chooses writer based on extension.
......@@ -210,10 +215,11 @@ public:
(
const fileName& name,
const word& ext,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
) const
{
write(name, ext, *this, options);
write(name, ext, *this, streamOpt, options);
}
//- Write to database
......
......@@ -106,10 +106,11 @@ void Foam::UnsortedMeshedSurface<Face>::write
(
const fileName& name,
const UnsortedMeshedSurface<Face>& surf,
IOstreamOption streamOpt,
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
const fileName& name,
const word& ext,
const UnsortedMeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options
)
{
......@@ -136,7 +138,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
if (delegate.found(ext))
{
MeshedSurfaceProxy<Face>(surf).write(name, ext, options);
MeshedSurfaceProxy<Face>(surf).write(name, ext, streamOpt, options);
}
else
{
......@@ -149,7 +151,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
}
else
{
mfIter()(name, surf, options);
mfIter()(name, surf, streamOpt, options);
}
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -62,8 +62,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
//
// Forward Declarations
class Time;
class Istream;
class Ostream;
......@@ -95,14 +94,14 @@ class UnsortedMeshedSurface
private:
// Private typedefs for convenience
// Private Typedefs (convenience)
typedef MeshedSurface<Face> ParentType;
typedef MeshedSurface<Face> FriendType;
typedef MeshedSurfaceProxy<Face> ProxyType;
// Private Member Data
// Private Data
//- The zone Id associated with each face
labelList zoneIds_;
......@@ -128,7 +127,7 @@ private:
protected:
// Protected Member functions
// Protected Member Functions
//- Return non-const access to the zone Ids
labelList& storedZoneIds()
......@@ -148,16 +147,17 @@ protected:
public:
// Public typedefs
// Public Typedefs
//- Face type used
typedef Face FaceType;
//- Runtime type information
TypeName("UnsortedMeshedSurface");
//- Declare type-name, virtual type (with debug switch)
TypeName("UnsortedMeshedSurface");
// Static
// Static Functions
//- Can we read this file format type?
static bool canReadType(const word& ext, bool verbose=false);
......@@ -177,10 +177,10 @@ public:
// Constructors
//- Construct null
//- Default construct
UnsortedMeshedSurface();
//- Construct as copy
//- Copy construct
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>& surf);
//- Construct from a MeshedSurface
......@@ -261,9 +261,10 @@ public:
(
const fileName& name,
const UnsortedMeshedSurface<Face>& surf,
IOstreamOption streamOpt,
const dictionary& options
),
(name, surf, options)
(name, surf, streamOpt, options)
);
//- Write to file, select based on its extension
......@@ -271,6 +272,7 @@ public:
(
const fileName& name,
const UnsortedMeshedSurface<Face>& surf,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
);
......@@ -280,7 +282,8 @@ public:
const fileName& name,
const word& ext,
const UnsortedMeshedSurface<Face>& surf,
const dictionary& options
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
);
......@@ -382,10 +385,11 @@ public:
virtual void write
(
const fileName& name,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
) const
{
write(name, *this, options);
write(name, *this, streamOpt, options);
}
//- Write to database
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -44,6 +44,7 @@ namespace Foam
Foam::word Foam::surfMesh::meshSubDir = "surfMesh";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// void Foam::surfMesh::oneZone()
......@@ -566,10 +567,11 @@ void Foam::surfMesh::removeFiles() const
void Foam::surfMesh::write
(
const fileName& name,
IOstreamOption streamOpt,
const dictionary& options
) const
{
write(name, name.ext(), options);
write(name, name.ext(), streamOpt, options);
}
......@@ -577,6 +579,7 @@ void Foam::surfMesh::write
(
const fileName& name,
const word& ext,
IOstreamOption streamOpt,
const dictionary& options
) const
{
......@@ -585,7 +588,7 @@ void Foam::surfMesh::write
this->points(),
this->faces(),
this->surfZones()
).write(name, ext, options);
).write(name, ext, streamOpt, options);
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -53,7 +53,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class dimensionSet;
class meshedSurf;
template<class Face> class MeshedSurface;
......@@ -100,7 +100,7 @@ private:
MeshReference;
// Demand driven private data
// Private Data
//- The surface zones
surfZoneIOList surfZones_;
......@@ -149,7 +149,7 @@ protected:
public:
// Public typedefs
// Public Typedefs
//- Typedef required for GeoMesh
typedef surfMesh Mesh;
......@@ -158,7 +158,7 @@ public:
typedef bool BoundaryMesh;
//- Runtime type information
//- Declare type-name, virtual type (with debug switch)
TypeName("surfMesh");
//- Return the mesh sub-directory name (normally "surfMesh")
......@@ -361,6 +361,7 @@ public:
void write
(
const fileName& name,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
) const;
......@@ -370,11 +371,12 @@ public:
(
const fileName& name,
const word& ext,
IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null
) const;
// Storage management
// Storage Management
//- Release the geometry and return as a MeshedSurface<face>.
autoPtr<MeshedSurface<face>> releaseGeom();
......@@ -399,9 +401,9 @@ public:
//- Remove all files from mesh instance()
void removeFiles() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -309,9 +309,13 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
(
const fileName& filename,
const MeshedSurfaceProxy<Face>& surf,
IOstreamOption streamOpt,
const dictionary&
)
{
// ASCII only, allow output compression
streamOpt.format(IOstream::ASCII);
const pointField& pointLst = surf.points();
const UList<Face>& faceLst = surf.surfFaces();