functionObjects::writeLocalObjects: Provides support for controlled writing of field
defined by functionObjects, e.g. wallHeatFlux, wallShearStress and yPlus. Patch contributed by Bruno Santos Resolves bug-report http://bugs.openfoam.org/view.php?id=2353
This commit is contained in:
@ -228,6 +228,8 @@ db/functionObjects/functionObject/functionObject.C
|
||||
db/functionObjects/functionObjectList/functionObjectList.C
|
||||
db/functionObjects/writeFile/writeFile.C
|
||||
db/functionObjects/logFiles/logFiles.C
|
||||
db/functionObjects/writeObjectsBase/writeObjectsBase.C
|
||||
db/functionObjects/writeLocalObjects/writeLocalObjects.C
|
||||
db/functionObjects/timeControl/timeControl.C
|
||||
db/functionObjects/timeControl/timeControlFunctionObject.C
|
||||
db/functionObjects/regionFunctionObject/regionFunctionObject.C
|
||||
|
||||
@ -0,0 +1,106 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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 "writeLocalObjects.H"
|
||||
#include "stringListOps.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::writeLocalObjects::resetLocalObjectName
|
||||
(
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
localObjectNames_.clear();
|
||||
localObjectNames_.append(name);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeLocalObjects::resetLocalObjectNames
|
||||
(
|
||||
const wordList& names
|
||||
)
|
||||
{
|
||||
localObjectNames_.clear();
|
||||
localObjectNames_.append(names);
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::functionObjects::writeLocalObjects::objectNames()
|
||||
{
|
||||
wordList names
|
||||
(
|
||||
subsetStrings(wordReListMatcher(writeObjectNames_), localObjectNames_)
|
||||
);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeLocalObjects::writeLocalObjects
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const Switch& log
|
||||
)
|
||||
:
|
||||
writeObjectsBase(obr, log),
|
||||
localObjectNames_()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeLocalObjects::~writeLocalObjects()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::wordList&
|
||||
Foam::functionObjects::writeLocalObjects::localObjectNames() const
|
||||
{
|
||||
return localObjectNames_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeLocalObjects::read(const dictionary& dict)
|
||||
{
|
||||
if (dict.found("objects"))
|
||||
{
|
||||
writeObjectsBase::read(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
resetWriteObjectName(wordRe(".*", wordRe::DETECT));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,160 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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::functionObjects::writeLocalObjects
|
||||
|
||||
Description
|
||||
FunctionObject base class for managing a list of objects on behalf of the
|
||||
inheriting function object, on when those should be written to disk.
|
||||
|
||||
FunctionObjects that inherit this class will receive the additional
|
||||
dictionary option \c objects which allows selecting which fields of the
|
||||
inherited function should be written to disk when \c write() is called.
|
||||
When \c objects is omitted, it will write all objects and when that list is
|
||||
empty, it will not write any of the inheriting function object's managed
|
||||
objects.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
<functionObjectName>
|
||||
{
|
||||
...
|
||||
objects (obj1 obj2);
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
objects | List of objects to be written | no | ".*"
|
||||
\endtable
|
||||
|
||||
Note: Regular expressions can also be used in \c objects.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::writeObjectsBase
|
||||
|
||||
SourceFiles
|
||||
writeLocalObjects.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_writeLocalObjects_H
|
||||
#define functionObjects_writeLocalObjects_H
|
||||
|
||||
#include "wordList.H"
|
||||
#include "writeObjectsBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class regIOobject;
|
||||
class Switch;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeLocalObjects Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeLocalObjects
|
||||
:
|
||||
public writeObjectsBase
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Object names that are handled on behalf of the inheritor
|
||||
wordList localObjectNames_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Reset the list of local object names from a single word
|
||||
void resetLocalObjectName(const word& name);
|
||||
|
||||
//- Reset the list of local object names from a wordList
|
||||
void resetLocalObjectNames(const wordList& names);
|
||||
|
||||
//- Get the list of field names to be written
|
||||
virtual wordList objectNames();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
writeLocalObjects(const writeLocalObjects&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const writeLocalObjects&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from objectRegistry and inheriting function object
|
||||
writeLocalObjects
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const Switch& logRef
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~writeLocalObjects();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return const access to the local object names
|
||||
const wordList& localObjectNames() const;
|
||||
|
||||
//- Read the list of objects to be written
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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 "writeObjectsBase.H"
|
||||
#include "Time.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::writeObjectsBase::resetWriteObjectName
|
||||
(
|
||||
const wordRe& name
|
||||
)
|
||||
{
|
||||
writeObjectNames_.clear();
|
||||
writeObjectNames_.append(name);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeObjectsBase::resetWriteObjectNames
|
||||
(
|
||||
const wordReList& names
|
||||
)
|
||||
{
|
||||
writeObjectNames_.clear();
|
||||
writeObjectNames_.append(names);
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::functionObjects::writeObjectsBase::objectNames()
|
||||
{
|
||||
DynamicList<word> allNames(writeObr_.toc().size());
|
||||
forAll(writeObjectNames_, i)
|
||||
{
|
||||
wordList names(writeObr_.names<regIOobject>(writeObjectNames_[i]));
|
||||
|
||||
if (names.size())
|
||||
{
|
||||
allNames.append(names);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Object " << writeObjectNames_[i] << " not found in "
|
||||
<< "database. Available objects:" << nl << writeObr_.sortedToc()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
return allNames;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeObjectsBase::writeObject
|
||||
(
|
||||
const regIOobject& obj
|
||||
)
|
||||
{
|
||||
if (log_) Info << " writing object " << obj.name() << endl;
|
||||
|
||||
obj.write();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeObjectsBase::writeObjectsBase
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const Switch& log
|
||||
)
|
||||
:
|
||||
writeObr_(obr),
|
||||
log_(log)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeObjectsBase::~writeObjectsBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::wordReList&
|
||||
Foam::functionObjects::writeObjectsBase::writeObjectNames() const
|
||||
{
|
||||
return writeObjectNames_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeObjectsBase::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("objects") >> writeObjectNames_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeObjectsBase::write()
|
||||
{
|
||||
wordList names(objectNames());
|
||||
|
||||
if(!names.empty())
|
||||
{
|
||||
if (!writeObr_.time().writeTime())
|
||||
{
|
||||
writeObr_.time().writeTimeDict();
|
||||
}
|
||||
|
||||
forAll(names, i)
|
||||
{
|
||||
const regIOobject& obj =
|
||||
writeObr_.lookupObject<regIOobject>(names[i]);
|
||||
|
||||
writeObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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::functionObjects::writeObjectsBase
|
||||
|
||||
Description
|
||||
FunctionObject base class for writing a list of objects registered to the
|
||||
database, on behalf of the inheriting function object, on when those should
|
||||
be written to disk.
|
||||
|
||||
FunctionObjects that inherit this class will receive the additional
|
||||
dictionary option \c objects which allows selecting which fields of the
|
||||
inherited function should be written to disk when \c write() is called.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
<functionObjectName>
|
||||
{
|
||||
...
|
||||
objects (obj1 obj2);
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
objects | List of objects to be written | yes |
|
||||
\endtable
|
||||
|
||||
Note: Regular expressions can also be used in \c objects.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::writeObjects
|
||||
Foam::functionObjects::writeLocalObjects
|
||||
|
||||
SourceFiles
|
||||
writeObjectsBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_writeObjectsBase_H
|
||||
#define functionObjects_writeObjectsBase_H
|
||||
|
||||
#include "wordList.H"
|
||||
#include "wordReList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class regIOobject;
|
||||
class Switch;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeObjectsBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeObjectsBase
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the region objectRegistry
|
||||
const objectRegistry& writeObr_;
|
||||
|
||||
//- Reference to the inheriting function object's log variable
|
||||
const Switch& log_;
|
||||
|
||||
//- Object names requested by the user to be written
|
||||
wordReList writeObjectNames_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Reset the list of object names to be written to a single regular
|
||||
// expression
|
||||
void resetWriteObjectName(const wordRe& name);
|
||||
|
||||
//- Reset the list of object names to be written
|
||||
void resetWriteObjectNames(const wordReList& names);
|
||||
|
||||
//- Get the list of field names to be written
|
||||
virtual wordList objectNames();
|
||||
|
||||
//- Write the requested registered IO object
|
||||
virtual void writeObject(const regIOobject& obj);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
writeObjectsBase(const writeObjectsBase&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const writeObjectsBase&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from objectRegistry and inheriting function object
|
||||
writeObjectsBase
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const Switch& logRef
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~writeObjectsBase();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return const access to the object names requested to be written
|
||||
const wordReList& writeObjectNames() const;
|
||||
|
||||
//- Read the list of objects to be written
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Write function
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -104,6 +104,7 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
logFiles(obr_, name),
|
||||
writeLocalObjects(obr_, log),
|
||||
patchSet_()
|
||||
{
|
||||
volScalarField* wallHeatFluxPtr
|
||||
@ -127,6 +128,7 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
resetLocalObjectName(typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -141,6 +143,7 @@ Foam::functionObjects::wallHeatFlux::~wallHeatFlux()
|
||||
bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeLocalObjects::read(dict);
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
@ -229,16 +232,15 @@ bool Foam::functionObjects::wallHeatFlux::execute()
|
||||
|
||||
bool Foam::functionObjects::wallHeatFlux::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
writeLocalObjects::write();
|
||||
|
||||
logFiles::write();
|
||||
|
||||
const volScalarField& wallHeatFlux =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Log << type() << " " << name() << " write:" << nl
|
||||
<< " writing field " << wallHeatFlux.name() << endl;
|
||||
|
||||
wallHeatFlux.write();
|
||||
|
||||
const fvPatchList& patches = mesh_.boundary();
|
||||
|
||||
const surfaceScalarField::Boundary& magSf =
|
||||
@ -249,8 +251,7 @@ bool Foam::functionObjects::wallHeatFlux::write()
|
||||
label patchi = iter.key();
|
||||
const fvPatch& pp = patches[patchi];
|
||||
|
||||
const scalarField& hfp =
|
||||
wallHeatFlux.boundaryField()[patchi];
|
||||
const scalarField& hfp = wallHeatFlux.boundaryField()[patchi];
|
||||
|
||||
const scalar minHfp = gMin(hfp);
|
||||
const scalar maxHfp = gMax(hfp);
|
||||
@ -267,10 +268,12 @@ bool Foam::functionObjects::wallHeatFlux::write()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Log << " min/max(" << pp.name() << ") = "
|
||||
Log << " min/max/integ(" << pp.name() << ") = "
|
||||
<< minHfp << ", " << maxHfp << ", " << integralHfp << endl;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -52,10 +52,15 @@ Usage
|
||||
patches | list of patches to process | no | all wall patches
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Writing field 'wallHeatFlux' is done by default, but it can be overridden by
|
||||
defining an empty \c objects list. For details see writeLocalObjects.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::logFiles
|
||||
Foam::functionObjects::writeLocalObjects
|
||||
Foam::functionObjects::pressureTools
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
@ -69,6 +74,7 @@ SourceFiles
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
#include "writeLocalObjects.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
@ -88,7 +94,8 @@ namespace functionObjects
|
||||
class wallHeatFlux
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public logFiles
|
||||
public logFiles,
|
||||
public writeLocalObjects
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
@ -90,6 +90,7 @@ Foam::functionObjects::wallShearStress::wallShearStress
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
logFiles(obr_, name),
|
||||
writeLocalObjects(obr_, log),
|
||||
patchSet_()
|
||||
{
|
||||
volVectorField* wallShearStressPtr
|
||||
@ -118,6 +119,7 @@ Foam::functionObjects::wallShearStress::wallShearStress
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
resetLocalObjectName(typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -132,6 +134,7 @@ Foam::functionObjects::wallShearStress::~wallShearStress()
|
||||
bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeLocalObjects::read(dict);
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
@ -225,16 +228,15 @@ bool Foam::functionObjects::wallShearStress::execute()
|
||||
|
||||
bool Foam::functionObjects::wallShearStress::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
writeLocalObjects::write();
|
||||
|
||||
logFiles::write();
|
||||
|
||||
const volVectorField& wallShearStress =
|
||||
obr_.lookupObject<volVectorField>(type());
|
||||
|
||||
Log << type() << " " << name() << " write:" << nl
|
||||
<< " writing field " << wallShearStress.name() << endl;
|
||||
|
||||
wallShearStress.write();
|
||||
|
||||
const fvPatchList& patches = mesh_.boundary();
|
||||
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
@ -260,6 +262,8 @@ bool Foam::functionObjects::wallShearStress::write()
|
||||
<< minSsp << ", " << maxSsp << endl;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -63,10 +63,15 @@ Usage
|
||||
patches | list of patches to process | no | all wall patches
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Writing field 'wallShearStress' is done by default, but it can be overridden
|
||||
by defining an empty \c objects list. For details see writeLocalObjects.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::logFiles
|
||||
Foam::functionObjects::writeLocalObjects
|
||||
Foam::functionObjects::pressureTools
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
@ -80,6 +85,7 @@ SourceFiles
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
#include "writeLocalObjects.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
@ -97,7 +103,8 @@ namespace functionObjects
|
||||
class wallShearStress
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public logFiles
|
||||
public logFiles,
|
||||
public writeLocalObjects
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
@ -121,7 +121,8 @@ Foam::functionObjects::yPlus::yPlus
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
logFiles(obr_, name)
|
||||
logFiles(obr_, name),
|
||||
writeLocalObjects(obr_, log)
|
||||
{
|
||||
volScalarField* yPlusPtr
|
||||
(
|
||||
@ -144,6 +145,7 @@ Foam::functionObjects::yPlus::yPlus
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
resetLocalObjectName(typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -158,6 +160,7 @@ Foam::functionObjects::yPlus::~yPlus()
|
||||
bool Foam::functionObjects::yPlus::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeLocalObjects::read(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -193,16 +196,15 @@ bool Foam::functionObjects::yPlus::execute()
|
||||
|
||||
bool Foam::functionObjects::yPlus::write()
|
||||
{
|
||||
const volScalarField& yPlus =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
Log << type() << " " << name() << " write:" << nl
|
||||
<< " writing field " << yPlus.name() << endl;
|
||||
|
||||
yPlus.write();
|
||||
writeLocalObjects::write();
|
||||
|
||||
logFiles::write();
|
||||
|
||||
const volScalarField& yPlus =
|
||||
mesh_.lookupObject<volScalarField>(type());
|
||||
|
||||
const volScalarField::Boundary& yPlusBf = yPlus.boundaryField();
|
||||
const fvPatchList& patches = mesh_.boundary();
|
||||
|
||||
@ -235,6 +237,8 @@ bool Foam::functionObjects::yPlus::write()
|
||||
}
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -29,12 +29,33 @@ Group
|
||||
|
||||
Description
|
||||
Evaluates and outputs turbulence y+ for models. Values written to
|
||||
time directories as field 'yPlus'
|
||||
time directories as field 'yPlus'.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
yPlus1
|
||||
{
|
||||
type yPlus;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: yPlus | yes |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Writing field 'yPlus' is done by default, but it can be overridden by
|
||||
defining an empty \c objects list. For details see writeLocalObjects.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::logFiles
|
||||
Foam::functionObjects::writeLocalObjects
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
@ -47,6 +68,7 @@ SourceFiles
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
#include "writeLocalObjects.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -67,7 +89,8 @@ namespace functionObjects
|
||||
class yPlus
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public logFiles
|
||||
public logFiles,
|
||||
public writeLocalObjects
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
|
||||
@ -64,114 +64,20 @@ const Foam::NamedEnum
|
||||
> Foam::functionObjects::writeObjects::writeOptionNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeObjects::writeObjects
|
||||
void Foam::functionObjects::writeObjects::writeObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
const regIOobject& obj
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
writeOption_(ANY_WRITE),
|
||||
objectNames_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeObjects::~writeObjects()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
|
||||
{
|
||||
if (dict.found("field"))
|
||||
{
|
||||
objectNames_.setSize(1);
|
||||
dict.lookup("field") >> objectNames_[0];
|
||||
}
|
||||
else if (dict.found("fields"))
|
||||
{
|
||||
dict.lookup("fields") >> objectNames_;
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.lookup("objects") >> objectNames_;
|
||||
}
|
||||
|
||||
if (dict.found("writeOption"))
|
||||
{
|
||||
writeOption_ = writeOptionNames_.read(dict.lookup("writeOption"));
|
||||
}
|
||||
else
|
||||
{
|
||||
writeOption_ = ANY_WRITE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeObjects::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeObjects::write()
|
||||
{
|
||||
Info<< type() << " " << name() << " write:" << nl;
|
||||
|
||||
if (!obr_.time().writeTime())
|
||||
{
|
||||
obr_.time().writeTimeDict();
|
||||
}
|
||||
|
||||
DynamicList<word> allNames(obr_.toc().size());
|
||||
forAll(objectNames_, i)
|
||||
{
|
||||
wordList names(obr_.names<regIOobject>(objectNames_[i]));
|
||||
|
||||
if (names.size())
|
||||
{
|
||||
allNames.append(names);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Object " << objectNames_[i] << " not found in "
|
||||
<< "database. Available objects:" << nl << obr_.sortedToc()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
forAll(allNames, i)
|
||||
{
|
||||
regIOobject& obj = const_cast<regIOobject&>
|
||||
(
|
||||
obr_.lookupObject<regIOobject>(allNames[i])
|
||||
);
|
||||
|
||||
switch (writeOption_)
|
||||
{
|
||||
case AUTO_WRITE:
|
||||
{
|
||||
if(obj.writeOpt() != IOobject::AUTO_WRITE)
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -180,7 +86,7 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
{
|
||||
if(obj.writeOpt() != IOobject::NO_WRITE)
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -202,18 +108,92 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
if
|
||||
(
|
||||
obj.writeOpt() == IOobject::AUTO_WRITE
|
||||
&& obr_.time().writeTime()
|
||||
&& writeObr_.time().writeTime()
|
||||
)
|
||||
{
|
||||
Info<< " automatically written object " << obj.name() << endl;
|
||||
Log << " automatically written object " << obj.name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " writing object " << obj.name() << endl;
|
||||
writeObjectsBase::writeObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
obj.write();
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeObjects::writeObjects
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
writeObjectsBase
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
),
|
||||
log
|
||||
),
|
||||
writeOption_(ANY_WRITE)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::writeObjects::~writeObjects()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
|
||||
{
|
||||
if (dict.found("field"))
|
||||
{
|
||||
writeObjectNames_.setSize(1);
|
||||
dict.lookup("field") >> writeObjectNames_[0];
|
||||
}
|
||||
else if (dict.found("fields"))
|
||||
{
|
||||
dict.lookup("fields") >> writeObjectNames_;
|
||||
}
|
||||
else
|
||||
{
|
||||
writeObjectsBase::read(dict);
|
||||
}
|
||||
|
||||
if (dict.found("writeOption"))
|
||||
{
|
||||
writeOption_ = writeOptionNames_.read(dict.lookup("writeOption"));
|
||||
}
|
||||
else
|
||||
{
|
||||
writeOption_ = ANY_WRITE;
|
||||
}
|
||||
|
||||
return functionObject::read(dict);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeObjects::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeObjects::write()
|
||||
{
|
||||
Info<< type() << " " << name() << " write:" << nl;
|
||||
|
||||
writeObjectsBase::write();
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ Usage
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::writeObjectsBase
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
@ -83,7 +84,7 @@ SourceFiles
|
||||
#define functionObjects_writeObjects_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordReList.H"
|
||||
#include "writeObjectsBase.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -91,9 +92,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -103,7 +101,8 @@ namespace functionObjects
|
||||
|
||||
class writeObjects
|
||||
:
|
||||
public functionObject
|
||||
public functionObject,
|
||||
public writeObjectsBase
|
||||
{
|
||||
public:
|
||||
|
||||
@ -124,18 +123,15 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to Db
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- To only write objects of defined writeOption
|
||||
writeOption writeOption_;
|
||||
|
||||
//- Names of objects to control
|
||||
wordReList objectNames_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write the requested registered IO object
|
||||
virtual void writeObject(const regIOobject& obj);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
writeObjects(const writeObjects&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user