functionObjectFile: Separated into functionObjectFile and functionObjectFiles

functionObjectFile provides basic directory, file and formatting functions
functionObjectFiles provides multi-file cache
This commit is contained in:
Henry Weller
2016-04-30 09:18:42 +01:00
parent 3c61a1dbeb
commit 67e2d02800
33 changed files with 488 additions and 347 deletions

View File

@ -82,7 +82,7 @@ SeeAlso
#include "noiseFFT.H"
#include "argList.H"
#include "Time.H"
#include "functionObjectFile.H"
#include "functionObjectFiles.H"
#include "CSV.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -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

View File

@ -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_;

View File

@ -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
@ -126,15 +126,4 @@ bool Foam::functionObject::adjustTimeStep()
}
Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
(
const word& name,
Istream& is
) const
{
dictionary dict(is);
return functionObject::New(name, time_, dict);
}
// ************************************************************************* //

View File

@ -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<functionObject>(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<functionObject> operator()
(
const word& name,
Istream& is
) const;
};
// Selectors

View File

@ -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<int> 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::OFstream>& 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;

View File

@ -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<OFstream> 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<int> 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<OFstream>& files();
//- Return file 'i'
OFstream& file(const label i);
//- Write a commented string to stream
void writeCommented
(

View File

@ -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<class Type>

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#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::OFstream>& 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];
}
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
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<OFstream> 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<OFstream>& files();
//- Return file 'i'
OFstream& file(const label i);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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)
{

View File

@ -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:

View File

@ -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;

View File

@ -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:

View File

@ -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),

View File

@ -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:

View File

@ -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();

View File

@ -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

View File

@ -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>
Foam::functionObjects::histogram::New
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
if (isA<fvMesh>(obr))
{
return autoPtr<histogram>(new histogram(name, obr, dict));
}
else
{
return autoPtr<histogram>();
}
}
// * * * * * * * * * * * * * * * * 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<scalar>("min", 0);
dict.lookup("nBins") >> nBins_;
word format(dict.lookup("setFormat"));

View File

@ -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<histogram> New
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor

View File

@ -322,7 +322,7 @@ Foam::regionSizeDistribution::regionSizeDistribution
const bool loadFromFiles
)
:
functionObjectFile(obr, name, typeName),
functionObjectFiles(obr, name, typeName),
name_(name),
obr_(obr),
active_(true),

View File

@ -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

View File

@ -199,7 +199,7 @@ void Foam::forceCoeffs::write()
if (Pstream::master())
{
functionObjectFile::write();
functionObjectFiles::write();
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;

View File

@ -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();

View File

@ -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:

View File

@ -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())
{

View File

@ -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:

View File

@ -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<const fvMesh>(obr_);
@ -279,7 +279,7 @@ void Foam::wallShearStress::write()
{
if (active_)
{
functionObjectFile::write();
functionObjectFiles::write();
const volVectorField& wallShearStress =
obr_.lookupObject<volVectorField>(type());

View File

@ -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:

View File

@ -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<const fvMesh>(obr_);
@ -184,7 +184,7 @@ void Foam::yPlus::write()
{
if (active_)
{
functionObjectFile::write();
functionObjectFiles::write();
const volScalarField& yPlus =
obr_.lookupObject<volScalarField>(type());

View File

@ -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

View File

@ -56,7 +56,7 @@ Foam::moleFractions<ThermoType>::moleFractions
const bool loadFromFiles
)
:
functionObjectFile(obr, name),
functionObjectFiles(obr, name),
name_(name),
mesh_(refCast<const fvMesh>(obr))
{

View File

@ -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 ThermoType>
class moleFractions
:
public functionObjectFile
public functionObjectFiles
{
// Private data