From 98c25d163a8cd02362f362d2b4f4cb9ee86dbf65 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Thu, 11 Nov 2021 13:44:49 +0000 Subject: [PATCH] ENH: sampledSets - enable writer construction from dictionary Users can now include additional controls via a new formatOptions dictionary. --- .../sampledSetWriters/csv/csvSetWriter.C | 8 ++++ .../sampledSetWriters/csv/csvSetWriter.H | 6 ++- .../ensight/ensightSetWriter.C | 7 ++++ .../ensight/ensightSetWriter.H | 6 ++- .../gnuplot/gnuplotSetWriter.C | 9 ++++- .../gnuplot/gnuplotSetWriter.H | 7 +++- .../sampledSetWriters/jplot/jplotSetWriter.C | 9 ++++- .../sampledSetWriters/jplot/jplotSetWriter.H | 6 ++- .../nastran/nastranSetWriter.C | 9 ++++- .../nastran/nastranSetWriter.H | 18 ++++----- .../sampledSetWriters/raw/rawSetWriter.C | 8 ++++ .../sampledSetWriters/raw/rawSetWriter.H | 7 +++- .../sampledSetWriters/vtk/vtkSetWriter.C | 9 ++++- .../sampledSetWriters/vtk/vtkSetWriter.H | 7 +++- src/fileFormats/sampledSetWriters/writer.C | 29 +++++++++++++-- src/fileFormats/sampledSetWriters/writer.H | 29 +++++++++++++-- src/fileFormats/sampledSetWriters/writers.C | 4 +- src/fileFormats/sampledSetWriters/writers.H | 6 ++- .../xmgrace/xmgraceSetWriter.C | 8 ++++ .../xmgrace/xmgraceSetWriter.H | 7 +++- .../sampledSet/sampledSets/sampledSets.C | 10 +++-- .../sampledSet/sampledSets/sampledSets.H | 37 +++++++------------ .../sampledSets/sampledSetsTemplates.C | 2 +- 23 files changed, 186 insertions(+), 62 deletions(-) diff --git a/src/fileFormats/sampledSetWriters/csv/csvSetWriter.C b/src/fileFormats/sampledSetWriters/csv/csvSetWriter.C index b0a92cd375..c24ebead34 100644 --- a/src/fileFormats/sampledSetWriters/csv/csvSetWriter.C +++ b/src/fileFormats/sampledSetWriters/csv/csvSetWriter.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +40,13 @@ Foam::csvSetWriter::csvSetWriter() {} +template +Foam::csvSetWriter::csvSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/csv/csvSetWriter.H b/src/fileFormats/sampledSetWriters/csv/csvSetWriter.H index e2f464affb..81026527ae 100644 --- a/src/fileFormats/sampledSetWriters/csv/csvSetWriter.H +++ b/src/fileFormats/sampledSetWriters/csv/csvSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -74,9 +75,12 @@ public: // Constructors - //- Construct null + //- Default construct csvSetWriter(); + //- Construct with dictionary + explicit csvSetWriter(const dictionary& dict); + //- Destructor virtual ~csvSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C index 17754ff2dc..44c896bb19 100644 --- a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C +++ b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C @@ -42,6 +42,13 @@ Foam::ensightSetWriter::ensightSetWriter() {} +template +Foam::ensightSetWriter::ensightSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.H b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.H index 2629b3c68b..c0ebfd1e71 100644 --- a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.H +++ b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,9 +62,12 @@ public: // Constructors - //- Construct null + //- Default construct ensightSetWriter(); + //- Construct with dictionary + explicit ensightSetWriter(const dictionary& dict); + //- Destructor virtual ~ensightSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C index df3fafc5e3..771dddfd14 100644 --- a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C +++ b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,6 +42,13 @@ Foam::gnuplotSetWriter::gnuplotSetWriter() {} +template +Foam::gnuplotSetWriter::gnuplotSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.H b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.H index 08c237d091..da88940954 100644 --- a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.H +++ b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,7 +53,6 @@ class gnuplotSetWriter : public writer { - public: //- Runtime type information @@ -61,9 +61,12 @@ public: // Constructors - //- Construct null + //- Default construct gnuplotSetWriter(); + //- Construct with dictionary + explicit gnuplotSetWriter(const dictionary& dict); + //- Destructor virtual ~gnuplotSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.C b/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.C index c3c4eb3190..dcb841af45 100644 --- a/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.C +++ b/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +32,6 @@ License #include "fileName.H" #include "OFstream.H" - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -53,6 +53,13 @@ Foam::jplotSetWriter::jplotSetWriter() {} +template +Foam::jplotSetWriter::jplotSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.H b/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.H index 39f19ccf32..26c0c8f503 100644 --- a/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.H +++ b/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,9 +66,12 @@ public: // Constructors - //- Construct null + //- Default construct jplotSetWriter(); + //- Construct with dictionary + explicit jplotSetWriter(const dictionary& dict); + //- Destructor virtual ~jplotSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C b/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C index 218384cb59..5747dda885 100644 --- a/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C +++ b/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +39,13 @@ Foam::nastranSetWriter::nastranSetWriter() {} +template +Foam::nastranSetWriter::nastranSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H b/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H index 34ec75ffce..6cdb208c25 100644 --- a/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H +++ b/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,13 +56,6 @@ class nastranSetWriter : public writer { -public: - - //- File field formats - using fieldFormat = Foam::fileFormats::NASCore::fieldFormat; - -private: - // Private Member Functions //- Write the formatted keyword to the output stream @@ -75,15 +68,22 @@ private: public: + //- File field formats + using fieldFormat = Foam::fileFormats::NASCore::fieldFormat; + + //- Runtime type information TypeName("nastran"); // Constructors - //- Construct null + //- Default construct nastranSetWriter(); + //- Construct with dictionary + explicit nastranSetWriter(const dictionary& dict); + //- Destructor virtual ~nastranSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/raw/rawSetWriter.C b/src/fileFormats/sampledSetWriters/raw/rawSetWriter.C index dc6a120606..6026e6508a 100644 --- a/src/fileFormats/sampledSetWriters/raw/rawSetWriter.C +++ b/src/fileFormats/sampledSetWriters/raw/rawSetWriter.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +40,13 @@ Foam::rawSetWriter::rawSetWriter() {} +template +Foam::rawSetWriter::rawSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/raw/rawSetWriter.H b/src/fileFormats/sampledSetWriters/raw/rawSetWriter.H index 817c80ce1d..87071a9285 100644 --- a/src/fileFormats/sampledSetWriters/raw/rawSetWriter.H +++ b/src/fileFormats/sampledSetWriters/raw/rawSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,7 +53,6 @@ class rawSetWriter : public writer { - public: //- Runtime type information @@ -61,9 +61,12 @@ public: // Constructors - //- Construct null + //- Default construct rawSetWriter(); + //- Construct with dictionary + explicit rawSetWriter(const dictionary& dict); + //- Destructor virtual ~rawSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C index ab0dde0a65..e6f806d4a4 100644 --- a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C +++ b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,6 +42,13 @@ Foam::vtkSetWriter::vtkSetWriter() {} +template +Foam::vtkSetWriter::vtkSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.H b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.H index da000a0acc..7e2e9493a4 100644 --- a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.H +++ b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +56,6 @@ class vtkSetWriter : public writer { - public: //- Runtime type information @@ -64,9 +64,12 @@ public: // Constructors - //- Construct null + //- Default construct vtkSetWriter(); + //- Construct with dictionary + explicit vtkSetWriter(const dictionary& dict); + //- Destructor virtual ~vtkSetWriter() = default; diff --git a/src/fileFormats/sampledSetWriters/writer.C b/src/fileFormats/sampledSetWriters/writer.C index ea14233287..09a6b88459 100644 --- a/src/fileFormats/sampledSetWriters/writer.C +++ b/src/fileFormats/sampledSetWriters/writer.C @@ -31,7 +31,7 @@ License #include "OFstream.H" #include "OSspecific.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // template Foam::autoPtr> Foam::writer::New @@ -55,6 +55,29 @@ Foam::autoPtr> Foam::writer::New } +template +Foam::autoPtr> Foam::writer::New +( + const word& writeType, + const dictionary& formatOptions +) +{ + auto ctorPtr = dictConstructorTable(writeType); + + if (!ctorPtr) + { + FatalErrorInLookup + ( + "writer", + writeType, + *dictConstructorTablePtr_ + ) << exit(FatalError); + } + + return autoPtr>(ctorPtr(formatOptions)); +} + + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template @@ -143,10 +166,8 @@ Foam::writer::writer() {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - template -Foam::writer::~writer() +Foam::writer::writer(const dictionary& dict) {} diff --git a/src/fileFormats/sampledSetWriters/writer.H b/src/fileFormats/sampledSetWriters/writer.H index da591db0f3..47438ff221 100644 --- a/src/fileFormats/sampledSetWriters/writer.H +++ b/src/fileFormats/sampledSetWriters/writer.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -70,7 +71,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class coordSet; /*---------------------------------------------------------------------------*\ @@ -80,7 +81,6 @@ class coordSet; template class writer { - protected: //- Generates filename from coordSet and sampled fields @@ -123,21 +123,42 @@ public: () ); + declareRunTimeSelectionTable + ( + autoPtr, + writer, + dict, + ( + const dictionary& formatOptions + ), + (formatOptions) + ); + // Selectors //- Return a reference to the selected writer static autoPtr New(const word& writeFormat); + //- Return a reference to the selected writer + static autoPtr New + ( + const word& writeFormat, + const dictionary& formatOptions + ); + // Constructors - //- Construct null + //- Default construct writer(); + //- Construct with dictionary + explicit writer(const dictionary& dict); + //- Destructor - virtual ~writer() = 0; + virtual ~writer() = default; // Member Functions diff --git a/src/fileFormats/sampledSetWriters/writers.C b/src/fileFormats/sampledSetWriters/writers.C index a730aae834..c94fc450ce 100644 --- a/src/fileFormats/sampledSetWriters/writers.C +++ b/src/fileFormats/sampledSetWriters/writers.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +37,8 @@ namespace Foam #define defineSetWriterType(dataType) \ defineNamedTemplateTypeNameAndDebug(writer, 0); \ - defineTemplatedRunTimeSelectionTable(writer, word, dataType); + defineTemplatedRunTimeSelectionTable(writer, word, dataType); \ + defineTemplatedRunTimeSelectionTable(writer, dict, dataType); defineSetWriterType(scalar); defineSetWriterType(vector); diff --git a/src/fileFormats/sampledSetWriters/writers.H b/src/fileFormats/sampledSetWriters/writers.H index f931e523cb..c1e7f75a76 100644 --- a/src/fileFormats/sampledSetWriters/writers.H +++ b/src/fileFormats/sampledSetWriters/writers.H @@ -61,7 +61,11 @@ SourceFiles addTemplatedToRunTimeSelectionTable \ ( \ writer, typeWriter, dataType, word \ - ) + ); \ + addTemplatedToRunTimeSelectionTable \ + ( \ + writer, typeWriter, dataType, dict \ + ); // Define type info for scalar, vector etc. instantiations diff --git a/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.C b/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.C index 74b6d19a85..6faca89cff 100644 --- a/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.C +++ b/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,6 +41,13 @@ Foam::xmgraceSetWriter::xmgraceSetWriter() {} +template +Foam::xmgraceSetWriter::xmgraceSetWriter(const dictionary& dict) +: + writer(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.H b/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.H index 31ec5e41e3..d3f064106d 100644 --- a/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.H +++ b/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,7 +53,6 @@ class xmgraceSetWriter : public writer { - public: //- Runtime type information @@ -61,9 +61,12 @@ public: // Constructors - //- Construct null + //- Default construct xmgraceSetWriter(); + //- Construct with dictionary + explicit xmgraceSetWriter(const dictionary& dict); + //- Destructor virtual ~xmgraceSetWriter() = default; diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 2420bc7ac5..06601d251e 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -97,7 +97,8 @@ Foam::sampledSets::sampledSets outputPath_(fileName::null), searchEngine_(mesh_), interpolationScheme_(word::null), - writeFormat_(word::null) + writeFormat_(word::null), + writeFormatOptions_(dict.subOrEmptyDict("formatOptions")) { outputPath_ = ( @@ -106,7 +107,7 @@ Foam::sampledSets::sampledSets if (mesh_.name() != polyMesh::defaultRegion) { - outputPath_ = outputPath_/mesh_.name(); + outputPath_ /= mesh_.name(); } outputPath_.clean(); // Remove unneeded ".." @@ -130,7 +131,8 @@ Foam::sampledSets::sampledSets outputPath_(fileName::null), searchEngine_(mesh_), interpolationScheme_(word::null), - writeFormat_(word::null) + writeFormat_(word::null), + writeFormatOptions_(dict.subOrEmptyDict("formatOptions")) { outputPath_ = ( @@ -139,7 +141,7 @@ Foam::sampledSets::sampledSets if (mesh_.name() != polyMesh::defaultRegion) { - outputPath_ = outputPath_/mesh_.name(); + outputPath_ /= mesh_.name(); } outputPath_.clean(); // Remove unneeded ".." diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.H b/src/sampling/sampledSet/sampledSets/sampledSets.H index 0f38753b7d..d148f48514 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.H +++ b/src/sampling/sampledSet/sampledSets/sampledSets.H @@ -53,7 +53,7 @@ SourceFiles namespace Foam { -// Forward declarations +// Forward Declarations class Time; class objectRegistry; class dictionary; @@ -68,7 +68,7 @@ class sampledSets public functionObjects::regionFunctionObject, public PtrList { - // Private classes + // Private Classes //- Class used for grouping field types template @@ -82,18 +82,7 @@ class sampledSets autoPtr> formatter; //- Construct null - fieldGroup() - : - DynamicList(0), - formatter(nullptr) - {} - - //- Construct for a particular format - fieldGroup(const word& writeFormat) - : - DynamicList(0), - formatter(writer::New(writeFormat)) - {} + fieldGroup() = default; //- Reset format and field list void clear() @@ -102,10 +91,9 @@ class sampledSets formatter.clear(); } - //- Assign a new formatter - void operator=(const word& writeFormat) + void setFormatter(const word& writeFormat, const dictionary& dict) { - formatter = writer::New(writeFormat); + formatter = writer::New(writeFormat, dict); } }; @@ -151,13 +139,13 @@ class sampledSets }; - // Static data members + // Static Data Members //- Output verbosity static bool verbose_; - // Private data + // Private Data //- Const reference to fvMesh const fvMesh& mesh_; @@ -175,7 +163,7 @@ class sampledSets meshSearch searchEngine_; - // Read from dictonary + // Read from dictionary //- Names of fields to sample wordRes fieldSelection_; @@ -186,8 +174,11 @@ class sampledSets //- Output format to use word writeFormat_; + //- Dictionary containing writer options + dictionary writeFormatOptions_; - // Categorized scalar/vector/tensor fields + + // Categorized scalar/vector/tensor fields fieldGroup scalarFields_; fieldGroup vectorFields_; @@ -196,7 +187,7 @@ class sampledSets fieldGroup tensorFields_; - // Merging structures + // Merging structures PtrList masterSampledSets_; labelListList indexSets_; @@ -211,7 +202,7 @@ class sampledSets label classifyFields(); //- Combine points from all processors. Sort by curveDist and produce - // index list. Valid result only on master processor. + //- index list. Valid result only on master processor. void combineSampledSets ( PtrList& masterSampledSets, diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 82dad524a2..c9441dd28c 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -231,7 +231,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup& fields) // Create or use existing writer if (!fields.formatter) { - fields = writeFormat_; + fields.setFormatter(writeFormat_, writeFormatOptions_); } // Storage for interpolated values