From 6f098748ccab9b9165058ced5d416f0fa81015f4 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sun, 7 Aug 2016 15:23:55 +0100
Subject: [PATCH] functionObjects: Separated writeFile and logFiles (previously
 writeFiles) from regionFunctionObject

Now the functionality to write single graph files or log files (vs time)
may be used in the creation of any form of functionObject, not just
those relating to a mesh region.
---
 .../utilities/postProcessing/noise/noise.C    |  1 -
 src/OpenFOAM/Make/files                       |  2 +-
 .../writeFiles.C => logFiles/logFiles.C}      | 45 +++++---------
 .../writeFiles.H => logFiles/logFiles.H}      | 59 +++++++++----------
 .../db/functionObjects/writeFile/writeFile.C  | 32 ++--------
 .../db/functionObjects/writeFile/writeFile.H  | 56 +++++++-----------
 .../field/fieldMinMax/fieldMinMax.C           |  7 ++-
 .../field/fieldMinMax/fieldMinMax.H           | 10 ++--
 .../field/fieldValues/fieldValue/fieldValue.C | 10 ++--
 .../field/fieldValues/fieldValue/fieldValue.H | 11 +++-
 .../fieldValueDelta/fieldValueDelta.C         |  7 ++-
 .../fieldValueDelta/fieldValueDelta.H         | 11 +++-
 .../field/histogram/histogram.C               |  5 +-
 .../field/histogram/histogram.H               |  8 ++-
 .../regionSizeDistribution.C                  |  5 +-
 .../regionSizeDistribution.H                  |  6 +-
 .../field/wallHeatFlux/wallHeatFlux.C         |  7 ++-
 .../field/wallHeatFlux/wallHeatFlux.H         | 10 +++-
 .../field/wallShearStress/wallShearStress.C   |  7 ++-
 .../field/wallShearStress/wallShearStress.H   | 10 +++-
 src/functionObjects/field/yPlus/yPlus.C       |  7 ++-
 src/functionObjects/field/yPlus/yPlus.H       |  9 ++-
 .../forces/forceCoeffs/forceCoeffs.C          |  2 +-
 src/functionObjects/forces/forces/forces.C    | 10 ++--
 src/functionObjects/forces/forces/forces.H    | 10 +++-
 .../lagrangian/cloudInfo/cloudInfo.C          | 11 +++-
 .../lagrangian/cloudInfo/cloudInfo.H          |  9 ++-
 .../utilities/residuals/residuals.C           |  7 ++-
 .../utilities/residuals/residuals.H           |  9 ++-
 29 files changed, 197 insertions(+), 186 deletions(-)
 rename src/OpenFOAM/db/functionObjects/{writeFiles/writeFiles.C => logFiles/logFiles.C} (78%)
 rename src/OpenFOAM/db/functionObjects/{writeFiles/writeFiles.H => logFiles/logFiles.H} (78%)

diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C
index 77e549c9de4..7230e0cd047 100644
--- a/applications/utilities/postProcessing/noise/noise.C
+++ b/applications/utilities/postProcessing/noise/noise.C
@@ -81,7 +81,6 @@ See also
 #include "noiseFFT.H"
 #include "argList.H"
 #include "Time.H"
-#include "writeFiles.H"
 #include "CSV.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index c975296d1d0..e530cb2a002 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -222,7 +222,7 @@ $(dll)/codedBase/codedBase.C
 db/functionObjects/functionObject/functionObject.C
 db/functionObjects/functionObjectList/functionObjectList.C
 db/functionObjects/writeFile/writeFile.C
-db/functionObjects/writeFiles/writeFiles.C
+db/functionObjects/logFiles/logFiles.C
 db/functionObjects/timeControl/timeControl.C
 db/functionObjects/timeControl/timeControlFunctionObject.C
 db/functionObjects/regionFunctionObject/regionFunctionObject.C
