diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index 43597560f0..24eda6383f 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -82,7 +82,7 @@ SeeAlso #include "noiseFFT.H" #include "argList.H" #include "Time.H" -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "CSV.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 056517f409..34a1300503 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -215,6 +215,7 @@ $(dll)/codedBase/codedBase.C db/functionObjects/functionObject/functionObject.C db/functionObjects/functionObjectList/functionObjectList.C db/functionObjects/functionObjectFile/functionObjectFile.C +db/functionObjects/functionObjectFiles/functionObjectFiles.C db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index 05b794d5e7..cf97dc5629 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -90,8 +90,8 @@ class OutputFilterFunctionObject //- De-activation time - defaults to VGREAT scalar timeEnd_; - //- Number of steps before the dumping time in which the deltaT - // will start to change (valid for ocAdjustableTime) + //- Number of steps before the dump-time during which deltaT + // may be changed (valid for adjustableRunTime) label nStepsToStartTimeChange_; diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index b6a2a8b192..9bcdd6cda0 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,8 +32,8 @@ License namespace Foam { -defineDebugSwitchWithName(functionObject, "functionObject", 0); -defineRunTimeSelectionTable(functionObject, dictionary); + defineDebugSwitchWithName(functionObject, "functionObject", 0); + defineRunTimeSelectionTable(functionObject, dictionary); } @@ -126,15 +126,4 @@ bool Foam::functionObject::adjustTimeStep() } -Foam::autoPtr Foam::functionObject::iNew::operator() -( - const word& name, - Istream& is -) const -{ - dictionary dict(is); - return functionObject::New(name, time_, dict); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 2d0d3ed1cb..c31427b388 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -105,26 +105,6 @@ public: return autoPtr(NULL); } - //- Return a pointer to a new functionObject created on freestore - // from Istream - class iNew - { - const Time& time_; - - public: - - iNew(const Time& t) - : - time_(t) - {} - - autoPtr operator() - ( - const word& name, - Istream& is - ) const; - }; - // Selectors diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C index a18bdc12e0..7481997138 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,7 +26,7 @@ License #include "functionObjectFile.H" #include "Time.H" #include "polyMesh.H" -#include "IFstream.H" +#include "IOmanip.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -78,81 +78,10 @@ Foam::fileName Foam::functionObjectFile::baseTimeDir() const } -void Foam::functionObjectFile::createFiles() -{ - if (Pstream::master()) - { - const word startTimeName = - obr_.time().timeName(obr_.time().startTime().value()); - - forAll(names_, i) - { - if (!filePtrs_.set(i)) - { - fileName outputDir(baseFileDir()/prefix_/startTimeName); - mkDir(outputDir); - - word fName(names_[i]); - - // Check if file already exists - IFstream is(outputDir/(fName + ".dat")); - if (is.good()) - { - fName = fName + "_" + obr_.time().timeName(); - } - - filePtrs_.set(i, new OFstream(outputDir/(fName + ".dat"))); - - initStream(filePtrs_[i]); - - writeFileHeader(i); - - } - } - } -} - - void Foam::functionObjectFile::writeFileHeader(const label i) {} -void Foam::functionObjectFile::write() -{ - createFiles(); -} - - -void Foam::functionObjectFile::resetNames(const wordList& names) -{ - names_.clear(); - names_.append(names); - - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(names_.size()); - - createFiles(); - } -} - - -void Foam::functionObjectFile::resetName(const word& name) -{ - names_.clear(); - names_.append(name); - - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(1); - - createFiles(); - } -} - - Foam::Omanip Foam::functionObjectFile::valueWidth(const label offset) const { return setw(IOstream::defaultPrecision() + addChars + offset); @@ -168,60 +97,10 @@ Foam::functionObjectFile::functionObjectFile ) : obr_(obr), - prefix_(prefix), - names_(), - filePtrs_() + prefix_(prefix) {} -Foam::functionObjectFile::functionObjectFile -( - const objectRegistry& obr, - const word& prefix, - const word& name -) -: - obr_(obr), - prefix_(prefix), - names_(), - filePtrs_() -{ - names_.clear(); - names_.append(name); - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(1); - - // Cannot create files - need to access virtual function - } -} - - -Foam::functionObjectFile::functionObjectFile -( - const objectRegistry& obr, - const word& prefix, - const wordList& names -) -: - obr_(obr), - prefix_(prefix), - names_(names), - filePtrs_() -{ - names_.clear(); - names_.append(names); - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(names_.size()); - - // Cannot create files - need to access virtual function - } -} - - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::functionObjectFile::~functionObjectFile() @@ -230,72 +109,6 @@ Foam::functionObjectFile::~functionObjectFile() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::wordList& Foam::functionObjectFile::names() const -{ - return names_; -} - - -Foam::OFstream& Foam::functionObjectFile::file() -{ - if (!Pstream::master()) - { - FatalErrorInFunction - << "Request for file() can only be done by the master process" - << abort(FatalError); - } - - if (filePtrs_.size() != 1) - { - WarningInFunction - << "Requested single file, but multiple files are present" - << endl; - } - - if (!filePtrs_.set(0)) - { - FatalErrorInFunction - << "File pointer at index " << 0 << " not allocated" - << abort(FatalError); - } - - return filePtrs_[0]; -} - - -Foam::PtrList& Foam::functionObjectFile::files() -{ - if (!Pstream::master()) - { - FatalErrorInFunction - << "Request for files() can only be done by the master process" - << abort(FatalError); - } - - return filePtrs_; -} - - -Foam::OFstream& Foam::functionObjectFile::file(const label i) -{ - if (!Pstream::master()) - { - FatalErrorInFunction - << "Request for file(i) can only be done by the master process" - << abort(FatalError); - } - - if (!filePtrs_.set(i)) - { - FatalErrorInFunction - << "File pointer at index " << i << " not allocated" - << abort(FatalError); - } - - return filePtrs_[i]; -} - - Foam::label Foam::functionObjectFile::charWidth() const { return IOstream::defaultPrecision() + addChars; diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H index 33a4ae5122..7a3ad27390 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,9 +40,6 @@ SourceFiles #define functionObjectFile_H #include "objectRegistry.H" -#include "OFstream.H" -#include "PtrList.H" -#include "HashSet.H" #include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,22 +54,17 @@ namespace Foam class functionObjectFile { - // Private data - //- Reference to the database +protected: + + // Protected data + + //- Reference to the objectRegistry const objectRegistry& obr_; //- Prefix const word prefix_; - //- File names - wordList names_; - - //- File pointer - PtrList filePtrs_; - - -protected: // Protected Member Functions @@ -85,21 +77,9 @@ protected: //- Return the base directory for the current time value virtual fileName baseTimeDir() const; - //- Create the output file - virtual void createFiles(); - //- File header information virtual void writeFileHeader(const label i = 0); - //- Write function - virtual void write(); - - //- Reset the list of names from a wordList - virtual void resetNames(const wordList& names); - - //- Reset the list of names to a single name entry - virtual void resetName(const word& name); - //- Return the value width when writing to stream with optional offset virtual Omanip valueWidth(const label offset = 0) const; @@ -121,25 +101,9 @@ public: // Constructors - //- Construct null + //- Construct from objectRegistry functionObjectFile(const objectRegistry& obr, const word& prefix); - //- Construct from components - functionObjectFile - ( - const objectRegistry& obr, - const word& prefix, - const word& name - ); - - //- Construct from components - functionObjectFile - ( - const objectRegistry& obr, - const word& prefix, - const wordList& names - ); - //- Destructor virtual ~functionObjectFile(); @@ -147,18 +111,6 @@ public: // Member Functions - //- 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& files(); - - //- Return file 'i' - OFstream& file(const label i); - //- Write a commented string to stream void writeCommented ( diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C index a9180e1fee..d0acfb8552 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,8 +23,6 @@ License \*---------------------------------------------------------------------------*/ -#include "OStringStream.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C b/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C new file mode 100644 index 0000000000..efaf20902a --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C @@ -0,0 +1,237 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "functionObjectFiles.H" +#include "Time.H" +#include "IFstream.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::functionObjectFiles::createFiles() +{ + if (Pstream::master()) + { + const word startTimeName = + obr_.time().timeName(obr_.time().startTime().value()); + + forAll(names_, i) + { + if (!filePtrs_.set(i)) + { + fileName outputDir(baseFileDir()/prefix_/startTimeName); + mkDir(outputDir); + + word fName(names_[i]); + + // Check if file already exists + IFstream is(outputDir/(fName + ".dat")); + if (is.good()) + { + fName = fName + "_" + obr_.time().timeName(); + } + + filePtrs_.set(i, new OFstream(outputDir/(fName + ".dat"))); + + initStream(filePtrs_[i]); + + writeFileHeader(i); + + } + } + } +} + + +void Foam::functionObjectFiles::write() +{ + createFiles(); +} + + +void Foam::functionObjectFiles::resetNames(const wordList& names) +{ + names_.clear(); + names_.append(names); + + if (Pstream::master()) + { + filePtrs_.clear(); + filePtrs_.setSize(names_.size()); + + createFiles(); + } +} + + +void Foam::functionObjectFiles::resetName(const word& name) +{ + names_.clear(); + names_.append(name); + + if (Pstream::master()) + { + filePtrs_.clear(); + filePtrs_.setSize(1); + + createFiles(); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjectFiles::functionObjectFiles +( + const objectRegistry& obr, + const word& prefix +) +: + functionObjectFile(obr, prefix), + names_(), + filePtrs_() +{} + + +Foam::functionObjectFiles::functionObjectFiles +( + const objectRegistry& obr, + const word& prefix, + const word& name +) +: + functionObjectFile(obr, prefix), + names_(), + filePtrs_() +{ + names_.clear(); + names_.append(name); + if (Pstream::master()) + { + filePtrs_.clear(); + filePtrs_.setSize(1); + + // Cannot create files - need to access virtual function + } +} + + +Foam::functionObjectFiles::functionObjectFiles +( + const objectRegistry& obr, + const word& prefix, + const wordList& names +) +: + functionObjectFile(obr, prefix), + names_(names), + filePtrs_() +{ + names_.clear(); + names_.append(names); + if (Pstream::master()) + { + filePtrs_.clear(); + filePtrs_.setSize(names_.size()); + + // Cannot create files - need to access virtual function + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjectFiles::~functionObjectFiles() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::wordList& Foam::functionObjectFiles::names() const +{ + return names_; +} + + +Foam::OFstream& Foam::functionObjectFiles::file() +{ + if (!Pstream::master()) + { + FatalErrorInFunction + << "Request for file() can only be done by the master process" + << abort(FatalError); + } + + if (filePtrs_.size() != 1) + { + WarningInFunction + << "Requested single file, but multiple files are present" + << endl; + } + + if (!filePtrs_.set(0)) + { + FatalErrorInFunction + << "File pointer at index " << 0 << " not allocated" + << abort(FatalError); + } + + return filePtrs_[0]; +} + + +Foam::PtrList& Foam::functionObjectFiles::files() +{ + if (!Pstream::master()) + { + FatalErrorInFunction + << "Request for files() can only be done by the master process" + << abort(FatalError); + } + + return filePtrs_; +} + + +Foam::OFstream& Foam::functionObjectFiles::file(const label i) +{ + if (!Pstream::master()) + { + FatalErrorInFunction + << "Request for file(i) can only be done by the master process" + << abort(FatalError); + } + + if (!filePtrs_.set(i)) + { + FatalErrorInFunction + << "File pointer at index " << i << " not allocated" + << abort(FatalError); + } + + return filePtrs_[i]; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H b/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H new file mode 100644 index 0000000000..cf29461add --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::functionObjectFiles + +Description + Base class for output file data handling + +See Also + Foam::functionObject + Foam::OutputFilterFunctionObject + +SourceFiles + functionObjectFiles.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjectFiles_H +#define functionObjectFiles_H + +#include "functionObjectFile.H" +#include "OFstream.H" +#include "PtrList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + + +/*---------------------------------------------------------------------------*\ + Class functionObjectFiles Declaration +\*---------------------------------------------------------------------------*/ + +class functionObjectFiles +: + public functionObjectFile +{ + // Private data + + //- File names + wordList names_; + + //- File pointer + PtrList filePtrs_; + + +protected: + + // Protected Member Functions + + //- Create the output file + virtual void createFiles(); + + //- Write function + virtual void write(); + + //- Reset the list of names from a wordList + virtual void resetNames(const wordList& names); + + //- Reset the list of names to a single name entry + virtual void resetName(const word& name); + + //- Disallow default bitwise copy construct + functionObjectFiles(const functionObjectFiles&); + + //- Disallow default bitwise assignment + void operator=(const functionObjectFiles&); + + +public: + + // Constructors + + //- Construct from objectRegistry + functionObjectFiles(const objectRegistry& obr, const word& prefix); + + //- Construct from components + functionObjectFiles + ( + const objectRegistry& obr, + const word& prefix, + const word& name + ); + + //- Construct from components + functionObjectFiles + ( + const objectRegistry& obr, + const word& prefix, + const wordList& names + ); + + + //- Destructor + virtual ~functionObjectFiles(); + + + // Member Functions + + //- 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& files(); + + //- Return file 'i' + OFstream& file(const label i); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C index 608f1a6275..902c79d0cf 100644 --- a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C +++ b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,7 +57,7 @@ Foam::cloudInfo::cloudInfo const bool loadFromFiles ) : - functionObjectFile(obr, name), + functionObjectFiles(obr, name), name_(name), obr_(obr), active_(true) @@ -78,7 +78,7 @@ void Foam::cloudInfo::read(const dictionary& dict) { if (active_) { - functionObjectFile::resetNames(dict.lookup("clouds")); + functionObjectFiles::resetNames(dict.lookup("clouds")); Info<< type() << " " << name_ << ": "; if (names().size()) @@ -114,7 +114,7 @@ void Foam::cloudInfo::write() { if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); forAll(names(), i) { diff --git a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H index e5aeb089be..281ef26b82 100644 --- a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H +++ b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H @@ -72,7 +72,7 @@ SourceFiles #ifndef cloudInfo_H #define cloudInfo_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "PtrList.H" #include "pointFieldFwd.H" #include "volFields.H" @@ -94,7 +94,7 @@ class mapPolyMesh; class cloudInfo : - public functionObjectFile + public functionObjectFiles { protected: diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index f50bb2a673..6b0c43ef7b 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,7 +59,7 @@ Foam::fieldMinMax::fieldMinMax const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), active_(true), @@ -164,7 +164,7 @@ void Foam::fieldMinMax::write() { if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); if (!location_) writeTime(file()); if (log_) Info<< type() << " " << name_ << " output:" << nl; diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H index 92a48257e9..22583932a5 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -78,7 +78,7 @@ SourceFiles #ifndef fieldMinMax_H #define fieldMinMax_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "Switch.H" #include "vector.H" @@ -99,7 +99,7 @@ class mapPolyMesh; class fieldMinMax : - public functionObjectFile + public functionObjectFiles { public: diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index 8694a16c1b..f726a20109 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,7 +56,7 @@ void Foam::fieldValue::write() { if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); if (log_) Info<< type() << " " << name_ << " output:" << nl; } @@ -74,7 +74,7 @@ Foam::fieldValue::fieldValue const bool loadFromFiles ) : - functionObjectFile(obr, name, valueType), + functionObjectFiles(obr, name, valueType), name_(name), obr_(obr), dict_(dict), diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index 92606dea3c..3abda7336a 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -38,7 +38,7 @@ SourceFiles #ifndef fieldValue_H #define fieldValue_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "Switch.H" #include "OFstream.H" #include "dictionary.H" @@ -62,7 +62,7 @@ class mapPolyMesh; class fieldValue : - public functionObjectFile + public functionObjectFiles { protected: diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index e0420a61d2..32fd6ff41d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,7 +64,7 @@ Foam::fieldValues::fieldValueDelta::fieldValueDelta const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), loadFromFiles_(loadFromFiles), @@ -148,7 +148,7 @@ void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict) void Foam::fieldValues::fieldValueDelta::write() { - functionObjectFile::write(); + functionObjectFiles::write(); source1Ptr_->write(); source2Ptr_->write(); diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H index d408227bbc..17c68eab75 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -76,7 +76,7 @@ SourceFiles #ifndef fieldValueDelta_H #define fieldValueDelta_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "fieldValue.H" #include "autoPtr.H" @@ -94,7 +94,7 @@ namespace fieldValues class fieldValueDelta : - public functionObjectFile + public functionObjectFiles { public: //- Operation type enumeration diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.C b/src/postProcessing/functionObjects/field/histogram/histogram.C index 3f4e46eaab..79391d628e 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.C +++ b/src/postProcessing/functionObjects/field/histogram/histogram.C @@ -74,9 +74,8 @@ Foam::functionObjects::histogram::histogram const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFile(obr, typeName), name_(name), - obr_(obr), active_(true) { // Check if the available mesh is an fvMesh, otherwise deactivate @@ -94,6 +93,26 @@ Foam::functionObjects::histogram::histogram } +Foam::autoPtr +Foam::functionObjects::histogram::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + if (isA(obr)) + { + return autoPtr(new histogram(name, obr, dict)); + } + else + { + return autoPtr(); + } +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::functionObjects::histogram::~histogram() @@ -108,8 +127,7 @@ void Foam::functionObjects::histogram::read(const dictionary& dict) { dict.lookup("field") >> fieldName_; dict.lookup("max") >> max_; - min_ = 0.0; - dict.readIfPresent("min", min_); + min_ = dict.lookupOrDefault("min", 0); dict.lookup("nBins") >> nBins_; word format(dict.lookup("setFormat")); diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.H b/src/postProcessing/functionObjects/field/histogram/histogram.H index 8d0c367f84..c39552d8f6 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.H +++ b/src/postProcessing/functionObjects/field/histogram/histogram.H @@ -30,7 +30,7 @@ Group Description Write the volume-weighted histogram of a volScalarField. - Example of function object specification: + Example: \verbatim histogram1 { @@ -69,9 +69,9 @@ SourceFiles #ifndef functionObjects_histogram_H #define functionObjects_histogram_H -#include "functionObjectFile.H" #include "writer.H" #include "volFieldsFwd.H" +#include "functionObjectFile.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -79,6 +79,7 @@ namespace Foam { // Forward declaration of classes +class objectRegistry; class mapPolyMesh; class polyMesh; @@ -95,11 +96,9 @@ class histogram { // Private data - //- Name of this set of histogram objects + //- Name of this histogram word name_; - const objectRegistry& obr_; - //- on/off switch bool active_; @@ -153,6 +152,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + // Destructor diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 5b607baed6..a2b5cea4bd 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -322,7 +322,7 @@ Foam::regionSizeDistribution::regionSizeDistribution const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), active_(true), diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H index fb8e4b71dc..e994e5667a 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H @@ -106,7 +106,7 @@ SourceFiles #ifndef regionSizeDistribution_H #define regionSizeDistribution_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "pointFieldFwd.H" #include "writer.H" #include "Map.H" @@ -132,7 +132,7 @@ class polyMesh; class regionSizeDistribution : - public functionObjectFile + public functionObjectFiles { // Private data diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index f75de46e10..a6e6dd108f 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -199,7 +199,7 @@ void Foam::forceCoeffs::write() if (Pstream::master()) { - functionObjectFile::write(); + functionObjectFiles::write(); scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_; diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 6b7a3f5ffb..743dd1a27e 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -524,7 +524,7 @@ Foam::forces::forces const bool readFields ) : - functionObjectFile(obr, name, createFileNames(dict)), + functionObjectFiles(obr, name, createFileNames(dict)), name_(name), obr_(obr), active_(true), @@ -583,7 +583,7 @@ Foam::forces::forces const coordinateSystem& coordSys ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), active_(true), @@ -787,7 +787,7 @@ void Foam::forces::write() if (Pstream::master()) { - functionObjectFile::write(); + functionObjectFiles::write(); writeForces(); diff --git a/src/postProcessing/functionObjects/forces/forces/forces.H b/src/postProcessing/functionObjects/forces/forces/forces.H index fc9436583e..9770642526 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.H +++ b/src/postProcessing/functionObjects/forces/forces/forces.H @@ -113,7 +113,7 @@ SourceFiles #ifndef forces_H #define forces_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "coordinateSystem.H" #include "coordinateSystems.H" #include "primitiveFieldsFwd.H" @@ -141,7 +141,7 @@ class mapPolyMesh; class forces : - public functionObjectFile + public functionObjectFiles { protected: diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.C b/src/postProcessing/functionObjects/utilities/residuals/residuals.C index 1cea77a8e0..9c7eca1be0 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,7 +46,7 @@ Foam::residuals::residuals const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), active_(true), @@ -121,7 +121,7 @@ void Foam::residuals::write() { if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); if (Pstream::master()) { diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.H b/src/postProcessing/functionObjects/utilities/residuals/residuals.H index 11b77ff3d8..06192df6b5 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.H +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.H @@ -62,7 +62,7 @@ SourceFiles #ifndef residuals_H #define residuals_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "primitiveFieldsFwd.H" #include "volFieldsFwd.H" #include "HashSet.H" @@ -88,7 +88,7 @@ class mapPolyMesh; class residuals : - public functionObjectFile + public functionObjectFiles { protected: diff --git a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C index ab6bc0e487..d64abbf03c 100644 --- a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C +++ b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C @@ -99,7 +99,7 @@ Foam::wallShearStress::wallShearStress const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), active_(true), @@ -220,7 +220,7 @@ void Foam::wallShearStress::execute() if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); const fvMesh& mesh = refCast(obr_); @@ -279,7 +279,7 @@ void Foam::wallShearStress::write() { if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); const volVectorField& wallShearStress = obr_.lookupObject(type()); diff --git a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H index ba0d5752de..b99c08ad6f 100644 --- a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H +++ b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H @@ -73,10 +73,10 @@ SourceFiles #ifndef wallShearStress_H #define wallShearStress_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "volFieldsFwd.H" #include "Switch.H" -#include "OFstream.H" +#include "HashSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -96,7 +96,7 @@ class fvMesh; class wallShearStress : - public functionObjectFile + public functionObjectFiles { protected: diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C index 3fa8fb613b..d5242319e2 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -61,7 +61,7 @@ Foam::yPlus::yPlus const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFiles(obr, name, typeName), name_(name), obr_(obr), active_(true), @@ -128,7 +128,7 @@ void Foam::yPlus::execute() if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); const fvMesh& mesh = refCast(obr_); @@ -184,7 +184,7 @@ void Foam::yPlus::write() { if (active_) { - functionObjectFile::write(); + functionObjectFiles::write(); const volScalarField& yPlus = obr_.lookupObject(type()); diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H index a2a27bf022..e1653107cd 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,7 +40,7 @@ SourceFiles #ifndef yPlus_H #define yPlus_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "volFieldsFwd.H" #include "Switch.H" #include "OFstream.H" @@ -63,7 +63,7 @@ class fvMesh; class yPlus : - public functionObjectFile + public functionObjectFiles { // Private data diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C index 4ae994033c..39e5e308da 100644 --- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C +++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C @@ -56,7 +56,7 @@ Foam::moleFractions::moleFractions const bool loadFromFiles ) : - functionObjectFile(obr, name), + functionObjectFiles(obr, name), name_(name), mesh_(refCast(obr)) { diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H index fa158e4754..05c7fa416a 100644 --- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H +++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H @@ -60,7 +60,7 @@ SourceFiles #ifndef moleFractions_H #define moleFractions_H -#include "functionObjectFile.H" +#include "functionObjectFiles.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,7 +75,7 @@ namespace Foam template class moleFractions : - public functionObjectFile + public functionObjectFiles { // Private data