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.
This commit is contained in:
Mark Olesen
2011-01-28 19:20:22 +01:00
parent 0be6ba87fc
commit faac56c1de
6 changed files with 71 additions and 3 deletions

View File

@ -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

View File

@ -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
(

View File

@ -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()

View File

@ -84,6 +84,9 @@ public:
//- Construct null
ensightSurfaceWriter();
//- Construct with some output options
ensightSurfaceWriter(const dictionary& options);
//- Destructor
virtual ~ensightSurfaceWriter();

View File

@ -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()

View File

@ -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