diff --git a/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.C
similarity index 78%
rename from src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C
rename to src/OpenFOAM/db/functionObjects/logFiles/logFiles.C
index 4fdee06be4b..32931590b59 100644
--- a/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C
+++ b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.C
@@ -23,18 +23,18 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "writeFiles.H"
+#include "logFiles.H"
 #include "Time.H"
 #include "IFstream.H"
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
-void Foam::functionObjects::writeFiles::createFiles()
+void Foam::functionObjects::logFiles::createFiles()
 {
     if (Pstream::master())
     {
         const word startTimeName =
-            obr_.time().timeName(obr_.time().startTime().value());
+            fileObr_.time().timeName(fileObr_.time().startTime().value());
 
         forAll(names_, i)
         {
@@ -49,7 +49,7 @@ void Foam::functionObjects::writeFiles::createFiles()
                 IFstream is(outputDir/(fName + ".dat"));
                 if (is.good())
                 {
-                    fName = fName + "_" + obr_.time().timeName();
+                    fName = fName + "_" + fileObr_.time().timeName();
                 }
 
                 filePtrs_.set(i, new OFstream(outputDir/(fName + ".dat")));
@@ -57,14 +57,13 @@ void Foam::functionObjects::writeFiles::createFiles()
                 initStream(filePtrs_[i]);
 
                 writeFileHeader(i);
-
             }
         }
     }
 }
 
 
-void Foam::functionObjects::writeFiles::resetNames(const wordList& names)
+void Foam::functionObjects::logFiles::resetNames(const wordList& names)
 {
     names_.clear();
     names_.append(names);
@@ -77,7 +76,7 @@ void Foam::functionObjects::writeFiles::resetNames(const wordList& names)
 }
 
 
