diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.C b/src/turbulenceModels/RAS/compressible/LRR/LRR.C index 6ed98cc0a2..90c7f3ca17 100644 --- a/src/turbulenceModels/RAS/compressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -155,8 +157,8 @@ LRR::LRR ) ), - R_(autoCreateKQR("R", mesh_)), - k_(autoCreateKQR("k", mesh_)), + R_(autoCreateR("R", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index b81e36ee6e..89b5ab1f09 100644 --- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -30,6 +30,8 @@ License #include "wallDist.H" #include "wallDistReflection.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -190,7 +192,7 @@ LaunderGibsonRSTM::LaunderGibsonRSTM mesh_ ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files index b4d8e310c7..48106587e3 100644 --- a/src/turbulenceModels/RAS/compressible/Make/files +++ b/src/turbulenceModels/RAS/compressible/Make/files @@ -34,4 +34,6 @@ $(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C + LIB = $(FOAM_LIBBIN)/libcompressibleRASModels diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C index eedfc4fdcd..a38da49b0e 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C @@ -29,12 +29,6 @@ License #include "wallFvPatch.H" #include "fixedValueFvPatchFields.H" -// Headers reqd for back-porting wall function boundary conditions -#include "calculatedFvPatchField.H" -#include "mutWallFunctionFvPatchScalarField.H" -#include "epsilonWallFunctionFvPatchScalarField.H" -#include "omegaWallFunctionFvPatchScalarField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -58,128 +52,6 @@ void RASModel::printCoeffs() } -wordList RASModel::replaceWallBoundaryTypes -( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames -) const -{ - const fvBoundaryMesh& bm = mesh.boundary(); - - wordList boundaryTypes(bm.size()); - - forAll(bm, patchI) - { - if (isType(bm[patchI])) - { - boundaryTypes[patchI] = newTypeNames[patchI]; - } - else - { - boundaryTypes[patchI] = oldTypeNames[patchI]; - } - } - - return boundaryTypes; -} - - -tmp RASModel::autoCreateMut -( - const word& fieldName, - const fvMesh& mesh -) const -{ - IOobject mutHeader - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ); - - if (mutHeader.headerOk()) - { - return tmp(new volScalarField(mutHeader, mesh)); - } - else - { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; - - wordList mutBoundaryTypes = replaceWallBoundaryTypes - ( - mesh, - wordList - ( - mesh.boundary().size(), - calculatedFvPatchField::typeName - ), - wordList - ( - mesh.boundary().size(), - RASModels::mutWallFunctionFvPatchScalarField::typeName - ) - ); - - tmp mut - ( - new volScalarField - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), - mutBoundaryTypes - ) - ); - - Info<< " Writing updated " << fieldName << endl; - mut().write(); - - return mut; - } -} - - -tmp RASModel::autoCreateEpsilon -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::epsilonWallFunctionFvPatchScalarField::typeName - ); -} - - -tmp RASModel::autoCreateOmega -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::omegaWallFunctionFvPatchScalarField::typeName - ); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // RASModel::RASModel diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H index f614a0cd34..51b4e706da 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H @@ -58,10 +58,6 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" -// Headers reqd for back-porting wall function boundary conditions -#include "wallFvPatch.H" -#include "kQRWallFunctionFvPatchField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -111,57 +107,6 @@ protected: // Protected member functions - // Auto creation of fields to provide backwards compatibility with - // runtime selectable wall functions - - //- Replace old wall BCs with new wall function BCs - wordList replaceWallBoundaryTypes - ( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames - ) const; - - //- mut - tmp autoCreateMut - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- epsilon - tmp autoCreateEpsilon - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- omega - tmp autoCreateOmega - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- kQR - template - tmp > autoCreateKQR - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- Helper function to create the new field - template - tmp > - autoCreateWallFunctionField - ( - const word& fieldName, - const fvMesh& mesh, - const word& wallFunctionName - ) const; - - //- Print model coefficients virtual void printCoeffs(); @@ -382,12 +327,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "RASModelTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C index cdce325fb4..2930fb284f 100644 --- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -137,7 +139,7 @@ RNGkEpsilon::RNGkEpsilon ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C new file mode 100644 index 0000000000..fdf205b930 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "backwardsCompatibilityWallFunctions.H" + +#include "calculatedFvPatchField.H" +#include "mutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "kQRWallFunctionFvPatchField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +wordList replaceWallBoundaryTypes +( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames +) +{ + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList boundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + boundaryTypes[patchI] = newTypeNames[patchI]; + } + else + { + boundaryTypes[patchI] = oldTypeNames[patchI]; + } + } + + return boundaryTypes; +} + + +tmp autoCreateMut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject mutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (mutHeader.headerOk()) + { + return tmp(new volScalarField(mutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + wordList mutBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + wordList + ( + mesh.boundary().size(), + calculatedFvPatchField::typeName + ), + wordList + ( + mesh.boundary().size(), + RASModels::mutWallFunctionFvPatchScalarField::typeName + ) + ); + + tmp mut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + mutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + mut().write(); + + return mut; + } +} + + +tmp autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::epsilonWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::omegaWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateK +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateQ +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateR +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // + diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H new file mode 100644 index 0000000000..6650b79832 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible + +Description + Auto creation of fields to provide backwards compatibility with + runtime selectable wall functions + +SourceFiles + backwardsCompatibilityWallFunctions.C + backwardsCompatibilityWallFunctionsTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef backwardsCompatibilityWallFunctions_H +#define backwardsCompatibilityWallFunctions_H + +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + + //- Replace old wall BCs with new wall function BCs + wordList replaceWallBoundaryTypes + ( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames + ); + + //- mut + tmp autoCreateMut + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- k + tmp autoCreateK + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Q + tmp autoCreateQ + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- R + tmp autoCreateR + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "backwardsCompatibilityWallFunctionsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C similarity index 91% rename from src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C rename to src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 6b0d4eb9d8..fd7c9d59bf 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ -#include "RASModel.H" +#include "backwardsCompatibilityWallFunctions.H" +#include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,12 +38,12 @@ namespace compressible template tmp > -RASModel::autoCreateWallFunctionField +autoCreateWallFunctionField ( const word& fieldName, const fvMesh& mesh, const word& wallFunctionName -) const +) { IOobject mutHeader ( @@ -145,22 +146,6 @@ RASModel::autoCreateWallFunctionField } -template -tmp > RASModel::autoCreateKQR -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::kQRWallFunctionFvPatchField::typeName - ); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace compressible diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C index 11052b2f1e..414690f6fd 100644 --- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -117,7 +119,7 @@ kEpsilon::kEpsilon 1.0 ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C index 31932efc37..32bb44bcbb 100644 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -221,7 +223,7 @@ kOmegaSST::kOmegaSST y_(mesh_), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), omega_(autoCreateOmega("omega", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C index 795fbb83c6..141a7376c9 100644 --- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -150,7 +152,7 @@ realizableKE::realizableKE ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C index 31f26ce14e..a7304b7c6c 100644 --- a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -136,8 +138,8 @@ LRR::LRR ) ), - R_(autoCreateKQR("R", mesh_)), - k_(autoCreateKQR("k", mesh_)), + R_(autoCreateR("R", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 2b57bf7904..ac7a036e49 100644 --- a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -165,8 +167,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM yr_(mesh_), - R_(autoCreateKQR("R", mesh_)), - k_(autoCreateKQR("k", mesh_)), + R_(autoCreateR("R", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C index 0181d7e88d..6e877d6a42 100644 --- a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C +++ b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -145,7 +147,7 @@ LienCubicKE::LienCubicKE ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), gradU_(fvc::grad(U)), diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index eaff934512..3943dcd0fc 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -42,4 +42,6 @@ $(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C + LIB = $(FOAM_LIBBIN)/libincompressibleRASModels diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index e282e27f4c..628da387da 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -27,13 +27,6 @@ License #include "RASModel.H" #include "wallFvPatch.H" -// Headers reqd for back-porting wall function boundary conditions -#include "calculatedFvPatchField.H" -#include "nutWallFunctionFvPatchScalarField.H" -#include "epsilonWallFunctionFvPatchScalarField.H" -#include "omegaWallFunctionFvPatchScalarField.H" - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -57,128 +50,6 @@ void RASModel::printCoeffs() } -wordList RASModel::replaceWallBoundaryTypes -( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames -) const -{ - const fvBoundaryMesh& bm = mesh.boundary(); - - wordList boundaryTypes(bm.size()); - - forAll(bm, patchI) - { - if (isType(bm[patchI])) - { - boundaryTypes[patchI] = newTypeNames[patchI]; - } - else - { - boundaryTypes[patchI] = oldTypeNames[patchI]; - } - } - - return boundaryTypes; -} - - -tmp RASModel::autoCreateNut -( - const word& fieldName, - const fvMesh& mesh -) const -{ - IOobject nutHeader - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ); - - if (nutHeader.headerOk()) - { - return tmp(new volScalarField(nutHeader, mesh)); - } - else - { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; - - wordList nutBoundaryTypes = replaceWallBoundaryTypes - ( - mesh, - wordList - ( - mesh.boundary().size(), - calculatedFvPatchField::typeName - ), - wordList - ( - mesh.boundary().size(), - RASModels::nutWallFunctionFvPatchScalarField::typeName - ) - ); - - tmp nut - ( - new volScalarField - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("zero", dimArea/dimTime, 0.0), - nutBoundaryTypes - ) - ); - - Info<< " Writing updated " << fieldName << endl; - nut().write(); - - return nut; - } -} - - -tmp RASModel::autoCreateEpsilon -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::epsilonWallFunctionFvPatchScalarField::typeName - ); -} - - -tmp RASModel::autoCreateOmega -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::omegaWallFunctionFvPatchScalarField::typeName - ); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // RASModel::RASModel diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index e06a310643..b5edce3ea3 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -56,11 +56,6 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" -// Headers reqd for back-porting wall function boundary conditions -#include "wallFvPatch.H" -#include "kQRWallFunctionFvPatchField.H" - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -109,57 +104,6 @@ protected: // Protected member functions - // Auto creation of fields to provide backwards compatibility with - // runtime selectable wall functions - - //- Replace old wall BCs with new wall function BCs - wordList replaceWallBoundaryTypes - ( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames - ) const; - - //- mut - tmp autoCreateNut - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- epsilon - tmp autoCreateEpsilon - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- omega - tmp autoCreateOmega - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- kQR - template - tmp > autoCreateKQR - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- Helper function to create the new field - template - tmp > - autoCreateWallFunctionField - ( - const word& fieldName, - const fvMesh& mesh, - const word& wallFunctionName - ) const; - - //- Print model coefficients virtual void printCoeffs(); @@ -365,12 +309,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "RASModelTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C index 57c6e9dfe0..2029df47c9 100644 --- a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -117,7 +119,7 @@ RNGkEpsilon::RNGkEpsilon ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C new file mode 100644 index 0000000000..567dbfb1fc --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "backwardsCompatibilityWallFunctions.H" + +#include "calculatedFvPatchField.H" +#include "nutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "kQRWallFunctionFvPatchField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +wordList replaceWallBoundaryTypes +( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames +) +{ + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList boundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + boundaryTypes[patchI] = newTypeNames[patchI]; + } + else + { + boundaryTypes[patchI] = oldTypeNames[patchI]; + } + } + + return boundaryTypes; +} + + +tmp autoCreateNut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject nutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (nutHeader.headerOk()) + { + return tmp(new volScalarField(nutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + wordList nutBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + wordList + ( + mesh.boundary().size(), + calculatedFvPatchField::typeName + ), + wordList + ( + mesh.boundary().size(), + RASModels::nutWallFunctionFvPatchScalarField::typeName + ) + ); + + tmp nut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + nutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + nut().write(); + + return nut; + } +} + + +tmp autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::epsilonWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::omegaWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateK +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateQ +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateR +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // + diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H new file mode 100644 index 0000000000..73c60014e0 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible + +Description + Auto creation of fields to provide backwards compatibility with + runtime selectable wall functions + +SourceFiles + backwardsCompatibilityWallFunctions.C + backwardsCompatibilityWallFunctionsTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef backwardsCompatibilityWallFunctions_H +#define backwardsCompatibilityWallFunctions_H + +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + + //- Replace old wall BCs with new wall function BCs + wordList replaceWallBoundaryTypes + ( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames + ); + + //- nut + tmp autoCreateNut + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- k + tmp autoCreateK + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Q + tmp autoCreateQ + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- R + tmp autoCreateR + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "backwardsCompatibilityWallFunctionsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C similarity index 90% rename from src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C rename to src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index e01d965434..50b755ecbe 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ -#include "RASModel.H" +#include "backwardsCompatibilityWallFunctions.H" +#include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,16 +38,16 @@ namespace incompressible template tmp > -RASModel::autoCreateWallFunctionField +autoCreateWallFunctionField ( const word& fieldName, const fvMesh& mesh, const word& wallFunctionName -) const +) { - IOobject nutHeader + IOobject mutHeader ( - "nut", + "mut", mesh.time().timeName(), mesh, IOobject::MUST_READ, @@ -55,7 +56,7 @@ RASModel::autoCreateWallFunctionField typedef GeometricField fieldType; - if (nutHeader.headerOk()) + if (mutHeader.headerOk()) { return tmp ( @@ -145,22 +146,6 @@ RASModel::autoCreateWallFunctionField } -template -tmp > RASModel::autoCreateKQR -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::kQRWallFunctionFvPatchField::typeName - ); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace incompressible diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C index 81c548ca27..43f3fa2d2d 100644 --- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -91,7 +93,7 @@ kEpsilon::kEpsilon ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C index 79adfef154..fb8326b5b8 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C +++ b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -102,7 +104,7 @@ kOmega::kOmega omega0_("omega0", dimless/dimTime, SMALL), omegaSmall_("omegaSmall", dimless/dimTime, SMALL), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), omega_(autoCreateOmega("omega", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C index be68d1fa55..ba8dc16525 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -211,7 +213,7 @@ kOmegaSST::kOmegaSST y_(mesh_), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), omega_(autoCreateOmega("omega", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C index d805137d30..c8f488f5a1 100644 --- a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -140,7 +142,7 @@ realizableKE::realizableKE ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) {