diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index cd0ae63fe4..c34ce71daf 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -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 diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index a4c3413214..581b7e206b 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -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 newList ( diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C index 135d566db0..d83ec611a1 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C @@ -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() diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H index 891947ffb4..628c178d4e 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H @@ -84,6 +84,9 @@ public: //- Construct null ensightSurfaceWriter(); + //- Construct with some output options + ensightSurfaceWriter(const dictionary& options); + //- Destructor virtual ~ensightSurfaceWriter(); diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.C b/src/sampling/sampledSurface/writers/surfaceWriter.C index 0f52c6f4aa..f297e0934f 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.C +++ b/src/sampling/sampledSurface/writers/surfaceWriter.C @@ -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::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(cstrIter()(optDict)); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::surfaceWriter::surfaceWriter() diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.H b/src/sampling/sampledSurface/writers/surfaceWriter.H index 8e24418d39..be26517849 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.H +++ b/src/sampling/sampledSurface/writers/surfaceWriter.H @@ -70,12 +70,31 @@ public: () ); + declareRunTimeSelectionTable + ( + autoPtr, + surfaceWriter, + wordDict, + ( + const dictionary& optDict + ), + (optDict) + ); + // Selectors //- Return a reference to the selected surfaceWriter static autoPtr New(const word& writeType); + //- Return a reference to the selected surfaceWriter + // Select with extra write option + static autoPtr New + ( + const word& writeType, + const dictionary& writeOptions + ); + // Constructors