-void Foam::functionObjects::writeFiles::resetName(const word& name)
+void Foam::functionObjects::logFiles::resetName(const word& name)
 {
     names_.clear();
     names_.append(name);
@@ -92,29 +91,13 @@ void Foam::functionObjects::writeFiles::resetName(const word& name)
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::functionObjects::writeFiles::writeFiles
-(
-    const word& name,
-    const Time& time,
-    const dictionary& dict,
-    const word& prefix
-)
-:
-    writeFile(name, time, dict, prefix),
-    names_(),
-    filePtrs_()
-{}
-
-
-Foam::functionObjects::writeFiles::writeFiles
+Foam::functionObjects::logFiles::logFiles
 (
-    const word& name,
     const objectRegistry& obr,
-    const dictionary& dict,
     const word& prefix
 )
 :
-    writeFile(name, obr, dict, prefix),
+    writeFile(obr, prefix),
     names_(),
     filePtrs_()
 {}
@@ -122,19 +105,19 @@ Foam::functionObjects::writeFiles::writeFiles
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-Foam::functionObjects::writeFiles::~writeFiles()
+Foam::functionObjects::logFiles::~logFiles()
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-const Foam::wordList& Foam::functionObjects::writeFiles::names() const
+const Foam::wordList& Foam::functionObjects::logFiles::names() const
 {
     return names_;
 }
 
 
-Foam::OFstream& Foam::functionObjects::writeFiles::file()
+Foam::OFstream& Foam::functionObjects::logFiles::file()
 {
     if (!Pstream::master())
     {
@@ -161,7 +144,7 @@ Foam::OFstream& Foam::functionObjects::writeFiles::file()
 }
 
 
-Foam::PtrList<Foam::OFstream>& Foam::functionObjects::writeFiles::files()
+Foam::PtrList<Foam::OFstream>& Foam::functionObjects::logFiles::files()
 {
     if (!Pstream::master())
     {
@@ -174,7 +157,7 @@ Foam::PtrList<Foam::OFstream>& Foam::functionObjects::writeFiles::files()
 }
 
 
-Foam::OFstream& Foam::functionObjects::writeFiles::file(const label i)
+Foam::OFstream& Foam::functionObjects::logFiles::file(const label i)
 {
     if (!Pstream::master())
     {
@@ -194,7 +177,7 @@ Foam::OFstream& Foam::functionObjects::writeFiles::file(const label i)
 }
 
 
-bool Foam::functionObjects::writeFiles::write()
+bool Foam::functionObjects::logFiles::write()
 {
     createFiles();
 
diff --git a/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.H
similarity index 78%
rename from src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H
rename to src/OpenFOAM/db/functionObjects/logFiles/logFiles.H
index 12667a11ea2..466d483f3e8 100644
--- a/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H
+++ b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.H
@@ -22,22 +22,23 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Class
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::logFiles
 
 Description
-    functionObject base class for writing files
+    functionObject base class for creating, maintaining and writing log
+    files e.g. integrated of averaged field data vs time.
 
 See also
     Foam::functionObject
-    Foam::OutputFilterFunctionObject
+    Foam::functionObjects::writeFile
 
 SourceFiles
-    functionObjectFiles.C
+    logFiles.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef functionObjects_writeFiles_H
-#define functionObjects_writeFiles_H
+#ifndef functionObjects_logFiles_H
+#define functionObjects_logFiles_H
 
 #include "writeFile.H"
 #include "OFstream.H"
@@ -51,14 +52,17 @@ namespace functionObjects
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class writeFiles Declaration
+                     Class logFiles Declaration
 \*---------------------------------------------------------------------------*/
 
-class writeFiles
+class logFiles
 :
     public writeFile
 {
-    // Private data
+
+protected:
+
+    // Protected data
 
         //- File names
         wordList names_;
@@ -67,8 +71,6 @@ class writeFiles
         PtrList<OFstream> filePtrs_;
 
 
-protected:
-
     // Protected Member Functions
 
         //- Create the output file
@@ -80,38 +82,35 @@ protected:
         //- Reset the list of names to a single name entry
         virtual void resetName(const word& name);
 
+        //- File header information
+        virtual void writeFileHeader(const label i = 0) = 0;
+
+
+private:
+
+    // Private Member Functions
+
         //- Disallow default bitwise copy construct
-        writeFiles(const writeFiles&);
+        logFiles(const logFiles&);
 
         //- Disallow default bitwise assignment
-        void operator=(const writeFiles&);
+        void operator=(const logFiles&);
 
 
 public:
 
     // Constructors
 
-        //- Construct from name, Time, dictionary and prefix
-        writeFiles
+        //- Construct from objectRegistry and prefix
+        logFiles
         (
-            const word& name,
-            const Time& time,
-            const dictionary& dict,
-            const word& prefix
-        );
-
-        //- Construct from name, objectRegistry, dictionary and prefix
-        writeFiles
-        (
-            const word& name,
             const objectRegistry& obr,
-            const dictionary& dict,
             const word& prefix
         );
 
 
     //- Destructor
-    virtual ~writeFiles();
+    virtual ~logFiles();
 
 
     // Member Functions
@@ -119,12 +118,12 @@ public:
         //- Return const access to the names
         const wordList& names() const;
 
-        //- Return access to the file (if only 1)
-        OFstream& file();
-
         //- Return access to the files
         PtrList<OFstream>& files();
 
+        //- Return access to the file (if only 1)
+        OFstream& file();
+
         //- Return file 'i'
         OFstream& file(const label i);
 
diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C
index d2a172d408e..919b948b0de 100644
--- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C
+++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C
@@ -26,7 +26,6 @@ License
 #include "writeFile.H"
 #include "Time.H"
 #include "polyMesh.H"
-#include "IOmanip.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -49,7 +48,7 @@ void Foam::functionObjects::writeFile::initStream(Ostream& os) const
 
 Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
 {
-    fileName baseDir = obr_.time().path();
+    fileName baseDir = fileObr_.time().path();
 
     if (Pstream::parRun())
     {
@@ -63,9 +62,9 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
     }
 
     // Append mesh name if not default region
-    if (isA<polyMesh>(obr_))
+    if (isA<polyMesh>(fileObr_))
     {
-        const polyMesh& mesh = refCast<const polyMesh>(obr_);
+        const polyMesh& mesh = refCast<const polyMesh>(fileObr_);
         if (mesh.name() != polyMesh::defaultRegion)
         {
             baseDir = baseDir/mesh.name();
@@ -78,14 +77,10 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
 
 Foam::fileName Foam::functionObjects::writeFile::baseTimeDir() const
 {
-    return baseFileDir()/prefix_/obr_.time().timeName();
+    return baseFileDir()/prefix_/fileObr_.time().timeName();
 }
 
 
-void Foam::functionObjects::writeFile::writeFileHeader(const label i)
-{}
-
-
 Foam::Omanip<int> Foam::functionObjects::writeFile::valueWidth
 (
     const label offset
@@ -99,26 +94,11 @@ Foam::Omanip<int> Foam::functionObjects::writeFile::valueWidth
 
 Foam::functionObjects::writeFile::writeFile
 (
-    const word& name,
-    const Time& runTime,
-    const dictionary& dict,
-    const word& prefix
-)
-:
-    regionFunctionObject(name, runTime, dict),
-    prefix_(prefix)
-{}
-
-
-Foam::functionObjects::writeFile::writeFile
-(
-    const word& name,
     const objectRegistry& obr,
-    const dictionary& dict,
     const word& prefix
 )
 :
-    regionFunctionObject(name, obr, dict),
+    fileObr_(obr),
     prefix_(prefix)
 {}
 
@@ -171,7 +151,7 @@ void Foam::functionObjects::writeFile::writeHeader
 
 void Foam::functionObjects::writeFile::writeTime(Ostream& os) const
 {
-    os  << setw(charWidth()) << obr_.time().timeName();
+    os  << setw(charWidth()) << fileObr_.time().timeName();
 }
 
 
diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
index 111a50a7f99..ccf6e0e3e42 100644
--- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
+++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
@@ -28,19 +28,18 @@ Description
     functionObject base class for writing single files
 
 See also
-    Foam::regionFunctionObject
     Foam::functionObject
+    Foam::functionObjects::logFiles
 
 SourceFiles
-    functionObjectFile.C
+    writeFile.C
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef functionObjects_writeFile_H
 #define functionObjects_writeFile_H
 
-#include "regionFunctionObject.H"
-#include "Time.H"
+#include "objectRegistry.H"
 #include "IOmanip.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -55,34 +54,22 @@ namespace functionObjects
 \*---------------------------------------------------------------------------*/
 
 class writeFile
-:
-    public regionFunctionObject
 {
 
 protected:
 
     // Protected data
 
+        //- Reference to the region objectRegistry
+        const objectRegistry& fileObr_;
+
         //- Prefix
         const word prefix_;
 
 
-    // Protected Member Functions
-
-        //- Initialise the output stream for writing
-        virtual void initStream(Ostream& os) const;
-
-        //- Return the base directory for output
-        virtual fileName baseFileDir() const;
+private:
 
-        //- Return the base directory for the current time value
-        virtual fileName baseTimeDir() const;
-
-        //- File header information
-        virtual void writeFileHeader(const label i = 0);
-
-        //- Return the value width when writing to stream with optional offset
-        virtual Omanip<int> valueWidth(const label offset = 0) const;
+    // Private Member Functions
 
         //- Disallow default bitwise copy construct
         writeFile(const writeFile&);
@@ -102,31 +89,32 @@ public:
 
     // Constructors
 
-        //- Construct from name, Time, dictionary and prefix
-        writeFile
-        (
-            const word& name,
-            const Time& t,
-            const dictionary& dict,
-            const word& prefix
-        );
-
-        //- Construct from name, objectRegistry, dictionary and prefix
+        //- Construct from objectRegistry and prefix
         writeFile
         (
-            const word& name,
             const objectRegistry& obr,
-            const dictionary& dict,
             const word& prefix
         );
 
 
     //- Destructor
-    virtual ~writeFile();
+    ~writeFile();
 
 
     // Member Functions
 
+        //- Initialise the output stream for writing
+        void initStream(Ostream& os) const;
+
+        //- Return the base directory for output
+        fileName baseFileDir() const;
+
+        //- Return the base directory for the current time value
+        fileName baseTimeDir() const;
+
+        //- Return the value width when writing to stream with optional offset
+        Omanip<int> valueWidth(const label offset = 0) const;
+
         //- Write a commented string to stream
         void writeCommented(Ostream& os, const string& str) const;
 
diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/functionObjects/field/fieldMinMax/fieldMinMax.C
index 18e66003cb4..94c46553453 100644
--- a/src/functionObjects/field/fieldMinMax/fieldMinMax.C
+++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.C
@@ -103,7 +103,8 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     location_(true),
     mode_(mdMag),
     fieldSet_()
@@ -129,7 +130,7 @@ Foam::functionObjects::fieldMinMax::~fieldMinMax()
 
 bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
 {
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     location_ = dict.lookupOrDefault<Switch>("location", true);
 
@@ -148,7 +149,7 @@ bool Foam::functionObjects::fieldMinMax::execute()
 
 bool Foam::functionObjects::fieldMinMax::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     if (!location_) writeTime(file());
     Log << type() << " " << name() <<  " write:" << nl;
diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/functionObjects/field/fieldMinMax/fieldMinMax.H
index a024b61cbc2..24a218e4248 100644
--- a/src/functionObjects/field/fieldMinMax/fieldMinMax.H
+++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.H
@@ -67,8 +67,8 @@ Usage
     Output data is written to the file \<timeDir\>/fieldMinMax.dat
 
 See also
-    Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
 
 SourceFiles
     fieldMinMax.C
@@ -78,7 +78,8 @@ SourceFiles
 #ifndef functionObjects_fieldMinMax_H
 #define functionObjects_fieldMinMax_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "vector.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -94,7 +95,8 @@ namespace functionObjects
 
 class fieldMinMax
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
 public:
 
diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C
index 54731bb9ff9..fac60d2f9cf 100644
--- a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C
+++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.C
@@ -49,7 +49,8 @@ Foam::functionObjects::fieldValue::fieldValue
     const word& valueType
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     dict_(dict),
     regionName_(word::null),
     resultDict_(fileName("name"), dictionary::null)
@@ -67,7 +68,8 @@ Foam::functionObjects::fieldValue::fieldValue
     const word& valueType
 )
 :
-    writeFiles(name, obr, dict, name),
+    regionFunctionObject(name, obr, dict),
+    logFiles(obr_, name),
     dict_(dict),
     regionName_(word::null),
     resultDict_(fileName("name"), dictionary::null)
@@ -88,7 +90,7 @@ Foam::functionObjects::fieldValue::~fieldValue()
 bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
 {
     dict_ = dict;
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     dict.lookup("fields") >> fields_;
     dict.lookup("writeFields") >> writeFields_;
@@ -105,7 +107,7 @@ bool Foam::functionObjects::fieldValue::execute()
 
 bool Foam::functionObjects::fieldValue::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     Log << type() << " " << name() << " write:" << nl;
 
diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H
index cad2b654907..c6331b5abb1 100644
--- a/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H
+++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValue.H
@@ -30,6 +30,11 @@ Group
 Description
     Base class for field value -based function objects.
 
+See also
+    Foam::functionObject
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
+
 SourceFiles
     fieldValue.C
 
@@ -38,7 +43,8 @@ SourceFiles
 #ifndef functionObjects_fieldValue_H
 #define functionObjects_fieldValue_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "Switch.H"
 #include "Field.H"
 
@@ -59,7 +65,8 @@ namespace functionObjects
 
 class fieldValue
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
 
 protected:
diff --git a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C
index 5c0b22c3e9a..3b243f87b58 100644
--- a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C
+++ b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C
@@ -106,7 +106,8 @@ Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     operation_(opSubtract),
     region1Ptr_(nullptr),
     region2Ptr_(nullptr)
@@ -135,7 +136,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
     const dictionary& dict
 )
 {
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     region1Ptr_.reset
     (
@@ -166,7 +167,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
 
 bool Foam::functionObjects::fieldValues::fieldValueDelta::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     region1Ptr_->write();
     region2Ptr_->write();
diff --git a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
index 127efb97536..d31620c97f9 100644
--- a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
+++ b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
@@ -65,7 +65,10 @@ Usage
     \endplaintable
 
 See also
-    Foam::fieldValue
+    Foam::functionObject
+    Foam::functionObject::fieldValue
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
 
 SourceFiles
     fieldValueDelta.C
@@ -75,7 +78,8 @@ SourceFiles
 #ifndef functionObjects_fieldValueDelta_H
 #define functionObjects_fieldValueDelta_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "fieldValue.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -93,7 +97,8 @@ namespace fieldValues
 
 class fieldValueDelta
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
 public:
         //- Operation type enumeration
diff --git a/src/functionObjects/field/histogram/histogram.C b/src/functionObjects/field/histogram/histogram.C
index f8e015020d3..6ccc0dbaf4d 100644
--- a/src/functionObjects/field/histogram/histogram.C
+++ b/src/functionObjects/field/histogram/histogram.C
@@ -50,7 +50,7 @@ void Foam::functionObjects::histogram::writeGraph
 {
     const wordList fieldNames(1, fieldName);
 
-    fileName outputPath = baseTimeDir();
+    fileName outputPath = file_.baseTimeDir();
     mkDir(outputPath);
     OFstream graphFile
     (
@@ -75,7 +75,8 @@ Foam::functionObjects::histogram::histogram
     const dictionary& dict
 )
 :
-    writeFile(name, runTime, dict, name)
+    regionFunctionObject(name, runTime, dict),
+    file_(obr_, name)
 {
     if (!isA<fvMesh>(obr_))
     {
diff --git a/src/functionObjects/field/histogram/histogram.H b/src/functionObjects/field/histogram/histogram.H
index 07674443697..9972e7fd035 100644
--- a/src/functionObjects/field/histogram/histogram.H
+++ b/src/functionObjects/field/histogram/histogram.H
@@ -59,6 +59,7 @@ Usage
 
 See also
     Foam::functionObject
+    Foam::functionObjects::regionFunctionObject
     Foam::functionObjects::writeFile
 
 SourceFiles
@@ -69,8 +70,9 @@ SourceFiles
 #ifndef functionObjects_histogram_H
 #define functionObjects_histogram_H
 
-#include "writer.H"
+#include "regionFunctionObject.H"
 #include "writeFile.H"
+#include "writer.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -85,10 +87,12 @@ namespace functionObjects
 
 class histogram
 :
-    public writeFile
+    public regionFunctionObject
 {
     // Private data
 
+        writeFile file_;
+
         //- Name of field
         word fieldName_;
 
diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
index 95bab35c13a..f6bd360ef30 100644
--- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
+++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
@@ -74,7 +74,7 @@ void Foam::functionObjects::regionSizeDistribution::writeGraph
 {
     const wordList valNames(1, valueName);
 
-    fileName outputPath = baseTimeDir();
+    fileName outputPath = file_.baseTimeDir();
     mkDir(outputPath);
 
     OFstream str(outputPath/formatterPtr_().getFileName(coords, valNames));
@@ -330,7 +330,8 @@ Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
     const dictionary& dict
 )
 :
-    writeFile(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    file_(obr_, name),
     alphaName_(dict.lookup("field")),
     patchNames_(dict.lookup("patches"))
 {
diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H
index f3a7b53a0c2..52d45ef292e 100644
--- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H
+++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H
@@ -96,6 +96,7 @@ Usage
 
 See also
     Foam::functionObject
+    Foam::functionObjects::regionFunctionObject
     Foam::functionObjects::writeFile
 
 SourceFiles
@@ -106,6 +107,7 @@ SourceFiles
 #ifndef functionObjects_regionSizeDistribution_H
 #define functionObjects_regionSizeDistribution_H
 
+#include "regionFunctionObject.H"
 #include "writeFile.H"
 #include "writer.H"
 #include "Map.H"
@@ -130,10 +132,12 @@ namespace functionObjects
 
 class regionSizeDistribution
 :
-    public writeFile
+    public regionFunctionObject
 {
     // Private data
 
+        writeFile file_;
+
         //- Name of field
         word alphaName_;
 
diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C
index 142d3d739a8..9f42c564912 100644
--- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C
+++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C
@@ -102,7 +102,8 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     patchSet_()
 {
     if (!isA<fvMesh>(obr_))
@@ -147,7 +148,7 @@ Foam::functionObjects::wallHeatFlux::~wallHeatFlux()
 
 bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
 {
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     const fvMesh& mesh = refCast<const fvMesh>(obr_);
     const polyBoundaryMesh& pbm = mesh.boundaryMesh();
@@ -237,7 +238,7 @@ bool Foam::functionObjects::wallHeatFlux::execute()
 
 bool Foam::functionObjects::wallHeatFlux::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     const volScalarField& wallHeatFlux =
         obr_.lookupObject<volScalarField>(type());
diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H
index 505d0196698..4cb46bea232 100644
--- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H
+++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H
@@ -54,7 +54,8 @@ Usage
 
 See also
     Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
     Foam::functionObjects::pressureTools
     Foam::functionObjects::timeControl
 
@@ -66,7 +67,8 @@ SourceFiles
 #ifndef functionObjects_wallHeatFlux_H
 #define functionObjects_wallHeatFlux_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "volFieldsFwd.H"
 #include "surfaceFieldsFwd.H"
 #include "HashSet.H"
@@ -89,8 +91,10 @@ namespace functionObjects
 
 class wallHeatFlux
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
+
 protected:
 
     // Protected data
diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C
index a31714a4068..b9427c6a5fc 100644
--- a/src/functionObjects/field/wallShearStress/wallShearStress.C
+++ b/src/functionObjects/field/wallShearStress/wallShearStress.C
@@ -89,7 +89,8 @@ Foam::functionObjects::wallShearStress::wallShearStress
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     patchSet_()
 {
     if (!isA<fvMesh>(obr_))
@@ -139,7 +140,7 @@ Foam::functionObjects::wallShearStress::~wallShearStress()
 
 bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
 {
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     const fvMesh& mesh = refCast<const fvMesh>(obr_);
     const polyBoundaryMesh& pbm = mesh.boundaryMesh();
@@ -236,7 +237,7 @@ bool Foam::functionObjects::wallShearStress::execute()
 
 bool Foam::functionObjects::wallShearStress::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     const volVectorField& wallShearStress =
         obr_.lookupObject<volVectorField>(type());
diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.H b/src/functionObjects/field/wallShearStress/wallShearStress.H
index 5836f08b865..f63ffa5542e 100644
--- a/src/functionObjects/field/wallShearStress/wallShearStress.H
+++ b/src/functionObjects/field/wallShearStress/wallShearStress.H
@@ -65,7 +65,8 @@ Usage
 
 See also
     Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
     Foam::functionObjects::pressureTools
     Foam::functionObjects::timeControl
 
@@ -77,7 +78,8 @@ SourceFiles
 #ifndef functionObjects_wallShearStress_H
 #define functionObjects_wallShearStress_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "volFieldsFwd.H"
 #include "HashSet.H"
 
@@ -98,8 +100,10 @@ namespace functionObjects
 
 class wallShearStress
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
+
 protected:
 
     // Protected data
diff --git a/src/functionObjects/field/yPlus/yPlus.C b/src/functionObjects/field/yPlus/yPlus.C
index e9db697e782..a2dc994da14 100644
--- a/src/functionObjects/field/yPlus/yPlus.C
+++ b/src/functionObjects/field/yPlus/yPlus.C
@@ -121,7 +121,8 @@ Foam::functionObjects::yPlus::yPlus
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name)
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name)
 {
     if (!isA<fvMesh>(obr_))
     {
@@ -164,7 +165,7 @@ Foam::functionObjects::yPlus::~yPlus()
 
 bool Foam::functionObjects::yPlus::read(const dictionary& dict)
 {
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     return true;
 }
@@ -208,7 +209,7 @@ bool Foam::functionObjects::yPlus::write()
 
     yPlus.write();
 
-    writeFiles::write();
+    logFiles::write();
 
     const volScalarField::Boundary& yPlusBf = yPlus.boundaryField();
 
diff --git a/src/functionObjects/field/yPlus/yPlus.H b/src/functionObjects/field/yPlus/yPlus.H
index 45696b83000..e8435189ec9 100644
--- a/src/functionObjects/field/yPlus/yPlus.H
+++ b/src/functionObjects/field/yPlus/yPlus.H
@@ -33,7 +33,8 @@ Description
 
 See also
     Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
     Foam::functionObjects::timeControl
 
 SourceFiles
@@ -44,7 +45,8 @@ SourceFiles
 #ifndef functionObjects_yPlus_H
 #define functionObjects_yPlus_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "volFieldsFwd.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -65,7 +67,8 @@ namespace functionObjects
 
 class yPlus
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
     // Private Member Functions
 
diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C
index 64d72517e68..cf6d258bfa9 100644
--- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C
+++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C
@@ -179,7 +179,7 @@ bool Foam::functionObjects::forceCoeffs::write()
 
     if (Pstream::master())
     {
-        writeFiles::write();
+        logFiles::write();
 
         scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
 
diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C
index 6b208963d58..8f330337336 100644
--- a/src/functionObjects/forces/forces/forces.C
+++ b/src/functionObjects/forces/forces/forces.C
@@ -529,7 +529,8 @@ Foam::functionObjects::forces::forces
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     force_(3),
     moment_(3),
     patchSet_(),
@@ -569,7 +570,8 @@ Foam::functionObjects::forces::forces
     const dictionary& dict
 )
 :
-    writeFiles(name, obr, dict, name),
+    regionFunctionObject(name, obr, dict),
+    logFiles(obr_, name),
     force_(3),
     moment_(3),
     patchSet_(),
@@ -612,7 +614,7 @@ Foam::functionObjects::forces::~forces()
 
 bool Foam::functionObjects::forces::read(const dictionary& dict)
 {
-    writeFiles::read(dict);
+    regionFunctionObject::read(dict);
 
     initialised_ = false;
 
@@ -909,7 +911,7 @@ bool Foam::functionObjects::forces::write()
 
     if (Pstream::master())
     {
-        writeFiles::write();
+        logFiles::write();
 
         writeForces();
 
diff --git a/src/functionObjects/forces/forces/forces.H b/src/functionObjects/forces/forces/forces.H
index 223c4cd632f..a3ecac8f16e 100644
--- a/src/functionObjects/forces/forces/forces.H
+++ b/src/functionObjects/forces/forces/forces.H
@@ -101,7 +101,8 @@ Note
 
 See also
     Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
     Foam::functionObjects::timeControl
     Foam::forceCoeffs
 
@@ -113,7 +114,8 @@ SourceFiles
 #ifndef functionObjects_forces_H
 #define functionObjects_forces_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 #include "coordinateSystem.H"
 #include "volFieldsFwd.H"
 #include "HashSet.H"
@@ -131,8 +133,10 @@ namespace functionObjects
 
 class forces
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
+
 protected:
 
     // Protected data
diff --git a/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C b/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C
index f2e8639f8c8..f8cb1dfb71a 100644
--- a/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C
+++ b/src/functionObjects/lagrangian/cloudInfo/cloudInfo.C
@@ -25,6 +25,8 @@ License
 
 #include "cloudInfo.H"
 #include "kinematicCloud.H"
+#include "dictionary.H"
+#include "PstreamReduceOps.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -66,7 +68,8 @@ Foam::functionObjects::cloudInfo::cloudInfo
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name)
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name)
 {
     read(dict);
 }
@@ -82,7 +85,9 @@ Foam::functionObjects::cloudInfo::~cloudInfo()
 
 bool Foam::functionObjects::cloudInfo::read(const dictionary& dict)
 {
-    writeFiles::resetNames(dict.lookup("clouds"));
+    regionFunctionObject::read(dict);
+
+    logFiles::resetNames(dict.lookup("clouds"));
 
     Info<< type() << " " << name() << ": ";
     if (names().size())
@@ -111,7 +116,7 @@ bool Foam::functionObjects::cloudInfo::execute()
 
 bool Foam::functionObjects::cloudInfo::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     forAll(names(), i)
     {
diff --git a/src/functionObjects/lagrangian/cloudInfo/cloudInfo.H b/src/functionObjects/lagrangian/cloudInfo/cloudInfo.H
index 564406dde5f..a2720ea4e5b 100644
--- a/src/functionObjects/lagrangian/cloudInfo/cloudInfo.H
+++ b/src/functionObjects/lagrangian/cloudInfo/cloudInfo.H
@@ -61,7 +61,8 @@ Usage
 
 See also
     Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
 
 SourceFiles
     cloudInfo.C
@@ -71,7 +72,8 @@ SourceFiles
 #ifndef functionObjects_cloudInfo_H
 #define functionObjects_cloudInfo_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -86,7 +88,8 @@ namespace functionObjects
 
 class cloudInfo
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
 protected:
 
diff --git a/src/functionObjects/utilities/residuals/residuals.C b/src/functionObjects/utilities/residuals/residuals.C
index 17e1cb1a769..b86454a8a7a 100644
--- a/src/functionObjects/utilities/residuals/residuals.C
+++ b/src/functionObjects/utilities/residuals/residuals.C
@@ -53,7 +53,8 @@ Foam::functionObjects::residuals::residuals
     const dictionary& dict
 )
 :
-    writeFiles(name, runTime, dict, name),
+    regionFunctionObject(name, runTime, dict),
+    logFiles(obr_, name),
     fieldSet_()
 {
     if (!isA<fvMesh>(obr_))
@@ -77,6 +78,8 @@ Foam::functionObjects::residuals::~residuals()
 
 bool Foam::functionObjects::residuals::read(const dictionary& dict)
 {
+    regionFunctionObject::read(dict);
+
     dict.lookup("fields") >> fieldSet_;
 
     return true;
@@ -114,7 +117,7 @@ bool Foam::functionObjects::residuals::execute()
 
 bool Foam::functionObjects::residuals::write()
 {
-    writeFiles::write();
+    logFiles::write();
 
     if (Pstream::master())
     {
diff --git a/src/functionObjects/utilities/residuals/residuals.H b/src/functionObjects/utilities/residuals/residuals.H
index 92b23ddc6d0..0bd59727121 100644
--- a/src/functionObjects/utilities/residuals/residuals.H
+++ b/src/functionObjects/utilities/residuals/residuals.H
@@ -51,7 +51,8 @@ Description
 
 See also
     Foam::functionObject
-    Foam::functionObjects::writeFiles
+    Foam::functionObjects::regionFunctionObject
+    Foam::functionObjects::logFiles
     Foam::functionObjects::timeControl
 
 SourceFiles
@@ -62,7 +63,8 @@ SourceFiles
 #ifndef functionObjects_residuals_H
 #define functionObjects_residuals_H
 
-#include "writeFiles.H"
+#include "regionFunctionObject.H"
+#include "logFiles.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -77,7 +79,8 @@ namespace functionObjects
 
 class residuals
 :
-    public writeFiles
+    public regionFunctionObject,
+    public logFiles
 {
 protected:
 
-- 
GitLab