ENH: Generalised faceSourceDelta function object to use any pair of field value function objects

This commit is contained in:
andy
2012-11-21 10:01:52 +00:00
parent f19c9098d9
commit dd1c6c4167
7 changed files with 99 additions and 77 deletions

View File

@ -10,12 +10,13 @@ fieldMinMax/fieldMinMax.C
fieldMinMax/fieldMinMaxFunctionObject.C
fieldValues/fieldValue/fieldValue.C
fieldValues/fieldValue/fieldValueNew.C
fieldValues/fieldValueDelta/fieldValueDelta.C
fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C
fieldValues/faceSource/faceSource.C
fieldValues/faceSource/faceSourceFunctionObject.C
fieldValues/cellSource/cellSource.C
fieldValues/cellSource/cellSourceFunctionObject.C
fieldValues/faceSourceDelta/faceSourceDelta.C
fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C
nearWallFields/nearWallFields.C
nearWallFields/nearWallFieldsFunctionObject.C

View File

@ -22,25 +22,25 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::IOfaceSourceDelta
Foam::IOfieldValueDelta
Description
Instance of the generic IOOutputFilter for faceSourceDelta.
Instance of the generic IOOutputFilter for fieldValueDelta.
\*---------------------------------------------------------------------------*/
#ifndef IOfaceSourceDelta_H
#define IOfaceSourceDelta_H
#ifndef IOfieldValueDelta_H
#define IOfieldValueDelta_H
#include "faceSourceDelta.H"
#include "fieldValueDelta.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<faceSourceDelta> IOfaceSourceDelta;
typedef IOOutputFilter<fieldValueDelta> IOfieldValueDelta;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,22 +23,23 @@ License
\*---------------------------------------------------------------------------*/
#include "faceSourceDelta.H"
#include "fieldValueDelta.H"
#include "ListOps.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::fieldValues::faceSourceDelta, 0);
defineTypeNameAndDebug(Foam::fieldValues::fieldValueDelta, 0);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValues::faceSourceDelta::updateMesh(const mapPolyMesh&)
void Foam::fieldValues::fieldValueDelta::updateMesh(const mapPolyMesh&)
{
// Do nothing
}
void Foam::fieldValues::faceSourceDelta::movePoints(const Field<point>&)
void Foam::fieldValues::fieldValueDelta::movePoints(const Field<point>&)
{
// Do nothing
}
@ -46,7 +47,7 @@ void Foam::fieldValues::faceSourceDelta::movePoints(const Field<point>&)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldValues::faceSourceDelta::faceSourceDelta
Foam::fieldValues::fieldValueDelta::fieldValueDelta
(
const word& name,
const objectRegistry& obr,
@ -55,31 +56,21 @@ Foam::fieldValues::faceSourceDelta::faceSourceDelta
)
:
functionObjectFile(obr, name, typeName),
name_(name),
obr_(obr),
loadFromFiles_(loadFromFiles),
log_(false),
faceSource1_
(
name + ".faceSource1",
obr,
dict.subDict("faceSource1"),
loadFromFiles
),
faceSource2_
(
name + ".faceSource2",
obr,
dict.subDict("faceSource2"),
loadFromFiles
)
source1Ptr_(NULL),
source2Ptr_(NULL)
{
read(dict);
}
void Foam::fieldValues::faceSourceDelta::writeFileHeader(const label i)
void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
{
const wordList& fields1 = faceSource1_.fields();
const wordList& fields2 = faceSource2_.fields();
const wordList& fields1 = source1Ptr_->fields();
const wordList& fields2 = source2Ptr_->fields();
DynamicList<word> commonFields(fields1.size());
forAll(fields1, i)
@ -104,26 +95,46 @@ void Foam::fieldValues::faceSourceDelta::writeFileHeader(const label i)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldValues::faceSourceDelta::~faceSourceDelta()
Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldValues::faceSourceDelta::read(const dictionary& dict)
void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
faceSource1_.read(dict.subDict("faceSource1"));
faceSource2_.read(dict.subDict("faceSource2"));
source1Ptr_.reset
(
fieldValue::New
(
name_ + ".source1",
obr_,
dict.subDict("source1"),
loadFromFiles_,
false
).ptr()
);
source2Ptr_.reset
(
fieldValue::New
(
name_ + ".source2",
obr_,
dict.subDict("source2"),
loadFromFiles_,
false
).ptr()
);
}
void Foam::fieldValues::faceSourceDelta::write()
void Foam::fieldValues::fieldValueDelta::write()
{
functionObjectFile::write();
faceSource1_.write();
faceSource2_.write();
source1Ptr_->write();
source2Ptr_->write();
if (Pstream::master())
{
@ -161,13 +172,13 @@ void Foam::fieldValues::faceSourceDelta::write()
}
void Foam::fieldValues::faceSourceDelta::execute()
void Foam::fieldValues::fieldValueDelta::execute()
{
// Do nothing
}
void Foam::fieldValues::faceSourceDelta::end()
void Foam::fieldValues::fieldValueDelta::end()
{
// Do nothing
}

View File

@ -22,26 +22,26 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fieldValues::faceSourceDelta
Foam::fieldValues::fieldValueDelta
Group
grpFieldFunctionObjects
Description
This function object provides a differencing option between two 'face
source' function objects.
This function object provides a differencing option between two 'field
value' function objects.
Example of function object specification:
\verbatim
faceSourceDelta1
fieldValueDelta1
{
type faceSourceDelta;
type fieldValueDelta;
functionObjectLibs ("libfieldFunctionObjects.so");
faceSource1
fieldValue1
{
...
}
faceSource2
fieldValue2
{
...
}
@ -51,22 +51,23 @@ Description
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: faceSourceDelta | yes |
type | type name: fieldValueDelta | yes |
\endtable
SeeAlso
Foam::faceSource
Foam::fieldValue
SourceFiles
faceSourceDelta.C
fieldValueDelta.C
\*---------------------------------------------------------------------------*/
#ifndef faceSourceDelta_H
#define faceSourceDelta_H
#ifndef fieldValueDelta_H
#define fieldValueDelta_H
#include "functionObjectFile.H"
#include "faceSource.H"
#include "fieldValue.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -77,10 +78,10 @@ namespace fieldValues
{
/*---------------------------------------------------------------------------*\
Class faceSourceDelta Declaration
Class fieldValueDelta Declaration
\*---------------------------------------------------------------------------*/
class faceSourceDelta
class fieldValueDelta
:
public functionObjectFile
{
@ -89,17 +90,23 @@ private:
// Private data
//- Name of this fieldValue object
word name_;
//- Database this class is registered to
const objectRegistry& obr_;
//- Flag to indicate to load from files
bool loadFromFiles_;
//- Switch to send output to Info as well as to file
Switch log_;
//- Face source 1
faceSource faceSource1_;
//- Field value source object 1
autoPtr<fieldValue> source1Ptr_;
//- Face source 2
faceSource faceSource2_;
//- Field value source object 2
autoPtr<fieldValue> source2Ptr_;
// Private Member Functions
@ -126,11 +133,11 @@ protected:
public:
//- Run-time type information
TypeName("faceSourceDelta");
TypeName("fieldValueDelta");
//- Construct from components
faceSourceDelta
fieldValueDelta
(
const word& name,
const objectRegistry& obr,
@ -140,7 +147,7 @@ public:
//- Destructor
virtual ~faceSourceDelta();
virtual ~fieldValueDelta();
// Public Member Functions
@ -169,7 +176,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "faceSourceDeltaTemplates.C"
#include "fieldValueDeltaTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "faceSourceDeltaFunctionObject.H"
#include "fieldValueDeltaFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -31,14 +31,14 @@ namespace Foam
{
defineNamedTemplateTypeNameAndDebug
(
faceSourceDeltaFunctionObject,
fieldValueDeltaFunctionObject,
0
);
addToRunTimeSelectionTable
(
functionObject,
faceSourceDeltaFunctionObject,
fieldValueDeltaFunctionObject,
dictionary
);
}

View File

@ -22,29 +22,29 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::faceSourceDeltaFunctionObject
Foam::fieldValueDeltaFunctionObject
Description
FunctionObject wrapper around faceSourceDelta to allow it to be
FunctionObject wrapper around fieldValueDelta to allow it to be
created via the functions entry within controlDict.
SourceFiles
faceSourceDeltaFunctionObject.C
fieldValueDeltaFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef faceSourceDeltaFunctionObject_H
#define faceSourceDeltaFunctionObject_H
#ifndef fieldValueDeltaFunctionObject_H
#define fieldValueDeltaFunctionObject_H
#include "faceSourceDelta.H"
#include "fieldValueDelta.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<fieldValues::faceSourceDelta>
faceSourceDeltaFunctionObject;
typedef OutputFilterFunctionObject<fieldValues::fieldValueDelta>
fieldValueDeltaFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,17 +23,20 @@ License
\*---------------------------------------------------------------------------*/
#include "GeometricField.H"
#include "volMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::fieldValues::faceSourceDelta::processFields(bool& found)
void Foam::fieldValues::fieldValueDelta::processFields(bool& found)
{
typedef GeometricField<Type, fvPatchField, volMesh> vf;
const wordList& fields1 = faceSource1_.fields();
const wordList& fields1 = source1Ptr_->fields();
const dictionary& results1 = faceSource1_.resultDict();
const dictionary& results2 = faceSource2_.resultDict();
const dictionary& results1 = source1Ptr_->resultDict();
const dictionary& results2 = source2Ptr_->resultDict();
Type r1(pTraits<Type>::zero);
Type r2(pTraits<Type>::zero);