diff --git a/src/fileFormats/sampledSetWriters/csv/csvSetWriter.C b/src/fileFormats/sampledSetWriters/csv/csvSetWriter.C index b0a92cd37595e93805f7415821c0096bd32e95a8..c24ebead3453f07521e1a4e33e1641b480cdf30b 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<Type>::csvSetWriter() {} +template<class Type> +Foam::csvSetWriter<Type>::csvSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/csv/csvSetWriter.H b/src/fileFormats/sampledSetWriters/csv/csvSetWriter.H index e2f464affb177c415b90fecac3cb9682706194fd..81026527ae5b0545debab26beff02b903fc4cc72 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 17754ff2dc3682e933599e22ac4a4452029223a8..44c896bb19413c3665f8821d2d5b98be83a91991 100644 --- a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C +++ b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C @@ -42,6 +42,13 @@ Foam::ensightSetWriter<Type>::ensightSetWriter() {} +template<class Type> +Foam::ensightSetWriter<Type>::ensightSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.H b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.H index 2629b3c68b41b76fb8956c7f15ea2a885ec0f0d6..c0ebfd1e7173622199122bf4b3f3fe1e9fc6e8ee 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 df3fafc5e3edd79db6cfcb281e037fbba612875e..771dddfd1487af0fa6aadb69733e62aefe3648d2 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<Type>::gnuplotSetWriter() {} +template<class Type> +Foam::gnuplotSetWriter<Type>::gnuplotSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.H b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.H index 08c237d091264742081160a69d82c299d2f62f48..da88940954003e554c774b91f68f5b8d794f1c4e 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<Type> { - 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 c3c4eb319095be5f132668e5fea5babbcda16103..dcb841af45c3f995660ca0cf10fae8bd6835dd74 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<class Type> @@ -53,6 +53,13 @@ Foam::jplotSetWriter<Type>::jplotSetWriter() {} +template<class Type> +Foam::jplotSetWriter<Type>::jplotSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.H b/src/fileFormats/sampledSetWriters/jplot/jplotSetWriter.H index 39f19ccf3221110efa13555a0182a13f32e30dba..26c0c8f5036141e1e7c458f3e186bd4e5f82c548 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 218384cb5905f805a7896260b040bc14c18095df..5747dda885328d326bac54d0d514fa19a2968edc 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<Type>::nastranSetWriter() {} +template<class Type> +Foam::nastranSetWriter<Type>::nastranSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H b/src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H index 34ec75ffce180a407670ad56f1a0f8be6243b54d..6cdb208c256f927d7e1588316c440dc6b46c594a 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<Type> { -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 dc6a120606f4442735c0e0b69a8242eadf1bd657..6026e6508aec3b4b57e0b2b2cc2f294bc7ece009 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<Type>::rawSetWriter() {} +template<class Type> +Foam::rawSetWriter<Type>::rawSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/raw/rawSetWriter.H b/src/fileFormats/sampledSetWriters/raw/rawSetWriter.H index 817c80ce1de4baf17d12808ab4c9e17084bf627b..87071a9285c9f45e5ec0ca00b6222b1464937304 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<Type> { - 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 ab0dde0a6580bd6a0666ea376e152f9e0d778981..e6f806d4a457237ff9513aad54afe3ac44e8ba70 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<Type>::vtkSetWriter() {} +template<class Type> +Foam::vtkSetWriter<Type>::vtkSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.H b/src/fileFormats/sampledSetWriters/vtk/vtkSetWriter.H index da000a0acc57b468f510589bffe3293c6ce21ef3..7e2e9493a4e25650b648f0ac905e24bc31b0ef13 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<Type> { - 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 ea1423328763c6630a260d8a7cf70777f7ae6988..09a6b884594dedaf4e7c134e94a1e05c06eaada6 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<class Type> Foam::autoPtr<Foam::writer<Type>> Foam::writer<Type>::New @@ -55,6 +55,29 @@ Foam::autoPtr<Foam::writer<Type>> Foam::writer<Type>::New } +template<class Type> +Foam::autoPtr<Foam::writer<Type>> Foam::writer<Type>::New +( + const word& writeType, + const dictionary& formatOptions +) +{ + auto ctorPtr = dictConstructorTable(writeType); + + if (!ctorPtr) + { + FatalErrorInLookup + ( + "writer", + writeType, + *dictConstructorTablePtr_ + ) << exit(FatalError); + } + + return autoPtr<writer<Type>>(ctorPtr(formatOptions)); +} + + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template<class Type> @@ -143,10 +166,8 @@ Foam::writer<Type>::writer() {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - template<class Type> -Foam::writer<Type>::~writer() +Foam::writer<Type>::writer(const dictionary& dict) {} diff --git a/src/fileFormats/sampledSetWriters/writer.H b/src/fileFormats/sampledSetWriters/writer.H index da591db0f3093223814562c3c68ebec975d84e1e..47438ff2215ba08074e351aafcc0ae6f1419465a 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 Type> 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<writer> New(const word& writeFormat); + //- Return a reference to the selected writer + static autoPtr<writer> 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 a730aae834347ffc0798174358c46affc35d0920..c94fc450cef854936411647d8d61daafcbb78e1b 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<dataType >, 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 f931e523cbbc78397af5adcfe615ca71bb812a71..c1e7f75a7644e5976cc42edea9a63d6d76d1227d 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 74b6d19a85f0774dddabc5374fdf922f5ce563cf..6faca89cffc48383b18f61560fbfa4d13d6db4f4 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<Type>::xmgraceSetWriter() {} +template<class Type> +Foam::xmgraceSetWriter<Type>::xmgraceSetWriter(const dictionary& dict) +: + writer<Type>(dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.H b/src/fileFormats/sampledSetWriters/xmgrace/xmgraceSetWriter.H index 31ec5e41e378e318d56c23103b3108f5f9b76f93..d3f064106d43d1348e9419dddb26a687d8a62cc4 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<Type> { - 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 2420bc7ac5927915140f3fb9e66e15817d40998c..06601d251e3321974336bb289e0d8ce01bc0d708 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 0f38753b7d2d183451660242af26714e947eed90..d148f48514716cc041eb85689a72de95970a0ad1 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<sampledSet> { - // Private classes + // Private Classes //- Class used for grouping field types template<class Type> @@ -82,18 +82,7 @@ class sampledSets autoPtr<writer<Type>> formatter; //- Construct null - fieldGroup() - : - DynamicList<word>(0), - formatter(nullptr) - {} - - //- Construct for a particular format - fieldGroup(const word& writeFormat) - : - DynamicList<word>(0), - formatter(writer<Type>::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<Type>::New(writeFormat); + formatter = writer<Type>::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<scalar> scalarFields_; fieldGroup<vector> vectorFields_; @@ -196,7 +187,7 @@ class sampledSets fieldGroup<tensor> tensorFields_; - // Merging structures + // Merging structures PtrList<coordSet> 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<coordSet>& masterSampledSets, diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 82dad524a242f8197f983656b123f3a7464a7f64..c9441dd28c1c4cd7b7855d8c5a5da149007776da 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -231,7 +231,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields) // Create or use existing writer if (!fields.formatter) { - fields = writeFormat_; + fields.setFormatter(writeFormat_, writeFormatOptions_); } // Storage for interpolated values