GIT: Resolve merge conflict

This commit is contained in:
andy
2016-04-22 13:31:37 +01:00
22 changed files with 378 additions and 250 deletions

View File

@ -69,9 +69,9 @@ dimensionedScalar rhoMin
); );
Info<< "Creating turbulence model\n" << endl; Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::RASModel> turbulence autoPtr<compressible::turbulenceModel> turbulence
( (
compressible::New<compressible::RASModel> compressible::turbulenceModel::New
( (
rho, rho,
U, U,

View File

@ -47,9 +47,9 @@ volVectorField U
#include "readTransportProperties.H" #include "readTransportProperties.H"
Info<< "Creating turbulence model\n" << endl; Info<< "Creating turbulence model\n" << endl;
autoPtr<incompressible::RASModel> turbulence autoPtr<incompressible::turbulenceModel> turbulence
( (
incompressible::New<incompressible::RASModel>(U, phi, laminarTransport) incompressible::turbulenceModel::New(U, phi, laminarTransport)
); );
// Kinematic density for buoyancy force // Kinematic density for buoyancy force

View File

@ -47,9 +47,9 @@ volVectorField U
#include "readTransportProperties.H" #include "readTransportProperties.H"
Info<< "Creating turbulence model\n" << endl; Info<< "Creating turbulence model\n" << endl;
autoPtr<incompressible::RASModel> turbulence autoPtr<incompressible::turbulenceModel> turbulence
( (
incompressible::New<incompressible::RASModel>(U, phi, laminarTransport) incompressible::turbulenceModel::New(U, phi, laminarTransport)
); );
// Kinematic density for buoyancy force // Kinematic density for buoyancy force

View File

@ -45,13 +45,41 @@ Description
#include "turbulentFluidThermoModel.H" #include "turbulentFluidThermoModel.H"
#include "wallDist.H" #include "wallDist.H"
#include "processorFvPatchField.H" #include "processorFvPatchField.H"
#include "zeroGradientFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// turbulence constants - file-scope // Turbulence constants - file-scope
static const scalar Cmu(0.09); static const scalar Cmu(0.09);
static const scalar kappa(0.41); static const scalar kappa(0.41);
Foam::tmp<Foam::volVectorField> createSimplifiedU(const volVectorField& U)
{
tmp<volVectorField> tU
(
new volVectorField
(
IOobject
(
"Udash",
U.mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ
),
U.mesh(),
dimensionedVector("0", dimVelocity, vector::zero),
zeroGradientFvPatchField<vector>::typeName
)
);
// Assign the internal value to the original field
tU() = U;
return tU;
}
void correctProcessorPatches(volScalarField& vf) void correctProcessorPatches(volScalarField& vf)
{ {
if (!Pstream::parRun()) if (!Pstream::parRun())
@ -62,7 +90,6 @@ void correctProcessorPatches(volScalarField& vf)
// Not possible to use correctBoundaryConditions on fields as they may // Not possible to use correctBoundaryConditions on fields as they may
// use local info as opposed to the constraint values employed here, // use local info as opposed to the constraint values employed here,
// but still need to update processor patches // but still need to update processor patches
volScalarField::GeometricBoundaryField& bf = vf.boundaryField(); volScalarField::GeometricBoundaryField& bf = vf.boundaryField();
forAll(bf, patchI) forAll(bf, patchI)
@ -83,73 +110,49 @@ void correctProcessorPatches(volScalarField& vf)
} }
template<class TurbulenceModel> void blendField
Foam::tmp<Foam::volScalarField> calcK
( (
TurbulenceModel& turbulence, const word& fieldName,
const volScalarField& mask, const fvMesh& mesh,
const volScalarField& nut, const scalarField& mask,
const volScalarField& y, const scalarField& boundaryLayerField
const dimensionedScalar& ybl,
const scalar Cmu,
const scalar kappa
) )
{ {
// Turbulence k IOobject fieldHeader
tmp<volScalarField> tk = turbulence->k(); (
volScalarField& k = tk(); fieldName,
scalar ck0 = pow025(Cmu)*kappa; mesh.time().timeName(),
k = (1 - mask)*k + mask*sqr(nut/(ck0*min(y, ybl))); mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (fieldHeader.headerOk())
{
volScalarField fld(fieldHeader, mesh);
scalarField& internalField = fld.internalField();
internalField = (1 - mask)*internalField + mask*boundaryLayerField;
fld.max(SMALL);
// Do not correct BC // Do not correct BC
// - operation may use inconsistent fields wrt these local manipulations // - operation may use inconsistent fields wrt these local
// k.correctBoundaryConditions(); // manipulations
correctProcessorPatches(k); //fld.correctBoundaryConditions();
correctProcessorPatches(fld);
Info<< "Writing k\n" << endl; Info<< "Writing " << fieldName << nl << endl;
k.write(); fld.write();
}
return tk;
} }
template<class TurbulenceModel> void calcOmegaField
Foam::tmp<Foam::volScalarField> calcEpsilon
(
TurbulenceModel& turbulence,
const volScalarField& mask,
const volScalarField& k,
const volScalarField& y,
const dimensionedScalar& ybl,
const scalar Cmu,
const scalar kappa
)
{
// Turbulence epsilon
tmp<volScalarField> tepsilon = turbulence->epsilon();
volScalarField& epsilon = tepsilon();
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
epsilon = (1 - mask)*epsilon + mask*ce0*k*sqrt(k)/min(y, ybl);
epsilon.max(SMALL);
// Do not correct BC
// - operation may use inconsistent fields wrt these local manipulations
// epsilon.correctBoundaryConditions();
correctProcessorPatches(epsilon);
Info<< "Writing epsilon\n" << endl;
epsilon.write();
return tepsilon;
}
void calcOmega
( (
const fvMesh& mesh, const fvMesh& mesh,
const volScalarField& mask, const scalarField& mask,
const volScalarField& k, const scalarField& kBL,
const volScalarField& epsilon const scalarField& epsilonBL
) )
{ {
// Turbulence omega // Turbulence omega
@ -166,9 +169,10 @@ void calcOmega
if (omegaHeader.typeHeaderOk<volScalarField>(true)) if (omegaHeader.typeHeaderOk<volScalarField>(true))
{ {
volScalarField omega(omegaHeader, mesh); volScalarField omega(omegaHeader, mesh);
dimensionedScalar k0("SMALL", k.dimensions(), SMALL); scalarField& internalField = omega.internalField();
omega = (1 - mask)*omega + mask*epsilon/(Cmu*k + k0); internalField =
(1 - mask)*internalField + mask*epsilonBL/(Cmu*kBL + SMALL);
omega.max(SMALL); omega.max(SMALL);
// Do not correct BC // Do not correct BC
@ -217,17 +221,25 @@ void setField
} }
void calcCompressible tmp<volScalarField> calcNut
( (
const fvMesh& mesh, const fvMesh& mesh,
const volScalarField& mask, const volVectorField& U
const volVectorField& U,
const volScalarField& y,
const dimensionedScalar& ybl
) )
{ {
const Time& runTime = mesh.time(); const Time& runTime = mesh.time();
if
(
IOobject
(
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
)
{
// Compressible
autoPtr<fluidThermo> pThermo(fluidThermo::New(mesh)); autoPtr<fluidThermo> pThermo(fluidThermo::New(mesh));
fluidThermo& thermo = pThermo(); fluidThermo& thermo = pThermo();
volScalarField rho(thermo.rho()); volScalarField rho(thermo.rho());
@ -247,38 +259,19 @@ void calcCompressible
) )
); );
// Calculate nut - reference nut is calculated by the turbulence model // Hack to correct nut
// on its construction // Note: in previous versions of the code, nut was initialised on
tmp<volScalarField> tnut = turbulence->nut(); // construction of the turbulence model. This is no longer the
// case for the Templated Turbulence models. The call to correct
// below will evolve the turbulence model equations and update nut,
// whereas only nut update is required. Need to revisit.
turbulence->correct();
volScalarField& nut = tnut(); return tmp<volScalarField>(new volScalarField(turbulence->nut()));
volScalarField S(mag(dev(symm(fvc::grad(U)))));
nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S;
// Do not correct BC - wall functions will 'undo' manipulation above
// by using nut from turbulence model
correctProcessorPatches(nut);
nut.write();
tmp<volScalarField> k =
calcK(turbulence, mask, nut, y, ybl, Cmu, kappa);
tmp<volScalarField> epsilon =
calcEpsilon(turbulence, mask, k, y, ybl, Cmu, kappa);
calcOmega(mesh, mask, k, epsilon);
setField(mesh, "nuTilda", nut);
} }
else
void calcIncompressible
(
const fvMesh& mesh,
const volScalarField& mask,
const volVectorField& U,
const volScalarField& y,
const dimensionedScalar& ybl
)
{ {
const Time& runTime = mesh.time(); // Incompressible
// Update/re-write phi // Update/re-write phi
#include "createPhi.H" #include "createPhi.H"
@ -291,25 +284,16 @@ void calcIncompressible
incompressible::turbulenceModel::New(U, phi, laminarTransport) incompressible::turbulenceModel::New(U, phi, laminarTransport)
); );
tmp<volScalarField> tnut = turbulence->nut(); // Hack to correct nut
// Note: in previous versions of the code, nut was initialised on
// construction of the turbulence model. This is no longer the
// case for the Templated Turbulence models. The call to correct
// below will evolve the turbulence model equations and update nut,
// whereas only nut update is required. Need to revisit.
turbulence->correct();
// Calculate nut - reference nut is calculated by the turbulence model return tmp<volScalarField>(new volScalarField(turbulence->nut()));
// on its construction }
volScalarField& nut = tnut();
volScalarField S(mag(dev(symm(fvc::grad(U)))));
nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S;
// Do not correct BC - wall functions will 'undo' manipulation above
// by using nut from turbulence model
correctProcessorPatches(nut);
nut.write();
tmp<volScalarField> k =
calcK(turbulence, mask, nut, y, ybl, Cmu, kappa);
tmp<volScalarField> epsilon =
calcEpsilon(turbulence, mask, k, y, ybl, Cmu, kappa);
calcOmega(mesh, mask, k, epsilon);
setField(mesh, "nuTilda", nut);
} }
@ -361,44 +345,60 @@ int main(int argc, char *argv[])
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Create a copy of the U field where BCs are simplified to zeroGradient
// to enable boundary condition update without requiring other fields,
// e.g. phi. We can then call correctBoundaryConditions on this field to
// enable appropriate behaviour for processor patches.
volVectorField Udash(createSimplifiedU(U));
// Modify velocity by applying a 1/7th power law boundary-layer // Modify velocity by applying a 1/7th power law boundary-layer
// u/U0 = (y/ybl)^(1/7) // u/U0 = (y/ybl)^(1/7)
// assumes U0 is the same as the current cell velocity // assumes U0 is the same as the current cell velocity
Info<< "Setting boundary layer velocity" << nl << endl; Info<< "Setting boundary layer velocity" << nl << endl;
scalar yblv = ybl.value(); scalar yblv = ybl.value();
forAll(U, cellI) forAll(Udash, cellI)
{ {
if (y[cellI] <= yblv) if (y[cellI] <= yblv)
{ {
mask[cellI] = 1; mask[cellI] = 1;
U[cellI] *= ::pow(y[cellI]/yblv, (1.0/7.0)); Udash[cellI] *= ::pow(y[cellI]/yblv, (1.0/7.0));
} }
} }
mask.correctBoundaryConditions(); mask.correctBoundaryConditions();
Udash.correctBoundaryConditions();
// Retrieve nut from turbulence model
volScalarField nut(calcNut(mesh, Udash));
// Blend nut using boundary layer profile
volScalarField S("S", mag(dev(symm(fvc::grad(Udash)))));
nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S;
// Do not correct BC - wall functions will 'undo' manipulation above
// by using nut from turbulence model
correctProcessorPatches(nut);
nut.write();
// Boundary layer turbulence kinetic energy
scalar ck0 = pow025(Cmu)*kappa;
scalarField kBL(sqr(nut/(ck0*min(y, ybl))));
// Boundary layer turbulence dissipation
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
scalarField epsilonBL(ce0*kBL*sqrt(kBL)/min(y, ybl));
// Process fields if they are present
blendField("k", mesh, mask, kBL);
blendField("epsilon", mesh, mask, epsilonBL);
calcOmegaField(mesh, mask, kBL, epsilonBL);
setField(mesh, "nuTilda", nut);
// Copy internal field Udash into U before writing
Info<< "Writing U\n" << endl; Info<< "Writing U\n" << endl;
U = Udash;
U.write(); U.write();
if
(
IOobject
(
basicThermo::dictName,
runTime.constant(),
mesh
).typeHeaderOk<IOdictionary>(true)
)
{
calcCompressible(mesh, mask, U, y, ybl);
}
else
{
calcIncompressible(mesh, mask, U, y, ybl);
}
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl; << nl << endl;

View File

@ -38,7 +38,23 @@ volVectorField U
); );
Info<< "Calculating wall distance field" << endl; Info<< "Calculating wall distance field" << endl;
const volScalarField& y(wallDist::New(mesh).y()); volScalarField y
(
IOobject
(
"y",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimLength, 0.0),
zeroGradientFvPatchScalarField::typeName
);
y.internalField() = wallDist::New(mesh).y().internalField();
y.correctBoundaryConditions();
// Set the mean boundary-layer thickness // Set the mean boundary-layer thickness
dimensionedScalar ybl("ybl", dimLength, 0); dimensionedScalar ybl("ybl", dimLength, 0);

View File

@ -3,7 +3,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-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -66,7 +66,7 @@ Foam::functionObject* Foam::functionObjectList::remove
{ {
oldIndex = fnd(); oldIndex = fnd();
// retrieve the pointer and remove it from the old list // Retrieve the pointer and remove it from the old list
ptr = this->set(oldIndex, 0).ptr(); ptr = this->set(oldIndex, 0).ptr();
indices_.erase(fnd); indices_.erase(fnd);
} }
@ -124,6 +124,14 @@ Foam::functionObjectList::~functionObjectList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjectList::resetState()
{
// Reset (re-read) the state dictionary
stateDictPtr_.clear();
createStateDict();
}
Foam::IOdictionary& Foam::functionObjectList::stateDict() Foam::IOdictionary& Foam::functionObjectList::stateDict()
{ {
if (!stateDictPtr_.valid()) if (!stateDictPtr_.valid())
@ -177,7 +185,7 @@ void Foam::functionObjectList::on()
void Foam::functionObjectList::off() void Foam::functionObjectList::off()
{ {
// for safety, also force a read() when execution is turned back on // For safety, also force a read() when execution is turned back on
updated_ = execution_ = false; updated_ = execution_ = false;
} }
@ -200,6 +208,11 @@ bool Foam::functionObjectList::execute(const bool forceWrite)
if (execution_) if (execution_)
{ {
if (forceWrite)
{
resetState();
}
if (!updated_) if (!updated_)
{ {
read(); read();
@ -304,7 +317,7 @@ bool Foam::functionObjectList::read()
bool ok = true; bool ok = true;
updated_ = execution_; updated_ = execution_;
// avoid reading/initializing if execution is off // Avoid reading/initializing if execution is off
if (!execution_) if (!execution_)
{ {
return ok; return ok;
@ -328,7 +341,7 @@ bool Foam::functionObjectList::read()
if (entryPtr->isDict()) if (entryPtr->isDict())
{ {
// a dictionary of functionObjects // A dictionary of functionObjects
const dictionary& functionDicts = entryPtr->dict(); const dictionary& functionDicts = entryPtr->dict();
newPtrs.setSize(functionDicts.size()); newPtrs.setSize(functionDicts.size());
@ -336,7 +349,7 @@ bool Foam::functionObjectList::read()
forAllConstIter(dictionary, functionDicts, iter) forAllConstIter(dictionary, functionDicts, iter)
{ {
// safety: // Safety:
if (!iter().isDict()) if (!iter().isDict())
{ {
continue; continue;
@ -350,7 +363,7 @@ bool Foam::functionObjectList::read()
functionObject* objPtr = remove(key, oldIndex); functionObject* objPtr = remove(key, oldIndex);
if (objPtr) if (objPtr)
{ {
// an existing functionObject, and dictionary changed // An existing functionObject, and dictionary changed
if (newDigs[nFunc] != digests_[oldIndex]) if (newDigs[nFunc] != digests_[oldIndex])
{ {
ok = objPtr->read(dict) && ok; ok = objPtr->read(dict) && ok;
@ -358,7 +371,7 @@ bool Foam::functionObjectList::read()
} }
else else
{ {
// new functionObject // New functionObject
objPtr = functionObject::New(key, time_, dict).ptr(); objPtr = functionObject::New(key, time_, dict).ptr();
ok = objPtr->start() && ok; ok = objPtr->start() && ok;
} }
@ -370,7 +383,7 @@ bool Foam::functionObjectList::read()
} }
else else
{ {
// a list of functionObjects // A list of functionObjects
PtrList<entry> functionDicts(entryPtr->stream()); PtrList<entry> functionDicts(entryPtr->stream());
newPtrs.setSize(functionDicts.size()); newPtrs.setSize(functionDicts.size());
@ -378,7 +391,7 @@ bool Foam::functionObjectList::read()
forAllIter(PtrList<entry>, functionDicts, iter) forAllIter(PtrList<entry>, functionDicts, iter)
{ {
// safety: // Safety:
if (!iter().isDict()) if (!iter().isDict())
{ {
continue; continue;
@ -392,7 +405,7 @@ bool Foam::functionObjectList::read()
functionObject* objPtr = remove(key, oldIndex); functionObject* objPtr = remove(key, oldIndex);
if (objPtr) if (objPtr)
{ {
// an existing functionObject, and dictionary changed // An existing functionObject, and dictionary changed
if (newDigs[nFunc] != digests_[oldIndex]) if (newDigs[nFunc] != digests_[oldIndex])
{ {
ok = objPtr->read(dict) && ok; ok = objPtr->read(dict) && ok;
@ -400,7 +413,7 @@ bool Foam::functionObjectList::read()
} }
else else
{ {
// new functionObject // New functionObject
objPtr = functionObject::New(key, time_, dict).ptr(); objPtr = functionObject::New(key, time_, dict).ptr();
ok = objPtr->start() && ok; ok = objPtr->start() && ok;
} }
@ -411,11 +424,11 @@ bool Foam::functionObjectList::read()
} }
} }
// safety: // Safety:
newPtrs.setSize(nFunc); newPtrs.setSize(nFunc);
newDigs.setSize(nFunc); newDigs.setSize(nFunc);
// updating the PtrList of functionObjects also deletes any existing, // Updating the PtrList of functionObjects also deletes any existing,
// but unused functionObjects // but unused functionObjects
PtrList<functionObject>::transfer(newPtrs); PtrList<functionObject>::transfer(newPtrs);
digests_.transfer(newDigs); digests_.transfer(newDigs);

View File

@ -143,11 +143,14 @@ public:
//- Access to the functionObjects //- Access to the functionObjects
using PtrList<functionObject>::operator[]; using PtrList<functionObject>::operator[];
//- Reset/read state dictionary for current time
virtual void resetState();
//- Return the state dictionary //- Return the state dictionary
IOdictionary& stateDict(); virtual IOdictionary& stateDict();
//- Return const access to the state dictionary //- Return const access to the state dictionary
const IOdictionary& stateDict() const; virtual const IOdictionary& stateDict() const;
//- Clear the list of function objects //- Clear the list of function objects
virtual void clear(); virtual void clear();
@ -164,7 +167,6 @@ public:
//- Return the execution status (on/off) of the function objects //- Return the execution status (on/off) of the function objects
virtual bool status() const; virtual bool status() const;
//- Called at the start of the time-loop //- Called at the start of the time-loop
virtual bool start(); virtual bool start();

View File

@ -3,7 +3,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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,6 +28,19 @@ License
const Foam::word Foam::functionObjectState::resultsName_ = "results"; const Foam::word Foam::functionObjectState::resultsName_ = "results";
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
const Foam::IOdictionary& Foam::functionObjectState::stateDict() const
{
return obr_.time().functionObjects().stateDict();
}
Foam::IOdictionary& Foam::functionObjectState::stateDict()
{
return const_cast<IOdictionary&>(obr_.time().functionObjects().stateDict());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -39,11 +52,7 @@ Foam::functionObjectState::functionObjectState
: :
obr_(obr), obr_(obr),
name_(name), name_(name),
active_(true), active_(true)
stateDict_
(
const_cast<IOdictionary&>(obr.time().functionObjects().stateDict())
)
{} {}
@ -67,28 +76,26 @@ bool Foam::functionObjectState::active() const
} }
const Foam::IOdictionary& Foam::functionObjectState::stateDict() const
{
return stateDict_;
}
Foam::dictionary& Foam::functionObjectState::propertyDict() Foam::dictionary& Foam::functionObjectState::propertyDict()
{ {
if (!stateDict_.found(name_)) IOdictionary& stateDict = this->stateDict();
if (!stateDict.found(name_))
{ {
stateDict_.add(name_, dictionary()); stateDict.add(name_, dictionary());
} }
return stateDict_.subDict(name_); return stateDict.subDict(name_);
} }
bool Foam::functionObjectState::foundProperty(const word& entryName) const bool Foam::functionObjectState::foundProperty(const word& entryName) const
{ {
if (stateDict_.found(name_)) const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(name_))
{ {
const dictionary& baseDict = stateDict_.subDict(name_); const dictionary& baseDict = stateDict.subDict(name_);
return baseDict.found(entryName); return baseDict.found(entryName);
} }
@ -109,10 +116,11 @@ Foam::word Foam::functionObjectState::objectResultType
) const ) const
{ {
word result = word::null; word result = word::null;
const IOdictionary& stateDict = this->stateDict();
if (stateDict_.found(resultsName_)) if (stateDict.found(resultsName_))
{ {
const dictionary& resultsDict = stateDict_.subDict(resultsName_); const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName)) if (resultsDict.found(objectName))
{ {
@ -147,9 +155,11 @@ Foam::List<Foam::word> Foam::functionObjectState::objectResultEntries
{ {
DynamicList<word> result(2); DynamicList<word> result(2);
if (stateDict_.found(resultsName_)) const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{ {
const dictionary& resultsDict = stateDict_.subDict(resultsName_); const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName)) if (resultsDict.found(objectName))
{ {

View File

@ -3,7 +3,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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,6 +65,15 @@ private:
const objectRegistry& obr_; const objectRegistry& obr_;
// Private Member Functions
//- Disallow default bitwise copy construct
functionObjectState(const functionObjectState&);
//- Disallow default bitwise assignment
void operator=(const functionObjectState&);
protected: protected:
// Protected data // Protected data
@ -75,19 +84,15 @@ protected:
//- Flag to indicate whether the object is active //- Flag to indicate whether the object is active
bool active_; bool active_;
//- Reference to the state dictionary
IOdictionary& stateDict_;
// Protacted Member Functions
protected: //- Return a const reference to the state dictionary
const IOdictionary& stateDict() const;
// Protected Member Functions //- Return non-const access to the state dictionary
IOdictionary& stateDict();
//- Disallow default bitwise copy construct
functionObjectState(const functionObjectState&);
//- Disallow default bitwise assignment
void operator=(const functionObjectState&);
public: public:
@ -95,11 +100,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
functionObjectState functionObjectState(const objectRegistry& obr, const word& name);
(
const objectRegistry& obr,
const word& name
);
//- Destructor //- Destructor
@ -114,9 +115,6 @@ public:
//- Return the active flag //- Return the active flag
bool active() const; bool active() const;
//- Return access to the state dictionary
const IOdictionary& stateDict() const;
//- Return access to the property dictionary //- Return access to the property dictionary
dictionary& propertyDict(); dictionary& propertyDict();

View File

@ -100,9 +100,11 @@ void Foam::functionObjectState::getObjectProperty
Type& value Type& value
) const ) const
{ {
if (stateDict_.found(objectName)) const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(objectName))
{ {
const dictionary& baseDict = stateDict_.subDict(objectName); const dictionary& baseDict = stateDict.subDict(objectName);
if (baseDict.found(entryName)) if (baseDict.found(entryName))
{ {
if (baseDict.isDict(entryName)) if (baseDict.isDict(entryName))
@ -126,12 +128,14 @@ void Foam::functionObjectState::setObjectProperty
const Type& value const Type& value
) )
{ {
if (!stateDict_.found(objectName)) IOdictionary& stateDict = this->stateDict();
if (!stateDict.found(objectName))
{ {
stateDict_.add(objectName, dictionary()); stateDict.add(objectName, dictionary());
} }
dictionary& baseDict = stateDict_.subDict(objectName); dictionary& baseDict = stateDict.subDict(objectName);
baseDict.add(entryName, value, true); baseDict.add(entryName, value, true);
} }
@ -155,12 +159,14 @@ void Foam::functionObjectState::setObjectResult
const Type& value const Type& value
) )
{ {
if (!stateDict_.found(resultsName_)) IOdictionary& stateDict = this->stateDict();
if (!stateDict.found(resultsName_))
{ {
stateDict_.add(resultsName_, dictionary()); stateDict.add(resultsName_, dictionary());
} }
dictionary& resultsDict = stateDict_.subDict(resultsName_); dictionary& resultsDict = stateDict.subDict(resultsName_);
if (!resultsDict.found(objectName)) if (!resultsDict.found(objectName))
{ {
@ -215,9 +221,11 @@ void Foam::functionObjectState::getObjectResult
Type& value Type& value
) const ) const
{ {
if (stateDict_.found(resultsName_)) const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{ {
const dictionary& resultsDict = stateDict_.subDict(resultsName_); const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName)) if (resultsDict.found(objectName))
{ {

View File

@ -62,9 +62,9 @@ Description
type compressible::turbulentTemperatureCoupledBaffleMixed; type compressible::turbulentTemperatureCoupledBaffleMixed;
Tnbr T; Tnbr T;
kappa lookup; kappa lookup;
KappaName kappa; kappaName kappa;
thicknessLayers (0.1 0.2 0.3 0.4); thicknessLayers (0.1 0.2 0.3 0.4);
kappaLayers (1 2 3 4) kappaLayers (1 2 3 4);
value uniform 300; value uniform 300;
} }
\endverbatim \endverbatim

View File

@ -55,7 +55,7 @@ Description
type compressible::turbulentTemperatureRadCoupledMixed; type compressible::turbulentTemperatureRadCoupledMixed;
Tnbr T; Tnbr T;
kappa lookup; kappa lookup;
KappaName kappa; kappaName kappa;
QrNbr Qr; // or none. Name of Qr field on neighbour region QrNbr Qr; // or none. Name of Qr field on neighbour region
Qr Qr; // or none. Name of Qr field on local region Qr Qr; // or none. Name of Qr field on local region
thicknessLayers (0.1 0.2 0.3 0.4); thicknessLayers (0.1 0.2 0.3 0.4);

View File

@ -3,7 +3,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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -457,7 +457,29 @@ tmp<volScalarField> SpalartAllmarasDES<BasicTurbulenceModel>::k() const
{ {
const volScalarField chi(this->chi()); const volScalarField chi(this->chi());
const volScalarField fv1(this->fv1(chi)); const volScalarField fv1(this->fv1(chi));
return sqr(this->nut()/ck_/dTilda(chi, fv1, fvc::grad(this->U_)));
tmp<volScalarField> tdTilda
(
new volScalarField
(
IOobject
(
"dTilda",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh_,
dimensionedScalar("0", dimLength, 0.0),
zeroGradientFvPatchField<vector>::typeName
)
);
volScalarField& dTildaF = tdTilda();
dTildaF = dTilda(chi, fv1, fvc::grad(this->U_));
dTildaF.correctBoundaryConditions();
return sqr(this->nut()/ck_/dTildaF);
} }

View File

@ -3,7 +3,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) 2013-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -94,7 +94,7 @@ tmp<volScalarField> LESeddyViscosity<BasicTurbulenceModel>::epsilon() const
{ {
tmp<volScalarField> tk(this->k()); tmp<volScalarField> tk(this->k());
return tmp<volScalarField> tmp<volScalarField> tepsilon
( (
new volScalarField new volScalarField
( (
@ -106,9 +106,14 @@ tmp<volScalarField> LESeddyViscosity<BasicTurbulenceModel>::epsilon() const
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
Ce_*tk()*sqrt(tk())/this->delta() Ce_*tk()*sqrt(tk())/this->delta(),
zeroGradientFvPatchScalarField::typeName
) )
); );
volScalarField& epsilon = tepsilon();
epsilon.correctBoundaryConditions();
return tepsilon;
} }

View File

@ -300,6 +300,11 @@ tmp<volScalarField> SpalartAllmaras<BasicTurbulenceModel>::DnuTildaEff() const
template<class BasicTurbulenceModel> template<class BasicTurbulenceModel>
tmp<volScalarField> SpalartAllmaras<BasicTurbulenceModel>::k() const tmp<volScalarField> SpalartAllmaras<BasicTurbulenceModel>::k() const
{ {
WarningInFunction
<< "Turbulence kinetic energy not defined for "
<< "Spalart-Allmaras model. Returning zero field"
<< endl;
return tmp<volScalarField> return tmp<volScalarField>
( (
new volScalarField new volScalarField
@ -311,7 +316,8 @@ tmp<volScalarField> SpalartAllmaras<BasicTurbulenceModel>::k() const
this->mesh_ this->mesh_
), ),
this->mesh_, this->mesh_,
dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0) dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0),
zeroGradientFvPatchField<vector>::typeName
) )
); );
} }
@ -336,7 +342,8 @@ tmp<volScalarField> SpalartAllmaras<BasicTurbulenceModel>::epsilon() const
this->mesh_ this->mesh_
), ),
this->mesh_, this->mesh_,
dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0) dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0),
zeroGradientFvPatchField<vector>::typeName
) )
); );
} }

View File

@ -46,7 +46,9 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
uniformJumpFvPatchField<Type>(p, iF) uniformJumpFvPatchField<Type>(p, iF),
phiName_("phi"),
rhoName_("none")
{} {}
@ -59,7 +61,9 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
uniformJumpFvPatchField<Type>(ptf, p, iF, mapper) uniformJumpFvPatchField<Type>(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{} {}
@ -71,7 +75,9 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
uniformJumpFvPatchField<Type>(p, iF, dict) uniformJumpFvPatchField<Type>(p, iF, dict),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "none"))
{} {}
@ -81,7 +87,9 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
const fanFvPatchField<Type>& ptf const fanFvPatchField<Type>& ptf
) )
: :
uniformJumpFvPatchField<Type>(ptf) uniformJumpFvPatchField<Type>(ptf),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{} {}
@ -92,7 +100,9 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
uniformJumpFvPatchField<Type>(ptf, iF) uniformJumpFvPatchField<Type>(ptf, iF),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{} {}
@ -113,4 +123,13 @@ void Foam::fanFvPatchField<Type>::updateCoeffs()
} }
template<class Type>
void Foam::fanFvPatchField<Type>::write(Ostream& os) const
{
this->template writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
this->template writeEntryIfDifferent<word>(os, "rho", "none", rhoName_);
uniformJumpFvPatchField<Type>::write(os);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -187,6 +187,9 @@ public:
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -62,4 +62,8 @@ $(derivedConstraints)/fixedTemperatureConstraint/fixedTemperatureConstraint.C
$(derivedConstraints)/velocityDampingConstraint/velocityDampingConstraint.C $(derivedConstraints)/velocityDampingConstraint/velocityDampingConstraint.C
/* Corrections */
corrections/limitTemperature/limitTemperature.C
LIB = $(FOAM_LIBBIN)/libfvOptions LIB = $(FOAM_LIBBIN)/libfvOptions

View File

@ -3,7 +3,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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -348,7 +348,14 @@ bool Foam::scene::loop(vtkRenderer* renderer)
currentFrameI_++; currentFrameI_++;
position_ += currentFrameI_*dPosition_; if (position_ > (1 + 0.5*dPosition_))
{
WarningInFunction
<< "Current position exceeded 1 - please check your setup"
<< endl;
}
position_ += dPosition_;
if (currentFrameI_ < nFrameTotal_) if (currentFrameI_ < nFrameTotal_)
{ {

View File

@ -27,6 +27,9 @@ pressureTools/pressureToolsFunctionObject.C
Q/Q.C Q/Q.C
Q/QFunctionObject.C Q/QFunctionObject.C
residuals/residuals.C
residuals/residualsFunctionObject.C
scalarTransport/scalarTransport.C scalarTransport/scalarTransport.C
scalarTransport/scalarTransportFunctionObject.C scalarTransport/scalarTransportFunctionObject.C

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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -142,6 +142,14 @@ Foam::incompressibleTwoPhaseMixture::mu() const
} }
Foam::tmp<Foam::scalarField>
Foam::incompressibleTwoPhaseMixture::mu(const label patchI) const
{
return mu()().boundaryField()[patchI];
}
Foam::tmp<Foam::surfaceScalarField> Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleTwoPhaseMixture::muf() const Foam::incompressibleTwoPhaseMixture::muf() const
{ {

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-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -133,6 +133,9 @@ public:
//- Return the dynamic laminar viscosity //- Return the dynamic laminar viscosity
tmp<volScalarField> mu() const; tmp<volScalarField> mu() const;
//- Return the dynamic laminar viscosity on patch
tmp<scalarField> mu(const label patchI) const;
//- Return the face-interpolated dynamic laminar viscosity //- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> muf() const; tmp<surfaceScalarField> muf() const;