Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2012-03-09 09:12:30 +00:00
5 changed files with 68 additions and 44 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -134,17 +134,17 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
int dir = 2*direction_ - 1; int dir = 2*direction_ - 1;
// Average volumetric flow rate // Average volumetric flow rate
scalar aveFlowRate = 0; scalar volFlowRate = 0;
if (phi.dimensions() == dimVelocity*dimArea) if (phi.dimensions() == dimVelocity*dimArea)
{ {
aveFlowRate = dir*gSum(phip)/gSum(patch().magSf()); volFlowRate = dir*gSum(phip);
} }
else if (phi.dimensions() == dimVelocity*dimArea*dimDensity) else if (phi.dimensions() == dimVelocity*dimArea*dimDensity)
{ {
const scalarField& rhop = const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName()); patch().lookupPatchField<volScalarField, scalar>(rhoName());
aveFlowRate = dir*gSum(phip/rhop)/gSum(patch().magSf()); volFlowRate = dir*gSum(phip/rhop);
} }
else else
{ {
@ -157,7 +157,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
} }
// Pressure drop for this flow rate // Pressure drop for this flow rate
const scalar pdFan = fanCurve_(max(aveFlowRate, 0.0)); const scalar pdFan = fanCurve_(max(volFlowRate, 0.0));
totalPressureFvPatchScalarField::updateCoeffs totalPressureFvPatchScalarField::updateCoeffs
( (

View File

@ -79,14 +79,6 @@ void Foam::removeRegisteredObject::execute()
delete &obj; delete &obj;
} }
} }
else
{
WarningIn("Foam::removeRegisteredObject::write()")
<< "Object " << objectNames_[i] << " not found in "
<< "database. Available objects:" << nl << obr_.sortedToc()
<< endl;
}
} }
} }

View File

@ -85,20 +85,6 @@ bool Foam::turbulenceFields::compressible()
} }
Foam::IOobject Foam::turbulenceFields::io(const word& fieldName) const
{
return
IOobject
(
fieldName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::turbulenceFields::turbulenceFields Foam::turbulenceFields::turbulenceFields
@ -147,7 +133,22 @@ void Foam::turbulenceFields::read(const dictionary& dict)
{ {
if (active_) if (active_)
{ {
dict.lookup("fields") >> fieldSet_; fieldSet_.insert(wordList(dict.lookup("fields")));
Info<< type() << ": ";
if (fieldSet_.size())
{
Info<< "storing fields:" << nl;
forAllConstIter(wordHashSet, fieldSet_, iter)
{
Info<< " " << modelName << "::" << iter.key() << nl;
}
Info<< endl;
}
else
{
Info<< "no fields requested to be stored" << nl << endl;
}
execute(); execute();
} }
@ -168,9 +169,9 @@ void Foam::turbulenceFields::execute()
const compressible::turbulenceModel& model = const compressible::turbulenceModel& model =
obr_.lookupObject<compressible::turbulenceModel>(modelName); obr_.lookupObject<compressible::turbulenceModel>(modelName);
forAll(fieldSet_, fieldI) forAllConstIter(wordHashSet, fieldSet_, iter)
{ {
const word& f = fieldSet_[fieldI]; const word& f = iter.key();
switch (compressibleFieldNames_[f]) switch (compressibleFieldNames_[f])
{ {
case cfR: case cfR:
@ -216,9 +217,9 @@ void Foam::turbulenceFields::execute()
const incompressible::turbulenceModel& model = const incompressible::turbulenceModel& model =
obr_.lookupObject<incompressible::turbulenceModel>(modelName); obr_.lookupObject<incompressible::turbulenceModel>(modelName);
forAll(fieldSet_, fieldI) forAllConstIter(wordHashSet, fieldSet_, iter)
{ {
const word& f = fieldSet_[fieldI]; const word& f = iter.key();
switch (incompressibleFieldNames_[f]) switch (incompressibleFieldNames_[f])
{ {
case ifR: case ifR:

View File

@ -27,16 +27,20 @@ Class
Description Description
Stores turbulence fields on the mesh database for further manipulation. Stores turbulence fields on the mesh database for further manipulation.
Fields are stored as copies of the original, with the prefix
"tubulenceModel::", e.g.
turbulenceModel::R
SourceFiles SourceFiles
turbulenceFields.C turbulenceFields.C
IOturbulenceFields.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef turbulenceFields_H #ifndef turbulenceFields_H
#define turbulenceFields_H #define turbulenceFields_H
#include "wordList.H" #include "HashSet.H"
#include "IOobject.H" #include "IOobject.H"
#include "NamedEnum.H" #include "NamedEnum.H"
#include "pointField.H" #include "pointField.H"
@ -96,7 +100,7 @@ protected:
bool active_; bool active_;
//- Fields to load //- Fields to load
wordList fieldSet_; wordHashSet fieldSet_;
// Protected Member Functions // Protected Member Functions
@ -110,15 +114,12 @@ protected:
//- Return true if compressible turbulence model is identified //- Return true if compressible turbulence model is identified
bool compressible(); bool compressible();
//- Helper function to return IOobject
IOobject io(const word& fieldName) const;
//- Process the turbulence field //- Process the turbulence field
template<class Type> template<class Type>
void processField void processField
( (
const word& fieldName, const word& fieldName,
const GeometricField<Type, fvPatchField, volMesh>& value const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue
); );

View File

@ -31,19 +31,49 @@ template<class Type>
void Foam::turbulenceFields::processField void Foam::turbulenceFields::processField
( (
const word& fieldName, const word& fieldName,
const GeometricField<Type, fvPatchField, volMesh>& value const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType; typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
if (obr_.foundObject<FieldType>(fieldName))
const word scopedName = modelName + "::" + fieldName;
if (obr_.foundObject<FieldType>(scopedName))
{ {
FieldType& fld = FieldType& fld =
const_cast<FieldType&>(obr_.lookupObject<FieldType>(fieldName)); const_cast<FieldType&>(obr_.lookupObject<FieldType>(scopedName));
fld == value; fld == tvalue();
}
else if (obr_.found(scopedName))
{
WarningIn
(
"void Foam::turbulenceFields::processField"
"("
"const word&, "
"const tmp<GeometricField<Type, fvPatchField, volMesh> >&"
")"
) << "Cannot store turbulence field " << scopedName
<< " since an object with that name already exists"
<< nl << endl;
} }
else else
{ {
obr_.store(new FieldType(io(fieldName), value)); obr_.store
(
new FieldType
(
IOobject
(
scopedName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
tvalue
)
);
} }
} }