Commit faac56c1 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: ensight binary surface output, formatOptions in sampleDict

- For example,
    // optionally define extra controls for the output formats
    formatOptions
    {
        ensight
        {
            format  binary;
        }
    }

These are passed to the writer that support a dictionary of options.
Otherwise the normal null constructor is used.
parent 0be6ba87
......@@ -38,6 +38,16 @@ setFormat raw;
// but without any values!
surfaceFormat vtk;
// optionally define extra controls for the output formats
formatOptions
{
ensight
{
format ascii;
}
}
// interpolationScheme. choice of
// cell : use cell-centre value only; constant over cells (default)
// cellPoint : use cell-centre and vertex values
......
......@@ -220,11 +220,15 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
clearFieldGroups();
dict.lookup("interpolationScheme") >> interpolationScheme_;
word writeType(dict.lookup("surfaceFormat"));
const word writeType(dict.lookup("surfaceFormat"));
// define the surface formatter
formatter_ = surfaceWriter::New(writeType);
// optionally defined extra controls for the output formats
formatter_ = surfaceWriter::New
(
writeType,
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
);
PtrList<sampledSurface> newList
(
......
......@@ -37,6 +37,7 @@ License
namespace Foam
{
makeSurfaceWriterType(ensightSurfaceWriter);
addToRunTimeSelectionTable(surfaceWriter, ensightSurfaceWriter, wordDict);
}
......@@ -120,6 +121,19 @@ Foam::ensightSurfaceWriter::ensightSurfaceWriter()
{}
Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options)
:
surfaceWriter(),
writeFormat_(IOstream::ASCII)
{
// choose ascii or binary format
if (options.found("format"))
{
writeFormat_ = IOstream::formatEnum(options.lookup("format"));
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightSurfaceWriter::~ensightSurfaceWriter()
......
......@@ -84,6 +84,9 @@ public:
//- Construct null
ensightSurfaceWriter();
//- Construct with some output options
ensightSurfaceWriter(const dictionary& options);
//- Destructor
virtual ~ensightSurfaceWriter();
......
......@@ -38,6 +38,7 @@ namespace Foam
{
defineTypeNameAndDebug(surfaceWriter, 0);
defineRunTimeSelectionTable(surfaceWriter, word);
defineRunTimeSelectionTable(surfaceWriter, wordDict);
addNamedToRunTimeSelectionTable
(
surfaceWriter,
......@@ -83,6 +84,23 @@ Foam::surfaceWriter::New(const word& writeType)
}
Foam::autoPtr<Foam::surfaceWriter>
Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
{
// find constructors with dictionary options
wordDictConstructorTable::iterator cstrIter =
wordDictConstructorTablePtr_->find(writeType);
if (cstrIter == wordDictConstructorTablePtr_->end())
{
// revert to versions without options
return Foam::surfaceWriter::New(writeType);
}
return autoPtr<surfaceWriter>(cstrIter()(optDict));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceWriter::surfaceWriter()
......
......@@ -70,12 +70,31 @@ public:
()
);
declareRunTimeSelectionTable
(
autoPtr,
surfaceWriter,
wordDict,
(
const dictionary& optDict
),
(optDict)
);
// Selectors
//- Return a reference to the selected surfaceWriter
static autoPtr<surfaceWriter> New(const word& writeType);
//- Return a reference to the selected surfaceWriter
// Select with extra write option
static autoPtr<surfaceWriter> New
(
const word& writeType,
const dictionary& writeOptions
);
// Constructors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment