diff --git a/applications/solvers/compressible/rhoSimpleFoam/createFields.H b/applications/solvers/compressible/rhoSimpleFoam/createFields.H index 80f317cd85..61cea5c2e5 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoSimpleFoam/createFields.H @@ -69,9 +69,9 @@ dimensionedScalar rhoMin ); Info<< "Creating turbulence model\n" << endl; -autoPtr turbulence +autoPtr turbulence ( - compressible::New + compressible::turbulenceModel::New ( rho, U, diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H index b8d07b1f1a..0916e2788d 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H @@ -47,9 +47,9 @@ volVectorField U #include "readTransportProperties.H" Info<< "Creating turbulence model\n" << endl; -autoPtr turbulence +autoPtr turbulence ( - incompressible::New(U, phi, laminarTransport) + incompressible::turbulenceModel::New(U, phi, laminarTransport) ); // Kinematic density for buoyancy force diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H index 014bf8045c..e78daa67b3 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H @@ -47,9 +47,9 @@ volVectorField U #include "readTransportProperties.H" Info<< "Creating turbulence model\n" << endl; -autoPtr turbulence +autoPtr turbulence ( - incompressible::New(U, phi, laminarTransport) + incompressible::turbulenceModel::New(U, phi, laminarTransport) ); // Kinematic density for buoyancy force diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C index 2759555e07..017b42c0b1 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C +++ b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C @@ -45,13 +45,41 @@ Description #include "turbulentFluidThermoModel.H" #include "wallDist.H" #include "processorFvPatchField.H" +#include "zeroGradientFvPatchField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// turbulence constants - file-scope +// Turbulence constants - file-scope static const scalar Cmu(0.09); static const scalar kappa(0.41); + +Foam::tmp createSimplifiedU(const volVectorField& U) +{ + tmp tU + ( + new volVectorField + ( + IOobject + ( + "Udash", + U.mesh().time().timeName(), + U.mesh(), + IOobject::NO_READ + ), + U.mesh(), + dimensionedVector("0", dimVelocity, vector::zero), + zeroGradientFvPatchField::typeName + ) + ); + + // Assign the internal value to the original field + tU() = U; + + return tU; +} + + void correctProcessorPatches(volScalarField& vf) { if (!Pstream::parRun()) @@ -62,7 +90,6 @@ void correctProcessorPatches(volScalarField& vf) // Not possible to use correctBoundaryConditions on fields as they may // use local info as opposed to the constraint values employed here, // but still need to update processor patches - volScalarField::GeometricBoundaryField& bf = vf.boundaryField(); forAll(bf, patchI) @@ -83,73 +110,49 @@ void correctProcessorPatches(volScalarField& vf) } -template -Foam::tmp calcK +void blendField ( - TurbulenceModel& turbulence, - const volScalarField& mask, - const volScalarField& nut, - const volScalarField& y, - const dimensionedScalar& ybl, - const scalar Cmu, - const scalar kappa + const word& fieldName, + const fvMesh& mesh, + const scalarField& mask, + const scalarField& boundaryLayerField ) { - // Turbulence k - tmp tk = turbulence->k(); - volScalarField& k = tk(); - scalar ck0 = pow025(Cmu)*kappa; - k = (1 - mask)*k + mask*sqr(nut/(ck0*min(y, ybl))); + IOobject fieldHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); - // Do not correct BC - // - operation may use inconsistent fields wrt these local manipulations - // k.correctBoundaryConditions(); - correctProcessorPatches(k); + if (fieldHeader.headerOk()) + { + volScalarField fld(fieldHeader, mesh); + scalarField& internalField = fld.internalField(); + internalField = (1 - mask)*internalField + mask*boundaryLayerField; + fld.max(SMALL); - Info<< "Writing k\n" << endl; - k.write(); + // Do not correct BC + // - operation may use inconsistent fields wrt these local + // manipulations + //fld.correctBoundaryConditions(); + correctProcessorPatches(fld); - return tk; + Info<< "Writing " << fieldName << nl << endl; + fld.write(); + } } -template -Foam::tmp calcEpsilon -( - TurbulenceModel& turbulence, - const volScalarField& mask, - const volScalarField& k, - const volScalarField& y, - const dimensionedScalar& ybl, - const scalar Cmu, - const scalar kappa -) -{ - // Turbulence epsilon - tmp 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 +void calcOmegaField ( const fvMesh& mesh, - const volScalarField& mask, - const volScalarField& k, - const volScalarField& epsilon + const scalarField& mask, + const scalarField& kBL, + const scalarField& epsilonBL ) { // Turbulence omega @@ -166,9 +169,10 @@ void calcOmega if (omegaHeader.typeHeaderOk(true)) { 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); // Do not correct BC @@ -217,99 +221,79 @@ void setField } -void calcCompressible +tmp calcNut ( const fvMesh& mesh, - const volScalarField& mask, - const volVectorField& U, - const volScalarField& y, - const dimensionedScalar& ybl + const volVectorField& U ) { const Time& runTime = mesh.time(); - autoPtr pThermo(fluidThermo::New(mesh)); - fluidThermo& thermo = pThermo(); - volScalarField rho(thermo.rho()); - - // Update/re-write phi - #include "compressibleCreatePhi.H" - phi.write(); - - autoPtr turbulence + if ( - compressible::turbulenceModel::New + IOobject ( - rho, - U, - phi, - thermo - ) - ); + basicThermo::dictName, + runTime.constant(), + mesh + ).headerOk() + ) + { + // Compressible + autoPtr pThermo(fluidThermo::New(mesh)); + fluidThermo& thermo = pThermo(); + volScalarField rho(thermo.rho()); - // Calculate nut - reference nut is calculated by the turbulence model - // on its construction - tmp tnut = turbulence->nut(); + // Update/re-write phi + #include "compressibleCreatePhi.H" + phi.write(); - volScalarField& nut = tnut(); - volScalarField S(mag(dev(symm(fvc::grad(U))))); - nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S; + autoPtr turbulence + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) + ); - // Do not correct BC - wall functions will 'undo' manipulation above - // by using nut from turbulence model - correctProcessorPatches(nut); - nut.write(); + // 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(); - tmp k = - calcK(turbulence, mask, nut, y, ybl, Cmu, kappa); - tmp epsilon = - calcEpsilon(turbulence, mask, k, y, ybl, Cmu, kappa); - calcOmega(mesh, mask, k, epsilon); - setField(mesh, "nuTilda", nut); -} + return tmp(new volScalarField(turbulence->nut())); + } + else + { + // Incompressible + // Update/re-write phi + #include "createPhi.H" + phi.write(); -void calcIncompressible -( - const fvMesh& mesh, - const volScalarField& mask, - const volVectorField& U, - const volScalarField& y, - const dimensionedScalar& ybl -) -{ - const Time& runTime = mesh.time(); + singlePhaseTransportModel laminarTransport(U, phi); - // Update/re-write phi - #include "createPhi.H" - phi.write(); + autoPtr turbulence + ( + incompressible::turbulenceModel::New(U, phi, laminarTransport) + ); - singlePhaseTransportModel laminarTransport(U, phi); + // 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(); - autoPtr turbulence - ( - incompressible::turbulenceModel::New(U, phi, laminarTransport) - ); - - tmp tnut = turbulence->nut(); - - // Calculate nut - reference nut is calculated by the turbulence model - // 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 k = - calcK(turbulence, mask, nut, y, ybl, Cmu, kappa); - tmp epsilon = - calcEpsilon(turbulence, mask, k, y, ybl, Cmu, kappa); - calcOmega(mesh, mask, k, epsilon); - setField(mesh, "nuTilda", nut); + return tmp(new volScalarField(turbulence->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 // u/U0 = (y/ybl)^(1/7) // assumes U0 is the same as the current cell velocity - Info<< "Setting boundary layer velocity" << nl << endl; scalar yblv = ybl.value(); - forAll(U, cellI) + forAll(Udash, cellI) { if (y[cellI] <= yblv) { 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(); + 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; + U = Udash; U.write(); - - if - ( - IOobject - ( - basicThermo::dictName, - runTime.constant(), - mesh - ).typeHeaderOk(true) - ) - { - calcCompressible(mesh, mask, U, y, ybl); - } - else - { - calcIncompressible(mesh, mask, U, y, ybl); - } - - Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H index a5847f74ee..0adeb49b72 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H +++ b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H @@ -38,7 +38,23 @@ volVectorField U ); 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 dimensionedScalar ybl("ybl", dimLength, 0); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 7845c5fbc6..a66ef2893b 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ Foam::functionObject* Foam::functionObjectList::remove { 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(); indices_.erase(fnd); } @@ -124,6 +124,14 @@ Foam::functionObjectList::~functionObjectList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::functionObjectList::resetState() +{ + // Reset (re-read) the state dictionary + stateDictPtr_.clear(); + createStateDict(); +} + + Foam::IOdictionary& Foam::functionObjectList::stateDict() { if (!stateDictPtr_.valid()) @@ -177,7 +185,7 @@ void Foam::functionObjectList::on() 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; } @@ -200,6 +208,11 @@ bool Foam::functionObjectList::execute(const bool forceWrite) if (execution_) { + if (forceWrite) + { + resetState(); + } + if (!updated_) { read(); @@ -304,7 +317,7 @@ bool Foam::functionObjectList::read() bool ok = true; updated_ = execution_; - // avoid reading/initializing if execution is off + // Avoid reading/initializing if execution is off if (!execution_) { return ok; @@ -328,7 +341,7 @@ bool Foam::functionObjectList::read() if (entryPtr->isDict()) { - // a dictionary of functionObjects + // A dictionary of functionObjects const dictionary& functionDicts = entryPtr->dict(); newPtrs.setSize(functionDicts.size()); @@ -336,7 +349,7 @@ bool Foam::functionObjectList::read() forAllConstIter(dictionary, functionDicts, iter) { - // safety: + // Safety: if (!iter().isDict()) { continue; @@ -350,7 +363,7 @@ bool Foam::functionObjectList::read() functionObject* objPtr = remove(key, oldIndex); if (objPtr) { - // an existing functionObject, and dictionary changed + // An existing functionObject, and dictionary changed if (newDigs[nFunc] != digests_[oldIndex]) { ok = objPtr->read(dict) && ok; @@ -358,7 +371,7 @@ bool Foam::functionObjectList::read() } else { - // new functionObject + // New functionObject objPtr = functionObject::New(key, time_, dict).ptr(); ok = objPtr->start() && ok; } @@ -370,7 +383,7 @@ bool Foam::functionObjectList::read() } else { - // a list of functionObjects + // A list of functionObjects PtrList functionDicts(entryPtr->stream()); newPtrs.setSize(functionDicts.size()); @@ -378,7 +391,7 @@ bool Foam::functionObjectList::read() forAllIter(PtrList, functionDicts, iter) { - // safety: + // Safety: if (!iter().isDict()) { continue; @@ -392,7 +405,7 @@ bool Foam::functionObjectList::read() functionObject* objPtr = remove(key, oldIndex); if (objPtr) { - // an existing functionObject, and dictionary changed + // An existing functionObject, and dictionary changed if (newDigs[nFunc] != digests_[oldIndex]) { ok = objPtr->read(dict) && ok; @@ -400,7 +413,7 @@ bool Foam::functionObjectList::read() } else { - // new functionObject + // New functionObject objPtr = functionObject::New(key, time_, dict).ptr(); ok = objPtr->start() && ok; } @@ -411,11 +424,11 @@ bool Foam::functionObjectList::read() } } - // safety: + // Safety: newPtrs.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 PtrList::transfer(newPtrs); digests_.transfer(newDigs); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 6a46de6063..3a14a90e8d 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -143,11 +143,14 @@ public: //- Access to the functionObjects using PtrList::operator[]; + //- Reset/read state dictionary for current time + virtual void resetState(); + //- Return the state dictionary - IOdictionary& stateDict(); + virtual IOdictionary& stateDict(); //- Return const access to the state dictionary - const IOdictionary& stateDict() const; + virtual const IOdictionary& stateDict() const; //- Clear the list of function objects virtual void clear(); @@ -164,7 +167,6 @@ public: //- Return the execution status (on/off) of the function objects virtual bool status() const; - //- Called at the start of the time-loop virtual bool start(); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.C b/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.C index ce0b1c850f..3dc191cefe 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,19 @@ License 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(obr_.time().functionObjects().stateDict()); +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -39,11 +52,7 @@ Foam::functionObjectState::functionObjectState : obr_(obr), name_(name), - active_(true), - stateDict_ - ( - const_cast(obr.time().functionObjects().stateDict()) - ) + active_(true) {} @@ -67,28 +76,26 @@ bool Foam::functionObjectState::active() const } -const Foam::IOdictionary& Foam::functionObjectState::stateDict() const -{ - return stateDict_; -} - - 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 { - 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); } @@ -109,10 +116,11 @@ Foam::word Foam::functionObjectState::objectResultType ) const { 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)) { @@ -147,9 +155,11 @@ Foam::List Foam::functionObjectState::objectResultEntries { DynamicList 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)) { diff --git a/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.H b/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.H index c945451dac..6bf3ec4331 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectState.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,6 +65,15 @@ private: const objectRegistry& obr_; + // Private Member Functions + + //- Disallow default bitwise copy construct + functionObjectState(const functionObjectState&); + + //- Disallow default bitwise assignment + void operator=(const functionObjectState&); + + protected: // Protected data @@ -75,19 +84,15 @@ protected: //- Flag to indicate whether the object is 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: @@ -95,11 +100,7 @@ public: // Constructors //- Construct from components - functionObjectState - ( - const objectRegistry& obr, - const word& name - ); + functionObjectState(const objectRegistry& obr, const word& name); //- Destructor @@ -114,9 +115,6 @@ public: //- Return the active flag bool active() const; - //- Return access to the state dictionary - const IOdictionary& stateDict() const; - //- Return access to the property dictionary dictionary& propertyDict(); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectStateTemplates.C b/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectStateTemplates.C index f102eb0a4c..ef791f3547 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectStateTemplates.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectState/functionObjectStateTemplates.C @@ -100,9 +100,11 @@ void Foam::functionObjectState::getObjectProperty Type& value ) 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.isDict(entryName)) @@ -126,12 +128,14 @@ void Foam::functionObjectState::setObjectProperty 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); } @@ -155,12 +159,14 @@ void Foam::functionObjectState::setObjectResult 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)) { @@ -215,9 +221,11 @@ void Foam::functionObjectState::getObjectResult Type& value ) 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)) { diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H index 18d1d4cb4a..1b6668977c 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H @@ -62,9 +62,9 @@ Description type compressible::turbulentTemperatureCoupledBaffleMixed; Tnbr T; kappa lookup; - KappaName kappa; + kappaName kappa; thicknessLayers (0.1 0.2 0.3 0.4); - kappaLayers (1 2 3 4) + kappaLayers (1 2 3 4); value uniform 300; } \endverbatim diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H index 6bd2aaa6e9..77365b2aa6 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H @@ -55,7 +55,7 @@ Description type compressible::turbulentTemperatureRadCoupledMixed; Tnbr T; kappa lookup; - KappaName kappa; + kappaName kappa; QrNbr Qr; // or none. Name of Qr field on neighbour region Qr Qr; // or none. Name of Qr field on local region thicknessLayers (0.1 0.2 0.3 0.4); diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C index f5dce6ab61..3767153d78 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -457,7 +457,29 @@ tmp SpalartAllmarasDES::k() const { const volScalarField chi(this->chi()); const volScalarField fv1(this->fv1(chi)); - return sqr(this->nut()/ck_/dTilda(chi, fv1, fvc::grad(this->U_))); + + tmp 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::typeName + ) + ); + volScalarField& dTildaF = tdTilda(); + dTildaF = dTilda(chi, fv1, fvc::grad(this->U_)); + dTildaF.correctBoundaryConditions(); + + return sqr(this->nut()/ck_/dTildaF); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESeddyViscosity/LESeddyViscosity.C b/src/TurbulenceModels/turbulenceModels/LES/LESeddyViscosity/LESeddyViscosity.C index 2a58c71e35..d867084917 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESeddyViscosity/LESeddyViscosity.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESeddyViscosity/LESeddyViscosity.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -94,7 +94,7 @@ tmp LESeddyViscosity::epsilon() const { tmp tk(this->k()); - return tmp + tmp tepsilon ( new volScalarField ( @@ -106,9 +106,14 @@ tmp LESeddyViscosity::epsilon() const IOobject::NO_READ, IOobject::NO_WRITE ), - Ce_*tk()*sqrt(tk())/this->delta() + Ce_*tk()*sqrt(tk())/this->delta(), + zeroGradientFvPatchScalarField::typeName ) ); + volScalarField& epsilon = tepsilon(); + epsilon.correctBoundaryConditions(); + + return tepsilon; } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C index a029db7ad3..59a8ca1af3 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C @@ -300,6 +300,11 @@ tmp SpalartAllmaras::DnuTildaEff() const template tmp SpalartAllmaras::k() const { + WarningInFunction + << "Turbulence kinetic energy not defined for " + << "Spalart-Allmaras model. Returning zero field" + << endl; + return tmp ( new volScalarField @@ -311,7 +316,8 @@ tmp SpalartAllmaras::k() const this->mesh_ ), this->mesh_, - dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0) + dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0), + zeroGradientFvPatchField::typeName ) ); } @@ -336,7 +342,8 @@ tmp SpalartAllmaras::epsilon() const this->mesh_ ), this->mesh_, - dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0) + dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0), + zeroGradientFvPatchField::typeName ) ); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index 6885bd7d4d..eb38f7391a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -46,7 +46,9 @@ Foam::fanFvPatchField::fanFvPatchField const DimensionedField& iF ) : - uniformJumpFvPatchField(p, iF) + uniformJumpFvPatchField(p, iF), + phiName_("phi"), + rhoName_("none") {} @@ -59,7 +61,9 @@ Foam::fanFvPatchField::fanFvPatchField const fvPatchFieldMapper& mapper ) : - uniformJumpFvPatchField(ptf, p, iF, mapper) + uniformJumpFvPatchField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) {} @@ -71,7 +75,9 @@ Foam::fanFvPatchField::fanFvPatchField const dictionary& dict ) : - uniformJumpFvPatchField(p, iF, dict) + uniformJumpFvPatchField(p, iF, dict), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "none")) {} @@ -81,7 +87,9 @@ Foam::fanFvPatchField::fanFvPatchField const fanFvPatchField& ptf ) : - uniformJumpFvPatchField(ptf) + uniformJumpFvPatchField(ptf), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) {} @@ -92,7 +100,9 @@ Foam::fanFvPatchField::fanFvPatchField const DimensionedField& iF ) : - uniformJumpFvPatchField(ptf, iF) + uniformJumpFvPatchField(ptf, iF), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) {} @@ -113,4 +123,13 @@ void Foam::fanFvPatchField::updateCoeffs() } +template +void Foam::fanFvPatchField::write(Ostream& os) const +{ + this->template writeEntryIfDifferent(os, "phi", "phi", phiName_); + this->template writeEntryIfDifferent(os, "rho", "none", rhoName_); + uniformJumpFvPatchField::write(os); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H index fd27dfecd3..2ad75b1da6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H @@ -187,6 +187,9 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; }; diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files index a32c535177..e3778435f7 100644 --- a/src/fvOptions/Make/files +++ b/src/fvOptions/Make/files @@ -62,4 +62,8 @@ $(derivedConstraints)/fixedTemperatureConstraint/fixedTemperatureConstraint.C $(derivedConstraints)/velocityDampingConstraint/velocityDampingConstraint.C +/* Corrections */ + +corrections/limitTemperature/limitTemperature.C + LIB = $(FOAM_LIBBIN)/libfvOptions diff --git a/src/postProcessing/functionObjects/graphics/runTimePostProcessing/scene.C b/src/postProcessing/functionObjects/graphics/runTimePostProcessing/scene.C index 3ceace9695..c96e36566c 100644 --- a/src/postProcessing/functionObjects/graphics/runTimePostProcessing/scene.C +++ b/src/postProcessing/functionObjects/graphics/runTimePostProcessing/scene.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -348,7 +348,14 @@ bool Foam::scene::loop(vtkRenderer* renderer) 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_) { diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index f42510d7a5..1cee77173d 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -27,6 +27,9 @@ pressureTools/pressureToolsFunctionObject.C Q/Q.C Q/QFunctionObject.C +residuals/residuals.C +residuals/residualsFunctionObject.C + scalarTransport/scalarTransport.C scalarTransport/scalarTransportFunctionObject.C diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C index 3d59eda215..c79db9dc3d 100644 --- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C +++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.C @@ -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 @@ -142,6 +142,14 @@ Foam::incompressibleTwoPhaseMixture::mu() const } +Foam::tmp +Foam::incompressibleTwoPhaseMixture::mu(const label patchI) const +{ + + return mu()().boundaryField()[patchI]; +} + + Foam::tmp Foam::incompressibleTwoPhaseMixture::muf() const { diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.H b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.H index 6928f50b58..e867e5be75 100644 --- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.H +++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/incompressibleTwoPhaseMixture.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -133,6 +133,9 @@ public: //- Return the dynamic laminar viscosity tmp mu() const; + //- Return the dynamic laminar viscosity on patch + tmp mu(const label patchI) const; + //- Return the face-interpolated dynamic laminar viscosity tmp muf() const;