From 7d771c9599a5235f9cd69d72971ddff99d3c6915 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 28 Jul 2013 17:57:58 +0100 Subject: [PATCH 1/9] TurbulenceModels: Preliminary version of the templated turbulence models library --- src/TurbulenceModels/Allwmake | 12 + .../CompressibleTurbulenceModel.C | 98 +++ .../CompressibleTurbulenceModel.H | 157 +++++ src/TurbulenceModels/compressible/Make/files | 4 + .../compressible/Make/options | 12 + .../compressibleTurbulenceModel.C | 58 ++ .../compressibleTurbulenceModel.H | 117 ++++ .../compressibleTurbulenceModels.C | 97 +++ .../IncompressibleTurbulenceModel.C | 151 +++++ .../IncompressibleTurbulenceModel.H | 132 ++++ .../incompressible/Make/files | 4 + .../incompressible/Make/options | 10 + .../incompressibleTurbulenceModel.C | 99 +++ .../incompressibleTurbulenceModel.H | 136 ++++ .../incompressibleTurbulenceModels.C | 98 +++ .../PhaseCompressibleTurbulenceModel.C | 100 +++ .../PhaseCompressibleTurbulenceModel.H | 159 +++++ .../PhaseIncompressibleTurbulenceModel.C | 199 ++++++ .../PhaseIncompressibleTurbulenceModel.H | 142 ++++ .../RAS/LaheyKEpsilon/LaheyKEpsilon.C | 265 ++++++++ .../RAS/LaheyKEpsilon/LaheyKEpsilon.H | 146 +++++ .../continuousGasKEpsilon.C | 280 ++++++++ .../continuousGasKEpsilon.H | 148 +++++ .../turbulenceModel/Make/files | 49 ++ .../turbulenceModel/Make/options | 7 + .../turbulenceModel/RAS/RASModel/RASModel.C | 184 ++++++ .../turbulenceModel/RAS/RASModel/RASModel.H | 267 ++++++++ ...ndaryLayerInletEpsilonFvPatchScalarField.C | 199 ++++++ ...ndaryLayerInletEpsilonFvPatchScalarField.H | 249 +++++++ ...daryLayerInletVelocityFvPatchVectorField.C | 223 +++++++ ...daryLayerInletVelocityFvPatchVectorField.H | 266 ++++++++ .../incompressibleRASBoundaryConditionsDoc.H | 39 ++ ...thDissipationRateInletFvPatchScalarField.C | 186 ++++++ ...thDissipationRateInletFvPatchScalarField.H | 202 ++++++ ...ngLengthFrequencyInletFvPatchScalarField.C | 182 ++++++ ...ngLengthFrequencyInletFvPatchScalarField.H | 203 ++++++ ...silonLowReWallFunctionFvPatchScalarField.C | 189 ++++++ ...silonLowReWallFunctionFvPatchScalarField.H | 191 ++++++ .../epsilonWallFunctionFvPatchScalarField.C | 590 +++++++++++++++++ .../epsilonWallFunctionFvPatchScalarField.H | 285 ++++++++ .../fWallFunctionFvPatchScalarField.C | 259 ++++++++ .../fWallFunctionFvPatchScalarField.H | 203 ++++++ .../kLowReWallFunctionFvPatchScalarField.C | 256 ++++++++ .../kLowReWallFunctionFvPatchScalarField.H | 204 ++++++ .../kqRWallFunctionFvPatchField.C | 147 +++++ .../kqRWallFunctionFvPatchField.H | 182 ++++++ .../kqRWallFunctionFvPatchFields.C | 44 ++ .../kqRWallFunctionFvPatchFields.H | 49 ++ .../nutLowReWallFunctionFvPatchScalarField.C | 133 ++++ .../nutLowReWallFunctionFvPatchScalarField.H | 163 +++++ .../nutURoughWallFunctionFvPatchScalarField.C | 319 +++++++++ .../nutURoughWallFunctionFvPatchScalarField.H | 238 +++++++ ...tUSpaldingWallFunctionFvPatchScalarField.C | 232 +++++++ ...tUSpaldingWallFunctionFvPatchScalarField.H | 187 ++++++ ...UTabulatedWallFunctionFvPatchScalarField.C | 225 +++++++ ...UTabulatedWallFunctionFvPatchScalarField.H | 195 ++++++ .../nutUWallFunctionFvPatchScalarField.C | 215 +++++++ .../nutUWallFunctionFvPatchScalarField.H | 173 +++++ .../nutWallFunctionFvPatchScalarField.C | 194 ++++++ .../nutWallFunctionFvPatchScalarField.H | 178 +++++ ...tkAtmRoughWallFunctionFvPatchScalarField.C | 199 ++++++ ...tkAtmRoughWallFunctionFvPatchScalarField.H | 214 +++++++ .../nutkRoughWallFunctionFvPatchScalarField.C | 243 +++++++ .../nutkRoughWallFunctionFvPatchScalarField.H | 218 +++++++ .../nutkWallFunctionFvPatchScalarField.C | 173 +++++ .../nutkWallFunctionFvPatchScalarField.H | 163 +++++ .../omegaWallFunctionFvPatchScalarField.C | 606 ++++++++++++++++++ .../omegaWallFunctionFvPatchScalarField.H | 292 +++++++++ .../v2WallFunctionFvPatchScalarField.C | 249 +++++++ .../v2WallFunctionFvPatchScalarField.H | 205 ++++++ .../RAS/eddyViscosity/eddyViscosity.C | 159 +++++ .../RAS/eddyViscosity/eddyViscosity.H | 151 +++++ .../turbulenceModel/RAS/kEpsilon/kEpsilon.C | 293 +++++++++ .../turbulenceModel/RAS/kEpsilon/kEpsilon.H | 194 ++++++ .../TurbulenceModel/TurbulenceModel.C | 133 ++++ .../TurbulenceModel/TurbulenceModel.H | 188 ++++++ .../fixedShearStressFvPatchVectorField.C | 157 +++++ .../fixedShearStressFvPatchVectorField.H | 154 +++++ .../porousBafflePressureFvPatchField.C | 177 +++++ .../porousBafflePressureFvPatchField.H | 204 ++++++ .../porousBafflePressureFvPatchFieldFwd.H | 50 ++ .../turbulenceModel/laminar/laminar.C | 286 +++++++++ .../turbulenceModel/laminar/laminar.H | 156 +++++ .../turbulenceModel/turbulenceModel.C | 90 +++ .../turbulenceModel/turbulenceModel.H | 227 +++++++ .../turbulenceModel/turbulenceModelDoc.H | 31 + 86 files changed, 15143 insertions(+) create mode 100755 src/TurbulenceModels/Allwmake create mode 100644 src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.C create mode 100644 src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.H create mode 100644 src/TurbulenceModels/compressible/Make/files create mode 100644 src/TurbulenceModels/compressible/Make/options create mode 100644 src/TurbulenceModels/compressible/compressibleTurbulenceModel.C create mode 100644 src/TurbulenceModels/compressible/compressibleTurbulenceModel.H create mode 100644 src/TurbulenceModels/compressible/compressibleTurbulenceModels.C create mode 100644 src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.C create mode 100644 src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H create mode 100644 src/TurbulenceModels/incompressible/Make/files create mode 100644 src/TurbulenceModels/incompressible/Make/options create mode 100644 src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.C create mode 100644 src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.H create mode 100644 src/TurbulenceModels/incompressible/incompressibleTurbulenceModels.C create mode 100644 src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.C create mode 100644 src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.H create mode 100644 src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.C create mode 100644 src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.H create mode 100644 src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C create mode 100644 src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.H create mode 100644 src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C create mode 100644 src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.H create mode 100644 src/TurbulenceModels/turbulenceModel/Make/files create mode 100644 src/TurbulenceModels/turbulenceModel/Make/options create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/doc/incompressibleRASBoundaryConditionsDoc.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchFields.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchFields.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/eddyViscosity/eddyViscosity.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/eddyViscosity/eddyViscosity.H create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/kEpsilon/kEpsilon.C create mode 100644 src/TurbulenceModels/turbulenceModel/RAS/kEpsilon/kEpsilon.H create mode 100644 src/TurbulenceModels/turbulenceModel/TurbulenceModel/TurbulenceModel.C create mode 100644 src/TurbulenceModels/turbulenceModel/TurbulenceModel/TurbulenceModel.H create mode 100644 src/TurbulenceModels/turbulenceModel/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C create mode 100644 src/TurbulenceModels/turbulenceModel/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H create mode 100644 src/TurbulenceModels/turbulenceModel/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C create mode 100644 src/TurbulenceModels/turbulenceModel/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H create mode 100644 src/TurbulenceModels/turbulenceModel/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H create mode 100644 src/TurbulenceModels/turbulenceModel/laminar/laminar.C create mode 100644 src/TurbulenceModels/turbulenceModel/laminar/laminar.H create mode 100644 src/TurbulenceModels/turbulenceModel/turbulenceModel.C create mode 100644 src/TurbulenceModels/turbulenceModel/turbulenceModel.H create mode 100644 src/TurbulenceModels/turbulenceModel/turbulenceModelDoc.H diff --git a/src/TurbulenceModels/Allwmake b/src/TurbulenceModels/Allwmake new file mode 100755 index 0000000000..c0daf57343 --- /dev/null +++ b/src/TurbulenceModels/Allwmake @@ -0,0 +1,12 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +makeType=${1:-libso} +set -x + +wmake libso turbulenceModel +wmake libso incompressible +wmake libso compressible +wmakeLnInclude phaseIncompressible +wmakeLnInclude phaseCompressible + +# ----------------------------------------------------------------- end-of-file diff --git a/src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.C b/src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.C new file mode 100644 index 0000000000..918331d8ec --- /dev/null +++ b/src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.C @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "CompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CompressibleTurbulenceModel:: +CompressibleTurbulenceModel +( + const geometricOneField& alpha, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +: + TurbulenceModel + < + geometricOneField, + volScalarField, + compressibleTurbulenceModel, + transportModel + > + ( + alpha, + rho, + U, + alphaPhi, + phi, + transport, + propertiesName + ) +{} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +template +Foam::autoPtr > +Foam::CompressibleTurbulenceModel::New +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +{ + return autoPtr + ( + static_cast( + TurbulenceModel + < + geometricOneField, + volScalarField, + compressibleTurbulenceModel, + transportModel + >::New + ( + geometricOneField(), + rho, + U, + phi, + phi, + transport, + propertiesName + ).ptr()) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.H b/src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.H new file mode 100644 index 0000000000..ba118c0b02 --- /dev/null +++ b/src/TurbulenceModels/compressible/CompressibleTurbulenceModel/CompressibleTurbulenceModel.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::CompressibleTurbulenceModel + +Description + Templated abstract base class for single-phase compressible + turbulence models. + +SourceFiles + CompressibleTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CompressibleTurbulenceModel_H +#define CompressibleTurbulenceModel_H + +#include "TurbulenceModel.H" +#include "compressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class CompressibleTurbulenceModel Declaration +\*---------------------------------------------------------------------------*/ + +template +class CompressibleTurbulenceModel +: + public TurbulenceModel + < + geometricOneField, + volScalarField, + compressibleTurbulenceModel, + TransportModel + > +{ + +public: + + typedef geometricOneField alphaField; + typedef volScalarField rhoField; + typedef TransportModel transportModel; + + + // Constructors + + //- Construct + CompressibleTurbulenceModel + ( + const geometricOneField& alpha, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& trasport, + const word& propertiesName + ); + + + // Selectors + + //- Return a reference to the selected turbulence model + static autoPtr New + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const transportModel& trasportModel, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~CompressibleTurbulenceModel() + {} + + + // Member Functions + + //- Return the laminar dynamic viscosity + virtual tmp mu() const + { + return this->transport_.mu(); + } + + //- Return the laminar dynamic viscosity on patch + virtual tmp mu(const label patchi) const + { + return this->transport_.mu(patchi); + } + + //- Return the turbulence dynamic viscosity + virtual tmp mut() const + { + return this->rho_*this->nut(); + } + + //- Return the turbulence dynamic viscosity on patch + virtual tmp mut(const label patchi) const + { + return this->rho_.boundaryField()[patchi]*this->nut(patchi); + } + + //- Return the effective dynamic viscosity + virtual tmp muEff() const + { + return mut() + mu(); + } + + //- Return the effective dynamic viscosity on patch + virtual tmp muEff(const label patchi) const + { + return mut(patchi) + mu(patchi); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "CompressibleTurbulenceModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/compressible/Make/files b/src/TurbulenceModels/compressible/Make/files new file mode 100644 index 0000000000..c4107f1050 --- /dev/null +++ b/src/TurbulenceModels/compressible/Make/files @@ -0,0 +1,4 @@ +compressibleTurbulenceModel.C +compressibleTurbulenceModels.C + +LIB = $(FOAM_LIBBIN)/libcompressibleTurbulenceModels diff --git a/src/TurbulenceModels/compressible/Make/options b/src/TurbulenceModels/compressible/Make/options new file mode 100644 index 0000000000..73c2a143ce --- /dev/null +++ b/src/TurbulenceModels/compressible/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I../turbulenceModel/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lfluidThermophysicalModels \ + -lspecie diff --git a/src/TurbulenceModels/compressible/compressibleTurbulenceModel.C b/src/TurbulenceModels/compressible/compressibleTurbulenceModel.C new file mode 100644 index 0000000000..a9e7794cff --- /dev/null +++ b/src/TurbulenceModels/compressible/compressibleTurbulenceModel.C @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "compressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(compressibleTurbulenceModel, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibleTurbulenceModel::compressibleTurbulenceModel +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const word& propertiesName +) +: + turbulenceModel + ( + U, + alphaPhi, + phi, + propertiesName + ), + rho_(rho) +{} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/compressible/compressibleTurbulenceModel.H b/src/TurbulenceModels/compressible/compressibleTurbulenceModel.H new file mode 100644 index 0000000000..d762dc5a05 --- /dev/null +++ b/src/TurbulenceModels/compressible/compressibleTurbulenceModel.H @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::compressibleTurbulenceModel + +Description + Abstract base class for turbulence models (RAS, LES and laminar). + +SourceFiles + compressibleTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleTurbulenceModel_H +#define compressibleTurbulenceModel_H + +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declarations +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class compressibleTurbulenceModel Declaration +\*---------------------------------------------------------------------------*/ + +class compressibleTurbulenceModel +: + public turbulenceModel +{ + +protected: + + // Protected data + + const volScalarField& rho_; + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + compressibleTurbulenceModel(const compressibleTurbulenceModel&); + + //- Disallow default bitwise assignment + void operator=(const compressibleTurbulenceModel&); + + +public: + + //- Runtime type information + TypeName("compressibleTurbulenceModel"); + + + // Constructors + + //- Construct from components + compressibleTurbulenceModel + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const word& propertiesName + ); + + + //- Destructor + virtual ~compressibleTurbulenceModel() + {} + + + // Member Functions + + //- Return the effective stress tensor including the laminar stress + virtual tmp devRhoReff() const = 0; + + //- Return the source term for the momentum equation + virtual tmp divDevRhoReff(volVectorField& U) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/compressible/compressibleTurbulenceModels.C b/src/TurbulenceModels/compressible/compressibleTurbulenceModels.C new file mode 100644 index 0000000000..b8779c591e --- /dev/null +++ b/src/TurbulenceModels/compressible/compressibleTurbulenceModels.C @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "CompressibleTurbulenceModel.H" +#include "laminar.H" +#include "RASModel.H" +#include "kEpsilon.H" +#include "fluidThermo.H" +#include "addToRunTimeSelectionTable.H" + +namespace Foam +{ + typedef TurbulenceModel + < + geometricOneField, + volScalarField, + compressibleTurbulenceModel, + fluidThermo + > baseCompressibleFluidThermoTurbulenceModel; + + defineTemplateRunTimeSelectionTable + ( + baseCompressibleFluidThermoTurbulenceModel, + dictionary + ); + + + typedef CompressibleTurbulenceModel + compressibleFluidThermoTurbulenceModel; + + typedef laminar compressibleLaminar; + + defineNamedTemplateTypeNameAndDebug(compressibleLaminar, 0); + + addToRunTimeSelectionTable + ( + baseCompressibleFluidThermoTurbulenceModel, + compressibleLaminar, + dictionary + ); + + + typedef RASModel + compressibleRASModel; + + defineNamedTemplateTypeNameAndDebug(compressibleRASModel, 0); + + defineTemplateRunTimeSelectionTable(compressibleRASModel, dictionary); + + addToRunTimeSelectionTable + ( + baseCompressibleFluidThermoTurbulenceModel, + compressibleRASModel, + dictionary + ); + + + namespace RASModels + { + typedef kEpsilon + compressibleKEpsilon; + + defineNamedTemplateTypeNameAndDebug(compressibleKEpsilon, 0); + + addToRunTimeSelectionTable + ( + compressibleRASModel, + compressibleKEpsilon, + dictionary + ); + } +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.C b/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.C new file mode 100644 index 0000000000..96179e22b8 --- /dev/null +++ b/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "IncompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::IncompressibleTurbulenceModel:: +IncompressibleTurbulenceModel +( + const geometricOneField& alpha, + const geometricOneField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const TransportModel& transportModel, + const word& propertiesName +) +: + TurbulenceModel + < + geometricOneField, + geometricOneField, + incompressibleTurbulenceModel, + TransportModel + > + ( + alpha, + rho, + U, + alphaPhi, + phi, + transportModel, + propertiesName + ) +{} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +template +Foam::autoPtr > +Foam::IncompressibleTurbulenceModel::New +( + const volVectorField& U, + const surfaceScalarField& phi, + const TransportModel& transportModel, + const word& propertiesName +) +{ + return autoPtr + ( + static_cast( + TurbulenceModel + < + geometricOneField, + geometricOneField, + incompressibleTurbulenceModel, + TransportModel + >::New + ( + geometricOneField(), + geometricOneField(), + U, + phi, + phi, + transportModel, + propertiesName + ).ptr()) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp +Foam::IncompressibleTurbulenceModel::devReff() const +{ + return devRhoReff(); +} + + +template +Foam::tmp +Foam::IncompressibleTurbulenceModel::divDevReff +( + volVectorField& U +) const +{ + return divDevRhoReff(U); +} + + +template +Foam::tmp +Foam::IncompressibleTurbulenceModel:: +devRhoReff() const +{ + notImplemented + ( + "IncompressibleTurbulenceModel::" + "devRhoReff()" + ); + + return devReff(); +} + + +template +Foam::tmp +Foam::IncompressibleTurbulenceModel:: +divDevRhoReff +( + volVectorField& U +) const +{ + notImplemented + ( + "IncompressibleTurbulenceModel::" + "divDevRhoReff(volVectorField& U)" + ); + + return divDevReff(U); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H b/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H new file mode 100644 index 0000000000..d774ff9177 --- /dev/null +++ b/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::IncompressibleTurbulenceModel + +Description + Templated abstract base class for single-phase incompressible + turbulence models. + +SourceFiles + IncompressibleTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef IncompressibleTurbulenceModel_H +#define IncompressibleTurbulenceModel_H + +#include "TurbulenceModel.H" +#include "incompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class IncompressibleTurbulenceModel Declaration +\*---------------------------------------------------------------------------*/ + +template +class IncompressibleTurbulenceModel +: + public TurbulenceModel + < + geometricOneField, + geometricOneField, + incompressibleTurbulenceModel, + TransportModel + > +{ + +public: + + typedef geometricOneField alphaField; + typedef geometricOneField rhoField; + typedef TransportModel transportModel; + + + // Constructors + + //- Construct + IncompressibleTurbulenceModel + ( + const geometricOneField& alpha, + const geometricOneField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const TransportModel& trasportModel, + const word& propertiesName + ); + + + // Selectors + + //- Return a reference to the selected turbulence model + static autoPtr New + ( + const volVectorField& U, + const surfaceScalarField& phi, + const TransportModel& trasportModel, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~IncompressibleTurbulenceModel() + {} + + + // Member Functions + + //- Return the effective stress tensor + virtual tmp devReff() const; + + //- Return the source term for the momentum equation + virtual tmp divDevReff(volVectorField& U) const; + + //- Return the effective stress tensor + virtual tmp devRhoReff() const; + + //- Return the source term for the momentum equation + virtual tmp divDevRhoReff(volVectorField& U) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "IncompressibleTurbulenceModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/incompressible/Make/files b/src/TurbulenceModels/incompressible/Make/files new file mode 100644 index 0000000000..4b3ca65c16 --- /dev/null +++ b/src/TurbulenceModels/incompressible/Make/files @@ -0,0 +1,4 @@ +incompressibleTurbulenceModel.C +incompressibleTurbulenceModels.C + +LIB = $(FOAM_LIBBIN)/libincompressibleTurbulenceModels diff --git a/src/TurbulenceModels/incompressible/Make/options b/src/TurbulenceModels/incompressible/Make/options new file mode 100644 index 0000000000..0763d29c16 --- /dev/null +++ b/src/TurbulenceModels/incompressible/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I../turbulenceModel/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude + +LIB_LIBS = \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.C b/src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.C new file mode 100644 index 0000000000..232a31fc83 --- /dev/null +++ b/src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "incompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(incompressibleTurbulenceModel, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::incompressibleTurbulenceModel::incompressibleTurbulenceModel +( + const geometricOneField&, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const word& propertiesName +) +: + turbulenceModel + ( + U, + alphaPhi, + phi, + propertiesName + ) +{} + + +Foam::tmp +Foam::incompressibleTurbulenceModel::mu() const +{ + return nu(); +} + + +Foam::tmp +Foam::incompressibleTurbulenceModel::mu(const label patchi) const +{ + return nu(patchi); +} + + +Foam::tmp +Foam::incompressibleTurbulenceModel::mut() const +{ + return nut(); +} + + +Foam::tmp +Foam::incompressibleTurbulenceModel::mut(const label patchi) const +{ + return nut(patchi); +} + + +Foam::tmp +Foam::incompressibleTurbulenceModel::muEff() const +{ + return nuEff(); +} + + +Foam::tmp +Foam::incompressibleTurbulenceModel::muEff(const label patchi) const +{ + return nuEff(patchi); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.H b/src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.H new file mode 100644 index 0000000000..6876d88a48 --- /dev/null +++ b/src/TurbulenceModels/incompressible/incompressibleTurbulenceModel.H @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::incompressibleTurbulenceModel + +Description + Abstract base class for turbulence models (RAS, LES and laminar). + +SourceFiles + incompressibleTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef incompressibleTurbulenceModel_H +#define incompressibleTurbulenceModel_H + +#include "turbulenceModel.H" +#include "geometricOneField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declarations +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class incompressibleTurbulenceModel Declaration +\*---------------------------------------------------------------------------*/ + +class incompressibleTurbulenceModel +: + public turbulenceModel +{ + +protected: + + // Protected data + + geometricOneField rho_; + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + incompressibleTurbulenceModel(const incompressibleTurbulenceModel&); + + //- Disallow default bitwise assignment + void operator=(const incompressibleTurbulenceModel&); + + +public: + + //- Runtime type information + TypeName("incompressibleTurbulenceModel"); + + + // Constructors + + //- Construct from components + incompressibleTurbulenceModel + ( + const geometricOneField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const word& propertiesName + ); + + + //- Destructor + virtual ~incompressibleTurbulenceModel() + {} + + + // Member Functions + + //- Return the laminar dynamic viscosity + virtual tmp mu() const; + + //- Return the laminar dynamic viscosity on patch + virtual tmp mu(const label patchi) const; + + //- Return the turbulence dynamic viscosity + virtual tmp mut() const; + + //- Return the turbulence dynamic viscosity on patch + virtual tmp mut(const label patchi) const; + + //- Return the effective dynamic viscosity + virtual tmp muEff() const; + + //- Return the effective dynamic viscosity on patch + virtual tmp muEff(const label patchi) const; + + //- Return the effective stress tensor including the laminar stress + virtual tmp devReff() const = 0; + + //- Return the source term for the momentum equation + virtual tmp divDevReff(volVectorField& U) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/incompressible/incompressibleTurbulenceModels.C b/src/TurbulenceModels/incompressible/incompressibleTurbulenceModels.C new file mode 100644 index 0000000000..6d3b8aef5f --- /dev/null +++ b/src/TurbulenceModels/incompressible/incompressibleTurbulenceModels.C @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "IncompressibleTurbulenceModel.H" +#include "laminar.H" +#include "RASModel.H" +#include "kEpsilon.H" +#include "transportModel.H" +#include "addToRunTimeSelectionTable.H" + +namespace Foam +{ + typedef TurbulenceModel + < + geometricOneField, + geometricOneField, + incompressibleTurbulenceModel, + transportModel + > baseIncompressibleTransportTurbulenceModel; + + defineTemplateRunTimeSelectionTable + ( + baseIncompressibleTransportTurbulenceModel, + dictionary + ); + + typedef IncompressibleTurbulenceModel + < + transportModel + > incompressibleTransportTurbulenceModel; + + typedef laminar + incompressibleLaminar; + + defineNamedTemplateTypeNameAndDebug(incompressibleLaminar, 0); + + addToRunTimeSelectionTable + ( + baseIncompressibleTransportTurbulenceModel, + incompressibleLaminar, + dictionary + ); + + + typedef RASModel + incompressibleRASModel; + + defineNamedTemplateTypeNameAndDebug(incompressibleRASModel, 0); + + defineTemplateRunTimeSelectionTable(incompressibleRASModel, dictionary); + + addToRunTimeSelectionTable + ( + baseIncompressibleTransportTurbulenceModel, + incompressibleRASModel, + dictionary + ); + + namespace RASModels + { + typedef kEpsilon + incompressibleKEpsilon; + + defineNamedTemplateTypeNameAndDebug(incompressibleKEpsilon, 0); + + addToRunTimeSelectionTable + ( + incompressibleRASModel, + incompressibleKEpsilon, + dictionary + ); + } +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.C b/src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.C new file mode 100644 index 0000000000..70b60a64fa --- /dev/null +++ b/src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.C @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "PhaseCompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::PhaseCompressibleTurbulenceModel:: +PhaseCompressibleTurbulenceModel +( + const volScalarField& alpha, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +: + TurbulenceModel + < + volScalarField, + volScalarField, + compressibleTurbulenceModel, + transportModel + > + ( + alpha, + rho, + U, + alphaPhi, + phi, + transport, + propertiesName + ) +{} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +template +Foam::autoPtr > +Foam::PhaseCompressibleTurbulenceModel::New +( + const volScalarField& alpha, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +{ + return autoPtr + ( + static_cast( + TurbulenceModel + < + volScalarField, + volScalarField, + compressibleTurbulenceModel, + transportModel + >::New + ( + alpha, + rho, + U, + alphaPhi, + phi, + transport, + propertiesName + ).ptr()) + ); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.H b/src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.H new file mode 100644 index 0000000000..5eefb4ea3d --- /dev/null +++ b/src/TurbulenceModels/phaseCompressible/PhaseCompressibleTurbulenceModel/PhaseCompressibleTurbulenceModel.H @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::PhaseCompressibleTurbulenceModel + +Description + Templated abstract base class for multiphase compressible + turbulence models. + +SourceFiles + PhaseCompressibleTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PhaseCompressibleTurbulenceModel_H +#define PhaseCompressibleTurbulenceModel_H + +#include "TurbulenceModel.H" +#include "compressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PhaseCompressibleTurbulenceModel Declaration +\*---------------------------------------------------------------------------*/ + +template +class PhaseCompressibleTurbulenceModel +: + public TurbulenceModel + < + volScalarField, + volScalarField, + compressibleTurbulenceModel, + TransportModel + > +{ + +public: + + typedef volScalarField alphaField; + typedef volScalarField rhoField; + typedef TransportModel transportModel; + + + // Constructors + + //- Construct + PhaseCompressibleTurbulenceModel + ( + const alphaField& alpha, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& trasport, + const word& propertiesName + ); + + + // Selectors + + //- Return a reference to the selected turbulence model + static autoPtr New + ( + const alphaField& alpha, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& trasportModel, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~PhaseCompressibleTurbulenceModel() + {} + + + // Member Functions + + //- Return the laminar dynamic viscosity + virtual tmp mu() const + { + return this->transport_.mu(); + } + + //- Return the laminar dynamic viscosity on patch + virtual tmp mu(const label patchi) const + { + return this->transport_.mu(patchi); + } + + //- Return the turbulence dynamic viscosity + virtual tmp mut() const + { + return this->rho_*this->nut(); + } + + //- Return the turbulence dynamic viscosity on patch + virtual tmp mut(const label patchi) const + { + return this->rho_.boundaryField()[patchi]*this->nut(patchi); + } + + //- Return the effective dynamic viscosity + virtual tmp muEff() const + { + return mut() + mu(); + } + + //- Return the effective dynamic viscosity on patch + virtual tmp muEff(const label patchi) const + { + return mut(patchi) + mu(patchi); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "PhaseCompressibleTurbulenceModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.C b/src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.C new file mode 100644 index 0000000000..003c86794b --- /dev/null +++ b/src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.C @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "PhaseIncompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::PhaseIncompressibleTurbulenceModel:: +PhaseIncompressibleTurbulenceModel +( + const volScalarField& alpha, + const geometricOneField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const TransportModel& transportModel, + const word& propertiesName +) +: + TurbulenceModel + < + volScalarField, + geometricOneField, + incompressibleTurbulenceModel, + TransportModel + > + ( + alpha, + rho, + U, + alphaPhi, + phi, + transportModel, + propertiesName + ) +{} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +template +Foam::autoPtr > +Foam::PhaseIncompressibleTurbulenceModel::New +( + const volScalarField& alpha, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const TransportModel& transportModel, + const word& propertiesName +) +{ + return autoPtr + ( + static_cast( + TurbulenceModel + < + volScalarField, + geometricOneField, + incompressibleTurbulenceModel, + TransportModel + >::New + ( + alpha, + geometricOneField(), + U, + alphaPhi, + phi, + transportModel, + propertiesName + ).ptr()) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp +Foam::PhaseIncompressibleTurbulenceModel::pPrime() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + IOobject::groupName("pPrime", this->U_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh_, + dimensionedScalar("pPrimef", dimPressure, 0.0) + ) + ); +} + + +template +Foam::tmp +Foam::PhaseIncompressibleTurbulenceModel::pPrimef() const +{ + return tmp + ( + new surfaceScalarField + ( + IOobject + ( + IOobject::groupName("pPrimef", this->U_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh_, + dimensionedScalar("pPrimef", dimPressure, 0.0) + ) + ); +} + + +template +Foam::tmp +Foam::PhaseIncompressibleTurbulenceModel::devReff() const +{ + return devRhoReff(); +} + + +template +Foam::tmp +Foam::PhaseIncompressibleTurbulenceModel::divDevReff +( + volVectorField& U +) const +{ + return divDevRhoReff(U); +} + + +template +Foam::tmp +Foam::PhaseIncompressibleTurbulenceModel:: +devRhoReff() const +{ + notImplemented + ( + "PhaseIncompressibleTurbulenceModel::" + "devRhoReff()" + ); + + return devReff(); +} + + +template +Foam::tmp +Foam::PhaseIncompressibleTurbulenceModel:: +divDevRhoReff +( + volVectorField& U +) const +{ + notImplemented + ( + "PhaseIncompressibleTurbulenceModel::" + "divDevRhoReff(volVectorField& U)" + ); + + return divDevReff(U); +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.H b/src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.H new file mode 100644 index 0000000000..c15b54e92a --- /dev/null +++ b/src/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel/PhaseIncompressibleTurbulenceModel.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::PhaseIncompressibleTurbulenceModel + +Description + Templated abstract base class for multiphase incompressible + turbulence models. + +SourceFiles + PhaseIncompressibleTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PhaseIncompressibleTurbulenceModel_H +#define PhaseIncompressibleTurbulenceModel_H + +#include "TurbulenceModel.H" +#include "incompressibleTurbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PhaseIncompressibleTurbulenceModel Declaration +\*---------------------------------------------------------------------------*/ + +template +class PhaseIncompressibleTurbulenceModel +: + public TurbulenceModel + < + volScalarField, + geometricOneField, + incompressibleTurbulenceModel, + TransportModel + > +{ + +public: + + typedef volScalarField alphaField; + typedef geometricOneField rhoField; + typedef TransportModel transportModel; + + + // Constructors + + //- Construct + PhaseIncompressibleTurbulenceModel + ( + const alphaField& alpha, + const geometricOneField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const TransportModel& trasportModel, + const word& propertiesName + ); + + + // Selectors + + //- Return a reference to the selected turbulence model + static autoPtr New + ( + const alphaField& alpha, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const TransportModel& trasportModel, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~PhaseIncompressibleTurbulenceModel() + {} + + + // Member Functions + + //- Return the phase-pressure' + // (derivative of phase-pressure w.r.t. phase-fraction) + virtual tmp pPrime() const; + + //- Return the face-phase-pressure' + // (derivative of phase-pressure w.r.t. phase-fraction) + virtual tmp pPrimef() const; + + //- Return the effective stress tensor + virtual tmp devReff() const; + + //- Return the source term for the momentum equation + virtual tmp divDevReff(volVectorField& U) const; + + //- Return the effective stress tensor + virtual tmp devRhoReff() const; + + //- Return the source term for the momentum equation + virtual tmp divDevRhoReff(volVectorField& U) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "PhaseIncompressibleTurbulenceModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C b/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C new file mode 100644 index 0000000000..2194280174 --- /dev/null +++ b/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C @@ -0,0 +1,265 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "LaheyKEpsilon.H" +#include "addToRunTimeSelectionTable.H" +#include "twoPhaseSystem.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +LaheyKEpsilon::LaheyKEpsilon +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName, + const word& type +) +: + kEpsilon + ( + alpha, + rho, + U, + alphaPhi, + phi, + transport, + propertiesName, + type + ), + + gasTurbulencePtr_(NULL), + + alphaInversion_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaInversion", + this->coeffDict_, + 0.3 + ) + ), + + Cp_ + ( + dimensioned::lookupOrAddToDict + ( + "Cp", + this->coeffDict_, + 0.25 + ) + ), + + Cmub_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmub", + this->coeffDict_, + 0.6 + ) + ) +{ + if (type == typeName) + { + correctNut(); + this->printCoeffs(type); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool LaheyKEpsilon::read() +{ + if (kEpsilon::read()) + { + alphaInversion_.readIfPresent(this->coeffDict()); + Cp_.readIfPresent(this->coeffDict()); + Cmub_.readIfPresent(this->coeffDict()); + + return true; + } + else + { + return false; + } +} + + +template +const PhaseIncompressibleTurbulenceModel +< + typename BasicTurbulenceModel::transportModel +>& +LaheyKEpsilon::gasTurbulence() const +{ + if (!gasTurbulencePtr_) + { + const volVectorField& U = this->U_; + + const transportModel& liquid = this->transport(); + const twoPhaseSystem& fluid = liquid.fluid(); + const transportModel& gas = fluid.otherPhase(liquid); + + gasTurbulencePtr_ = + &U.db() + .lookupObject > + ( + IOobject::groupName + ( + turbulenceModel::propertiesName, + gas.name() + ) + ); + } + + return *gasTurbulencePtr_; +} + + +template +void LaheyKEpsilon::correctNut() +{ + const PhaseIncompressibleTurbulenceModel& gasTurbulence = + this->gasTurbulence(); + + this->nut_ = + this->Cmu_*sqr(this->k_)/this->epsilon_ + + Cmub_*gasTurbulence.transport().d()*gasTurbulence.alpha() + *(mag(this->U_ - gasTurbulence.U())); + + this->nut_.correctBoundaryConditions(); +} + + +template +tmp LaheyKEpsilon::bubbleG() const +{ + const PhaseIncompressibleTurbulenceModel& gasTurbulence = + this->gasTurbulence(); + + const transportModel& liquid = this->transport(); + const twoPhaseSystem& fluid = liquid.fluid(); + const transportModel& gas = fluid.otherPhase(liquid); + + volScalarField magUr(mag(this->U_ - gasTurbulence.U())); + + tmp bubbleG + ( + Cp_ + *( + pow3(magUr) + + pow(fluid.drag(gas).K(magUr)*gas.d()/liquid.rho(), 3.0/4.0) + *pow(magUr, 9.0/4.0) + ) + *gas + /gas.d() + ); + + return bubbleG; +} + + +template +tmp +LaheyKEpsilon::phaseTransferCoeff() const +{ + const volVectorField& U = this->U_; + const alphaField& alpha = this->alpha_; + const rhoField& rho = this->rho_; + + const turbulenceModel& gasTurbulence = this->gasTurbulence(); + + return + ( + max(alphaInversion_ - alpha, 0.0) + *rho + *min(gasTurbulence.epsilon()/gasTurbulence.k(), 1.0/U.time().deltaT()) + ); +} + + +template +tmp LaheyKEpsilon::kSource() const +{ + const alphaField& alpha = this->alpha_; + const rhoField& rho = this->rho_; + + const PhaseIncompressibleTurbulenceModel& gasTurbulence = + this->gasTurbulence(); + + const volScalarField phaseTransferCoeff(this->phaseTransferCoeff()); + + return + alpha*rho*bubbleG() + + phaseTransferCoeff*gasTurbulence.k() + - fvm::Sp(phaseTransferCoeff, this->k_); +} + + +template +tmp LaheyKEpsilon::epsilonSource() const +{ + const alphaField& alpha = this->alpha_; + const rhoField& rho = this->rho_; + + const PhaseIncompressibleTurbulenceModel& gasTurbulence = + this->gasTurbulence(); + + const volScalarField phaseTransferCoeff(this->phaseTransferCoeff()); + + return + alpha*rho*this->C2_*this->epsilon_*bubbleG()/this->k_ + + phaseTransferCoeff*gasTurbulence.epsilon() + - fvm::Sp(phaseTransferCoeff, this->epsilon_); +} + + +template +void LaheyKEpsilon::correct() +{ + kEpsilon::correct(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.H b/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.H new file mode 100644 index 0000000000..8766fe454f --- /dev/null +++ b/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::RASModels::LaheyKEpsilon + +Group + grpRASTurbulence + +Description + +SourceFiles + LaheyKEpsilon.C + +\*---------------------------------------------------------------------------*/ + +#ifndef LaheyKEpsilon_H +#define LaheyKEpsilon_H + +#include "kEpsilon.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class LaheyKEpsilon Declaration +\*---------------------------------------------------------------------------*/ + +template +class LaheyKEpsilon +: + public kEpsilon +{ + // Private data + + mutable const PhaseIncompressibleTurbulenceModel + < + typename BasicTurbulenceModel::transportModel + > *gasTurbulencePtr_; + + +protected: + + // Protected data + + // Model coefficients + + dimensionedScalar alphaInversion_; + dimensionedScalar Cp_; + dimensionedScalar Cmub_; + + + // Protected member functions + + virtual void correctNut(); + tmp bubbleG() const; + tmp phaseTransferCoeff() const; + virtual tmp kSource() const; + virtual tmp epsilonSource() const; + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("LaheyKEpsilon"); + + + // Constructors + + //- Construct from components + LaheyKEpsilon + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName, + const word& type = typeName + ); + + + //- Destructor + virtual ~LaheyKEpsilon() + {} + + + // Member Functions + + //- Return the turbulence model for the gas phase + const PhaseIncompressibleTurbulenceModel& + gasTurbulence() const; + + //- Solve the turbulence equations and correct the turbulence viscosity + virtual void correct(); + + //- Read RASProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "LaheyKEpsilon.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C b/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C new file mode 100644 index 0000000000..a237a8998c --- /dev/null +++ b/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C @@ -0,0 +1,280 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "continuousGasKEpsilon.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +continuousGasKEpsilon::continuousGasKEpsilon +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName, + const word& type +) +: + kEpsilon + ( + alpha, + rho, + U, + alphaPhi, + phi, + transport, + propertiesName, + type + ), + + liquidTurbulencePtr_(NULL), + + nutEff_ + ( + IOobject + ( + IOobject::groupName("nutEff", U.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + this->nut_ + ), + + alphaInversion_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaInversion", + this->coeffDict_, + 0.7 + ) + ) +{ + if (type == typeName) + { + kEpsilon::correctNut(); + this->printCoeffs(type); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool continuousGasKEpsilon::read() +{ + if (kEpsilon::read()) + { + alphaInversion_.readIfPresent(this->coeffDict()); + + return true; + } + else + { + return false; + } +} + + +template +void continuousGasKEpsilon::correctNut() +{ + kEpsilon::correctNut(); + + const turbulenceModel& liquidTurbulence = this->liquidTurbulence(); + const transportModel& gas = this->transport(); + const twoPhaseSystem& fluid = gas.fluid(); + const transportModel& liquid = fluid.otherPhase(gas); + + volScalarField thetal(liquidTurbulence.k()/liquidTurbulence.epsilon()); + volScalarField thetag((1.0/(18*liquid.nu()))*sqr(gas.d())); + volScalarField expThetar(exp(min(thetal/thetag, 50.0))); + volScalarField omega(sqr(expThetar - 1)/(sqr(expThetar) - 1)); + + nutEff_ = omega*liquidTurbulence.nut(); +} + + +template +const turbulenceModel& +continuousGasKEpsilon::liquidTurbulence() const +{ + if (!liquidTurbulencePtr_) + { + const volVectorField& U = this->U_; + + const transportModel& gas = this->transport(); + const twoPhaseSystem& fluid = gas.fluid(); + const transportModel& liquid = fluid.otherPhase(gas); + + liquidTurbulencePtr_ = + &U.db().lookupObject + ( + IOobject::groupName + ( + turbulenceModel::propertiesName, + liquid.name() + ) + ); + } + + return *liquidTurbulencePtr_; +} + + +template +tmp +continuousGasKEpsilon::nuEff() const +{ + volScalarField blend + ( + max(min((this->alpha_ - 0.5)/(alphaInversion_ - 0.5), 1.0), 0.0) + ); + + return tmp + ( + new volScalarField + ( + IOobject::groupName("nuEff", this->U_.group()), + blend*this->nut_ + + (1.0 - blend)*rhoEff()*nutEff_/this->transport().rho() + + this->nu() + ) + ); +} + + +template +tmp +continuousGasKEpsilon::rhoEff() const +{ + const transportModel& gas = this->transport(); + const twoPhaseSystem& fluid = gas.fluid(); + const transportModel& liquid = fluid.otherPhase(gas); + + return tmp + ( + new volScalarField + ( + IOobject::groupName("rhoEff", this->U_.group()), + gas.rho() + (fluid.Cvm() + 3.0/20.0)*liquid.rho() + ) + ); +} + + +template +tmp +continuousGasKEpsilon::phaseTransferCoeff() const +{ + const volVectorField& U = this->U_; + const alphaField& alpha = this->alpha_; + const rhoField& rho = this->rho_; + + const turbulenceModel& liquidTurbulence = this->liquidTurbulence(); + + return + ( + max(alphaInversion_ - alpha, 0.0) + *rho + *min + ( + liquidTurbulence.epsilon()/liquidTurbulence.k(), + 1.0/U.time().deltaT() + ) + ); +} + + +template +tmp +continuousGasKEpsilon::kSource() const +{ + const turbulenceModel& liquidTurbulence = this->liquidTurbulence(); + const volScalarField phaseTransferCoeff(this->phaseTransferCoeff()); + + return + phaseTransferCoeff*liquidTurbulence.k() + - fvm::Sp(phaseTransferCoeff, this->k_); +} + + +template +tmp +continuousGasKEpsilon::epsilonSource() const +{ + const turbulenceModel& liquidTurbulence = this->liquidTurbulence(); + const volScalarField phaseTransferCoeff(this->phaseTransferCoeff()); + + return + phaseTransferCoeff*liquidTurbulence.epsilon() + - fvm::Sp(phaseTransferCoeff, this->epsilon_); +} + + +template +tmp +continuousGasKEpsilon::R() const +{ + tmp tk(this->k()); + + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + IOobject::groupName("R", this->U_.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*tk() - (nutEff_)*dev(twoSymm(fvc::grad(this->U_))), + tk().boundaryField().types() + ) + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.H b/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.H new file mode 100644 index 0000000000..ecb9486339 --- /dev/null +++ b/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::RASModels::continuousGasKEpsilon + +Group + grpRASTurbulence + +Description + +SourceFiles + continuousGasKEpsilon.C + +\*---------------------------------------------------------------------------*/ + +#ifndef continuousGasKEpsilon_H +#define continuousGasKEpsilon_H + +#include "kEpsilon.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class continuousGasKEpsilon Declaration +\*---------------------------------------------------------------------------*/ + +template +class continuousGasKEpsilon +: + public kEpsilon +{ + // Private data + + mutable const turbulenceModel *liquidTurbulencePtr_; + + volScalarField nutEff_; + + +protected: + + // Protected data + + // Model coefficients + + dimensionedScalar alphaInversion_; + + + // Protected member functions + + virtual void correctNut(); + tmp phaseTransferCoeff() const; + virtual tmp kSource() const; + virtual tmp epsilonSource() const; + + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("continuousGasKEpsilon"); + + + // Constructors + + //- Construct from components + continuousGasKEpsilon + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName, + const word& type = typeName + ); + + + //- Destructor + virtual ~continuousGasKEpsilon() + {} + + + // Member Functions + + //- Return the turbulence model for the liquid phase + const turbulenceModel& liquidTurbulence() const; + + //- Return the effective viscosity + virtual tmp nuEff() const; + + //- Return the effective density for the stress + virtual tmp rhoEff() const; + + //- Return the Reynolds stress tensor + virtual tmp R() const; + + //- Read RASProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "continuousGasKEpsilon.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/Make/files b/src/TurbulenceModels/turbulenceModel/Make/files new file mode 100644 index 0000000000..b1b166316c --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/Make/files @@ -0,0 +1,49 @@ +turbulenceModel.C + +derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C +derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C + +/* Wall functions */ +wallFunctions = RAS/derivedFvPatchFields/wallFunctions + +nutWallFunctions = $(wallFunctions)/nutWallFunctions +$(nutWallFunctions)/nutWallFunction/nutWallFunctionFvPatchScalarField.C + +$(nutWallFunctions)/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C + +$(nutWallFunctions)/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C + +epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions +$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +$(epsilonWallFunctions)/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C + +omegaWallFunctions = $(wallFunctions)/omegaWallFunctions +$(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C + +kqRWallFunctions = $(wallFunctions)/kqRWallFunctions +$(kqRWallFunctions)/kqRWallFunction/kqRWallFunctionFvPatchFields.C +$(kqRWallFunctions)/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C + +/* +v2WallFunctions = $(wallFunctions)/v2WallFunctions +$(v2WallFunctions)/v2WallFunction/v2WallFunctionFvPatchScalarField.C + +fWallFunctions = $(wallFunctions)/fWallFunctions +$(fWallFunctions)/fWallFunction/fWallFunctionFvPatchScalarField.C +*/ + +/* Patch fields */ +RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C +RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C +RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C + +/* backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C */ + +LIB = $(FOAM_LIBBIN)/libturbulenceModels diff --git a/src/TurbulenceModels/turbulenceModel/Make/options b/src/TurbulenceModels/turbulenceModel/Make/options new file mode 100644 index 0000000000..a3ae8da833 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools diff --git a/src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.C b/src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.C new file mode 100644 index 0000000000..44a46a97bb --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.C @@ -0,0 +1,184 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "RASModel.H" + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +template +void Foam::RASModel::printCoeffs(const word& type) +{ + if (printCoeffs_) + { + Info<< type << "Coeffs" << coeffDict_ << endl; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::RASModel::RASModel +( + const word& type, + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +: + BasicTurbulenceModel + ( + alpha, + rho, + U, + alphaPhi, + phi, + transport, + propertiesName + ), + + RASDict_(this->subOrEmptyDict("RAS")), + turbulence_(RASDict_.lookup("turbulence")), + printCoeffs_(RASDict_.lookupOrDefault("printCoeffs", false)), + coeffDict_(RASDict_.subOrEmptyDict(type + "Coeffs")), + + kMin_("kMin", sqr(dimVelocity), SMALL), + epsilonMin_("epsilonMin", kMin_.dimensions()/dimTime, SMALL), + omegaMin_("omegaMin", dimless/dimTime, SMALL) +{ + kMin_.readIfPresent(RASDict_); + epsilonMin_.readIfPresent(RASDict_); + omegaMin_.readIfPresent(RASDict_); + + // Force the construction of the mesh deltaCoeffs which may be needed + // for the construction of the derived models and BCs + this->mesh_.deltaCoeffs(); +} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +template +Foam::autoPtr > +Foam::RASModel::New +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +{ + // get model name, but do not register the dictionary + // otherwise it is registered in the database twice + const word modelType + ( + IOdictionary + ( + IOobject + ( + IOobject::groupName(propertiesName, U.group()), + U.time().constant(), + U.db(), + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ).subDict("RAS").lookup("RASModel") + ); + + Info<< "Selecting RAS turbulence model " << modelType << endl; + + typename dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(modelType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "RASModel::New" + "(" + "const volScalarField&, " + "const volVectorField&, " + "const surfaceScalarField&, " + "transportModel&, " + "const word&" + ")" + ) << "Unknown RASModel type " + << modelType << nl << nl + << "Valid RASModel types:" << endl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter()(alpha, rho, U, alphaPhi, phi, transport, propertiesName) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::RASModel::correct() +{ + BasicTurbulenceModel::correct(); +} + + +template +bool Foam::RASModel::read() +{ + if (turbulenceModel::read()) + { + RASDict_ <<= this->subDict("RAS"); + RASDict_.lookup("turbulence") >> turbulence_; + + if (const dictionary* dictPtr = RASDict_.subDictPtr(type() + "Coeffs")) + { + coeffDict_ <<= *dictPtr; + } + + kMin_.readIfPresent(RASDict_); + epsilonMin_.readIfPresent(RASDict_); + omegaMin_.readIfPresent(RASDict_); + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.H b/src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.H new file mode 100644 index 0000000000..61aefd784f --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/RASModel/RASModel.H @@ -0,0 +1,267 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Namespace + Foam::RASModels + +Description + Namespace for RAS turbulence models. + +Class + Foam::RASModel + +Description + Templated abstract base class for RAS turbulence models + +SourceFiles + RASModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef RASModel_H +#define RASModel_H + +#include "TurbulenceModel.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "fvm.H" +#include "fvc.H" +#include "fvMatrices.H" +#include "IOdictionary.H" +#include "Switch.H" +#include "bound.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class RASModel Declaration +\*---------------------------------------------------------------------------*/ + +template +class RASModel +: + public BasicTurbulenceModel +{ + +protected: + + // Protected data + + //- RAS coefficients dictionary + dictionary RASDict_; + + //- Turbulence on/off flag + Switch turbulence_; + + //- Flag to print the model coeffs at run-time + Switch printCoeffs_; + + //- Model coefficients dictionary + dictionary coeffDict_; + + //- Lower limit of k + dimensionedScalar kMin_; + + //- Lower limit of epsilon + dimensionedScalar epsilonMin_; + + //- Lower limit for omega + dimensionedScalar omegaMin_; + + + // Protected Member Functions + + //- Print model coefficients + virtual void printCoeffs(const word& type); + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + RASModel(const RASModel&); + + //- Disallow default bitwise assignment + void operator=(const RASModel&); + + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("RAS"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + RASModel, + dictionary, + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName + ), + (alpha, rho, U, alphaPhi, phi, transport, propertiesName) + ); + + + // Constructors + + //- Construct from components + RASModel + ( + const word& type, + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName + ); + + + // Selectors + + //- Return a reference to the selected RAS model + static autoPtr New + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~RASModel() + {} + + + // Member Functions + + // Access + + //- Return the lower allowable limit for k (default: SMALL) + const dimensionedScalar& kMin() const + { + return kMin_; + } + + //- Return the lower allowable limit for epsilon (default: SMALL) + const dimensionedScalar& epsilonMin() const + { + return epsilonMin_; + } + + //- Return the lower allowable limit for omega (default: SMALL) + const dimensionedScalar& omegaMin() const + { + return omegaMin_; + } + + //- Allow kMin to be changed + dimensionedScalar& kMin() + { + return kMin_; + } + + //- Allow epsilonMin to be changed + dimensionedScalar& epsilonMin() + { + return epsilonMin_; + } + + //- Allow omegaMin to be changed + dimensionedScalar& omegaMin() + { + return omegaMin_; + } + + //- Const access to the coefficients dictionary + virtual const dictionary& coeffDict() const + { + return coeffDict_; + } + + + //- Return the effective viscosity + virtual tmp nuEff() const + { + return tmp + ( + new volScalarField + ( + IOobject::groupName("nuEff", this->U_.group()), + this->nut() + this->nu() + ) + ); + } + + //- Return the effective viscosity on patch + virtual tmp nuEff(const label patchi) const + { + return this->nut(patchi) + this->nu(patchi); + } + + //- Solve the turbulence equations and correct the turbulence viscosity + virtual void correct(); + + //- Read RASProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "RASModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C new file mode 100644 index 0000000000..d621d88845 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "atmBoundaryLayerInletEpsilonFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +atmBoundaryLayerInletEpsilonFvPatchScalarField:: +atmBoundaryLayerInletEpsilonFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + z_(vector::zero), + kappa_(0.41), + Uref_(0), + Href_(0), + z0_(0), + zGround_(0), + Ustar_(0) +{} + + +atmBoundaryLayerInletEpsilonFvPatchScalarField:: +atmBoundaryLayerInletEpsilonFvPatchScalarField +( + const atmBoundaryLayerInletEpsilonFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + z_(ptf.z_), + kappa_(ptf.kappa_), + Uref_(ptf.Uref_), + Href_(ptf.Href_), + z0_(ptf.z0_, mapper), + zGround_(ptf.zGround_, mapper), + Ustar_(ptf.Ustar_, mapper) +{} + + +atmBoundaryLayerInletEpsilonFvPatchScalarField:: +atmBoundaryLayerInletEpsilonFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF), + z_(dict.lookup("z")), + kappa_(dict.lookupOrDefault("kappa", 0.41)), + Uref_(readScalar(dict.lookup("Uref"))), + Href_(readScalar(dict.lookup("Href"))), + z0_("z0", dict, p.size()), + zGround_("zGround", dict, p.size()), + Ustar_(p.size()) +{ + if (mag(z_) < SMALL) + { + FatalErrorIn + ( + "atmBoundaryLayerInletEpsilonFvPatchScalarField" + "(" + "const fvPatch&, " + "const DimensionedField&, " + "const dictionary&" + ")" + ) + << "magnitude of z vector must be greater than zero" + << abort(FatalError); + } + + forAll (Ustar_, i) + { + Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001))); + } + + z_ /= mag(z_); + + const vectorField& c = patch().Cf(); + scalarField::operator=(pow3(Ustar_)/(kappa_*((c & z_) - zGround_ + z0_))); +} + + +atmBoundaryLayerInletEpsilonFvPatchScalarField:: +atmBoundaryLayerInletEpsilonFvPatchScalarField +( + const atmBoundaryLayerInletEpsilonFvPatchScalarField& blpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(blpsf, iF), + z_(blpsf.z_), + kappa_(blpsf.kappa_), + Uref_(blpsf.Uref_), + Href_(blpsf.Href_), + z0_(blpsf.z0_), + zGround_(blpsf.zGround_), + Ustar_(blpsf.Ustar_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void atmBoundaryLayerInletEpsilonFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + z0_.autoMap(m); + zGround_.autoMap(m); + Ustar_.autoMap(m); +} + + +void atmBoundaryLayerInletEpsilonFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const atmBoundaryLayerInletEpsilonFvPatchScalarField& blptf = + refCast(ptf); + + z0_.rmap(blptf.z0_, addr); + zGround_.rmap(blptf.zGround_, addr); + Ustar_.rmap(blptf.Ustar_, addr); +} + + +void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("z") + << z_ << token::END_STATEMENT << nl; + os.writeKeyword("kappa") + << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("Uref") + << Uref_ << token::END_STATEMENT << nl; + os.writeKeyword("Href") + << Href_ << token::END_STATEMENT << nl; + z0_.writeEntry("z0", os); + zGround_.writeEntry("zGround", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + atmBoundaryLayerInletEpsilonFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H new file mode 100644 index 0000000000..f18ce28dba --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::atmBoundaryLayerInletEpsilonFvPatchScalarField + +Group + grpRASBoundaryConditions grpInletBoundaryConditions + +Description + This boundary condition specifies an inlet value for the turbulence + dissipation, \f$\epsilon\f$ (\c epsilon), appropriate for atmospheric + boundary layers (ABL), and designed to be used in conjunction with the + \c ABLInletVelocity inlet velocity boundary condition. + + \f[ + \epsilon = \frac{(U^*)^3}{K(z - z_g + z_0)} + \f] + + where + \vartable + U^* | frictional velocity + K | Karman's constant + z | vertical co-ordinate [m] + z_0 | surface roughness length [m] + z_g | minimum vlaue in z direction [m] + \endvartable + + and: + + \f[ + U^* = K \frac{U_{ref}}{ln\left(\frac{Z_{ref} + z_0}{z_0}\right)} + \f] + + where: + \vartable + U_{ref} | reference velocity at \f$Z_{ref}\f$ [m/s] + Z_{ref} | reference height [m] + \endvartable + + \heading Patch usage + + \table + Property | Description | Required | Default value + z | vertical co-ordinate [m] | yes | + kappa | Karman's constanat | no | 0.41 + Uref | reference velocity [m/s] | yes | + Href | reference height [m] | yes | + z0 | surface roughness length [m] | yes | + zGround | minimum z co-ordinate [m] | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type atmBoundaryLayerInletEpsilon; + z 1.0; + kappa 0.41; + Uref 1.0; + Href 0.0; + z0 uniform 0.0; + zGround uniform 0.0; + } + \endverbatim + + Reference: + D.M. Hargreaves and N.G. Wright, "On the use of the k-epsilon model + in commercial CFD software to model the neutral atmospheric boundary + layer", Journal of Wind Engineering and Industrial Aerodynamics + 95(2007), pp 355-369. + +SourceFiles + atmBoundaryLayerInletEpsilonFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef atmBoundaryLayerInletEpsilonFvPatchScalarField_H +#define atmBoundaryLayerInletEpsilonFvPatchScalarField_H + +#include "fvPatchFields.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class atmBoundaryLayerInletEpsilonFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class atmBoundaryLayerInletEpsilonFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Direction of the z-coordinate + vector z_; + + //- Von Karman constant + const scalar kappa_; + + //- Reference velocity + const scalar Uref_; + + //- Reference height + const scalar Href_; + + //- Surface roughness length + scalarField z0_; + + //- Minimum co-ordinate value in z direction + scalarField zGround_; + + //- Frictional velocity + scalarField Ustar_; + + +public: + + //- Runtime type information + TypeName("atmBoundaryLayerInletEpsilon"); + + + // Constructors + + //- Construct from patch and internal field + atmBoundaryLayerInletEpsilonFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + atmBoundaryLayerInletEpsilonFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // atmBoundaryLayerInletEpsilonFvPatchScalarField onto a new patch + atmBoundaryLayerInletEpsilonFvPatchScalarField + ( + const atmBoundaryLayerInletEpsilonFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new atmBoundaryLayerInletEpsilonFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + atmBoundaryLayerInletEpsilonFvPatchScalarField + ( + const atmBoundaryLayerInletEpsilonFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new atmBoundaryLayerInletEpsilonFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return max value + const scalarField& Ustar() const + { + return Ustar_; + } + + //- Return z direction + const vector& z() const + { + return z_; + } + + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C new file mode 100644 index 0000000000..0966e50607 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "atmBoundaryLayerInletVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +atmBoundaryLayerInletVelocityFvPatchVectorField:: +atmBoundaryLayerInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(p, iF), + Ustar_(0), + n_(pTraits::zero), + z_(pTraits::zero), + z0_(0), + kappa_(0.41), + Uref_(0), + Href_(0), + zGround_(0) +{} + + +atmBoundaryLayerInletVelocityFvPatchVectorField:: +atmBoundaryLayerInletVelocityFvPatchVectorField +( + const atmBoundaryLayerInletVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchVectorField(ptf, p, iF, mapper), + Ustar_(ptf.Ustar_, mapper), + n_(ptf.n_), + z_(ptf.z_), + z0_(ptf.z0_, mapper), + kappa_(ptf.kappa_), + Uref_(ptf.Uref_), + Href_(ptf.Href_), + zGround_(ptf.zGround_, mapper) +{} + + +atmBoundaryLayerInletVelocityFvPatchVectorField:: +atmBoundaryLayerInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF), + Ustar_(p.size()), + n_(dict.lookup("n")), + z_(dict.lookup("z")), + z0_("z0", dict, p.size()), + kappa_(dict.lookupOrDefault("kappa", 0.41)), + Uref_(readScalar(dict.lookup("Uref"))), + Href_(readScalar(dict.lookup("Href"))), + zGround_("zGround", dict, p.size()) +{ + if (mag(n_) < SMALL || mag(z_) < SMALL) + { + FatalErrorIn + ( + "atmBoundaryLayerInletVelocityFvPatchVectorField" + "(" + "const fvPatch&, " + "const DimensionedField&, " + "onst dictionary&" + ")" + ) + << "magnitude of n or z must be greater than zero" + << abort(FatalError); + } + + n_ /= mag(n_); + z_ /= mag(z_); + + forAll (Ustar_, i) + { + Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001))); + } + + const vectorField& c = patch().Cf(); + const scalarField coord(c & z_); + scalarField Un(coord.size()); + + forAll(coord, i) + { + if ((coord[i] - zGround_[i]) < Href_) + { + Un[i] = + (Ustar_[i]/kappa_) + * log((coord[i] - zGround_[i] + z0_[i])/max(z0_[i], 0.001)); + } + else + { + Un[i] = Uref_; + } + } + + vectorField::operator=(n_*Un); +} + + +atmBoundaryLayerInletVelocityFvPatchVectorField:: +atmBoundaryLayerInletVelocityFvPatchVectorField +( + const atmBoundaryLayerInletVelocityFvPatchVectorField& blpvf, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(blpvf, iF), + Ustar_(blpvf.Ustar_), + n_(blpvf.n_), + z_(blpvf.z_), + z0_(blpvf.z0_), + kappa_(blpvf.kappa_), + Uref_(blpvf.Uref_), + Href_(blpvf.Href_), + zGround_(blpvf.zGround_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void atmBoundaryLayerInletVelocityFvPatchVectorField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchVectorField::autoMap(m); + z0_.autoMap(m); + zGround_.autoMap(m); + Ustar_.autoMap(m); +} + + +void atmBoundaryLayerInletVelocityFvPatchVectorField::rmap +( + const fvPatchVectorField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchVectorField::rmap(ptf, addr); + + const atmBoundaryLayerInletVelocityFvPatchVectorField& blptf = + refCast(ptf); + + z0_.rmap(blptf.z0_, addr); + zGround_.rmap(blptf.zGround_, addr); + Ustar_.rmap(blptf.Ustar_, addr); +} + + +void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + z0_.writeEntry("z0", os) ; + os.writeKeyword("n") + << n_ << token::END_STATEMENT << nl; + os.writeKeyword("z") + << z_ << token::END_STATEMENT << nl; + os.writeKeyword("kappa") + << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("Uref") + << Uref_ << token::END_STATEMENT << nl; + os.writeKeyword("Href") + << Href_ << token::END_STATEMENT << nl; + zGround_.writeEntry("zGround", os) ; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchVectorField, + atmBoundaryLayerInletVelocityFvPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..b2f7245ccb --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H @@ -0,0 +1,266 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::atmBoundaryLayerInletVelocityFvPatchVectorField + +Group + grpRASBoundaryConditions grpInletBoundaryConditions + +Description + This boundary condition specifies a velocity inlet profile appropriate + for atmospheric boundary layers (ABL). The profile is derived from the + friction velocity, flow direction and the direction of the parabolic + co-ordinate \c z. + + \f[ + U = \frac{U^*}{K} ln\left(\frac{z - z_g + z_0}{z_0}\right) + \f] + + where + \vartable + U^* | frictional velocity + K | Karman's constant + z | vertical co-ordinate [m] + z_0 | surface roughness length [m] + z_g | minimum vlaue in z direction [m] + \endvartable + + and: + + \f[ + U^* = K \frac{U_{ref}}{ln\left(\frac{Z_{ref} + z_0}{z_0}\right)} + \f] + + where: + \vartable + U_{ref} | reference velocity at \f$Z_{ref}\f$ [m/s] + Z_{ref} | reference height [m] + \endvartable + + Reference: + D.M. Hargreaves and N.G. Wright, "On the use of the k-epsilon model + in commercial CFD software to model the neutral atmospheric boundary + layer", Journal of Wind Engineering and Industrial Aerodynamics + 95(2007), pp 355-369. + + \heading Patch usage + + \table + Property | Description | Required | Default value + n | flow direction | yes | + z | vertical co-ordinate [m] | yes | + kappa | Karman's constanat | no | 0.41 + Uref | reference velocity [m/s] | yes | + Href | reference height [m] | yes | + z0 | surface roughness length [m] | yes | + zGround | minimum z co-ordinate [m] | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type atmBoundaryLayerInletVelocity; + n (0 1 0); + z 1.0; + kappa 0.41; + Uref 1.0; + Href 0.0; + z0 uniform 0.0; + zGround uniform 0.0; + } + \endverbatim + +Note + D.M. Hargreaves and N.G. Wright recommend Gamma epsilon in the + k-epsilon model should be changed from 1.3 to 1.11 for consistency. + The roughness height (Er) is given by Er = 20 z0 following the same + reference. + +SourceFiles + atmBoundaryLayerInletVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef atmBoundaryLayerInletVelocityFvPatchVectorField_H +#define atmBoundaryLayerInletVelocityFvPatchVectorField_H + +#include "fvPatchFields.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class atmBoundaryLayerInletVelocityFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class atmBoundaryLayerInletVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Frictional velocity + scalarField Ustar_; + + //- Flow direction + vector n_; + + //- Direction of the z-coordinate + vector z_; + + //- Surface roughness lenght + scalarField z0_; + + //- Von Karman constant + const scalar kappa_; + + //- Reference velocity + const scalar Uref_; + + //- Reference hight + const scalar Href_; + + //- Minimum corrdinate value in z direction + scalarField zGround_; + + +public: + + //- Runtime type information + TypeName("atmBoundaryLayerInletVelocity"); + + + // Constructors + + //- Construct from patch and internal field + atmBoundaryLayerInletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + atmBoundaryLayerInletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // atmBoundaryLayerInletVelocityFvPatchVectorField onto a new patch + atmBoundaryLayerInletVelocityFvPatchVectorField + ( + const atmBoundaryLayerInletVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new atmBoundaryLayerInletVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + atmBoundaryLayerInletVelocityFvPatchVectorField + ( + const atmBoundaryLayerInletVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new atmBoundaryLayerInletVelocityFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return Ustar + const scalarField& Ustar() const + { + return Ustar_; + } + + //- Return flow direction + const vector& n() const + { + return n_; + } + + //- Return z direction + const vector& z() const + { + return z_; + } + + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchVectorField&, + const labelList& + ); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/doc/incompressibleRASBoundaryConditionsDoc.H b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/doc/incompressibleRASBoundaryConditionsDoc.H new file mode 100644 index 0000000000..3cdbb45d35 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/doc/incompressibleRASBoundaryConditionsDoc.H @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +\defgroup grpRASBoundaryConditions RAS boundary conditions +@{ + \ingroup grpRASTurbulence + This group contains RAS turbulence model boundary conditions +@} + +\defgroup grpWallFunctions RAS wall functions +@{ + \ingroup grpRASBoundaryConditions + This group contains RAS turbulence model wall functions +@} + + +\*---------------------------------------------------------------------------*/ diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C new file mode 100644 index 0000000000..4714ec09ed --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -0,0 +1,186 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "turbulentMixingLengthDissipationRateInletFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + inletOutletFvPatchScalarField(p, iF), + mixingLength_(0.0), + phiName_("phi"), + kName_("k") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + inletOutletFvPatchScalarField(ptf, p, iF, mapper), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) +{} + + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + inletOutletFvPatchScalarField(p, iF), + mixingLength_(readScalar(dict.lookup("mixingLength"))), + phiName_(dict.lookupOrDefault("phi", "phi")), + kName_(dict.lookupOrDefault("k", "k")) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf +) +: + inletOutletFvPatchScalarField(ptf), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) +{} + + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + inletOutletFvPatchScalarField(ptf, iF), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentMixingLengthDissipationRateInletFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Lookup Cmu corresponding to the turbulence model selected + const turbulenceModel& turbulence = db().lookupObject + ( + IOobject::groupName + ( + turbulenceModel::propertiesName, + dimensionedInternalField().group() + ) + ); + + const scalar Cmu = + turbulence.coeffDict().lookupOrDefault("Cmu", 0.09); + + const scalar Cmu75 = pow(Cmu, 0.75); + + const fvPatchScalarField& kp = + patch().lookupPatchField(kName_); + + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); + + this->refValue() = Cmu75*kp*sqrt(kp)/mixingLength_; + this->valueFraction() = 1.0 - pos(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); +} + + +void turbulentMixingLengthDissipationRateInletFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("mixingLength") + << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentMixingLengthDissipationRateInletFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H new file mode 100644 index 0000000000..d9b5e481c0 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::turbulentMixingLengthDissipationRateInletFvPatchScalarField + +Group + grpRASBoundaryConditions grpInletBoundaryConditions + +Description + This boundary condition provides a turbulence dissipation, \f$\epsilon\f$ + (epsilon) inlet condition based on a specified mixing length. The patch + values are calculated using: + + \f[ + \epsilon_p = \frac{C_{\mu}^{0.75} k^{1.5}}{L} + \f] + + where + + \vartable + \epsilon_p | patch epsilon values + C_{\mu} | Model coefficient, set to 0.09 + k | turbulence kinetic energy + L | length scale + \endvartable + + \heading Patch usage + + \table + Property | Description | Required | Default value + mixingLength | Length scale [m] | yes | + phi | flux field name | no | phi + k | turbulence kinetic energy field name | no | k + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type turbulentMixingLengthDissipationRateInlet; + mixingLength 0.005; + value uniform 200; // placeholder + } + \endverbatim + +Note + In the event of reverse flow, a zero-gradient condition is applied + +SeeAlso + Foam::inletOutletFvPatchField + +SourceFiles + turbulentMixingLengthDissipationRateInletFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentMixingLengthDissipationRateInlet_H +#define turbulentMixingLengthDissipationRateInlet_H + +#include "inletOutletFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentMixingLengthDissipationRateInletFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentMixingLengthDissipationRateInletFvPatchScalarField +: + public inletOutletFvPatchScalarField +{ + // Private data + + //- turbulent length scale + scalar mixingLength_; + + //- Name of the flux field + word phiName_; + + //- Name of the turbulent kinetic energy field + word kName_; + + +public: + + //- Runtime type information + TypeName("turbulentMixingLengthDissipationRateInlet"); + + + // Constructors + + //- Construct from patch and internal field + turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentMixingLengthDissipationRateInletFvPatchScalarField + // onto a new patch + turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentMixingLengthDissipationRateInletFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C new file mode 100644 index 0000000000..0ce1cd6763 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -0,0 +1,182 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "turbulentMixingLengthFrequencyInletFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + inletOutletFvPatchScalarField(p, iF), + mixingLength_(0.0), + phiName_("undefined-phi"), + kName_("undefined-k") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + inletOutletFvPatchScalarField(ptf, p, iF, mapper), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) +{} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + inletOutletFvPatchScalarField(p, iF), + mixingLength_(readScalar(dict.lookup("mixingLength"))), + phiName_(dict.lookupOrDefault("phi", "phi")), + kName_(dict.lookupOrDefault("k", "k")) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf +) +: + inletOutletFvPatchScalarField(ptf), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) +{} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + inletOutletFvPatchScalarField(ptf, iF), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Lookup Cmu corresponding to the turbulence model selected + const turbulenceModel& turbulence = db().lookupObject + ( + IOobject::groupName + ( + turbulenceModel::propertiesName, + dimensionedInternalField().group() + ) + ); + + const scalar Cmu = + turbulence.coeffDict().lookupOrDefault("Cmu", 0.09); + + const scalar Cmu25 = pow(Cmu, 0.25); + + const fvPatchScalarField& kp = + patch().lookupPatchField(kName_); + + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); + + this->refValue() = sqrt(kp)/(Cmu25*mixingLength_); + this->valueFraction() = 1.0 - pos(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); +} + + +void turbulentMixingLengthFrequencyInletFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("mixingLength") + << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentMixingLengthFrequencyInletFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H new file mode 100644 index 0000000000..f16d5a4648 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H @@ -0,0 +1,203 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::turbulentMixingLengthFrequencyInletFvPatchScalarField + +Group + grpRASBoundaryConditions grpInletBoundaryConditions + +Description + This boundary condition provides a turbulence specific dissipation, + \f$\omega\f$ (omega) inlet condition based on a specified mixing length. + The patch values are calculated using: + + \f[ + \omega_p = \frac{k^{0.5}}{C_{\mu}^{0.25} L} + \f] + + where + + \vartable + \omega_p | patch omega values + C_{\mu} | Model coefficient, set to 0.09 + k | turbulence kinetic energy + L | length scale + \endvartable + + \heading Patch usage + + \table + Property | Description | Required | Default value + mixingLength | Length scale [m] | yes | + phi | flux field name | no | phi + k | turbulence kinetic energy field name | no | k + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type turbulentMixingLengthFrequencyInlet; + mixingLength 0.005; + value uniform 200; // placeholder + } + \endverbatim + +Note + In the event of reverse flow, a zero-gradient condition is applied + +SeeAlso + Foam::inletOutletFvPatchField + + +SourceFiles + turbulentMixingLengthFrequencyInletFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentMixingLengthFrequencyInletFvPatchScalarField_H +#define turbulentMixingLengthFrequencyInletFvPatchScalarField_H + +#include "inletOutletFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentMixingLengthFrequencyInletFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentMixingLengthFrequencyInletFvPatchScalarField +: + public inletOutletFvPatchScalarField +{ + // Private data + + //- Turbulent length scale + scalar mixingLength_; + + //- Name of the flux field + word phiName_; + + //- Name of the turbulent kinetic energy field + word kName_; + + +public: + + //- Runtime type information + TypeName("turbulentMixingLengthFrequencyInlet"); + + + // Constructors + + //- Construct from patch and internal field + turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentMixingLengthFrequencyInletFvPatchScalarField + // onto a new patch + turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + const turbulentMixingLengthFrequencyInletFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + const turbulentMixingLengthFrequencyInletFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentMixingLengthFrequencyInletFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..85ff9c446a --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "epsilonLowReWallFunctionFvPatchScalarField.H" +#include "turbulenceModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +scalar epsilonLowReWallFunctionFvPatchScalarField::yPlusLam +( + const scalar kappa, + const scalar E +) +{ + scalar ypl = 11.0; + + for (int i=0; i<10; i++) + { + ypl = log(max(E*ypl, 1))/kappa; + } + + return ypl; +} + + +void epsilonLowReWallFunctionFvPatchScalarField::calculate +( + const turbulenceModel& turbulence, + const List& cornerWeights, + const fvPatch& patch, + scalarField& G, + scalarField& epsilon +) +{ + const label patchi = patch.index(); + + const scalarField& y = turbulence.y()[patchi]; + + const scalar Cmu25 = pow025(Cmu_); + const scalar Cmu75 = pow(Cmu_, 0.75); + + const tmp tk = turbulence.k(); + const volScalarField& k = tk(); + + const tmp tnuw = turbulence.nu(patchi); + const scalarField& nuw = tnuw(); + + const tmp tnutw = turbulence.nut(patchi); + const scalarField& nutw = tnutw(); + + const fvPatchVectorField& Uw = turbulence.U().boundaryField()[patchi]; + + const scalarField magGradUw(mag(Uw.snGrad())); + + // Set epsilon and G + forAll(nutw, faceI) + { + label cellI = patch.faceCells()[faceI]; + + scalar yPlus = Cmu25*sqrt(k[cellI])*y[faceI]/nuw[faceI]; + + scalar w = cornerWeights[faceI]; + + if (yPlus > yPlusLam_) + { + epsilon[cellI] = w*Cmu75*pow(k[cellI], 1.5)/(kappa_*y[faceI]); + } + else + { + epsilon[cellI] = w*2.0*k[cellI]*nuw[faceI]/sqr(y[faceI]); + } + + G[cellI] = + w + *(nutw[faceI] + nuw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[cellI]) + /(kappa_*y[faceI]); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +epsilonLowReWallFunctionFvPatchScalarField:: +epsilonLowReWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + epsilonWallFunctionFvPatchScalarField(p, iF), + yPlusLam_(yPlusLam(kappa_, E_)) +{} + + +epsilonLowReWallFunctionFvPatchScalarField:: +epsilonLowReWallFunctionFvPatchScalarField +( + const epsilonLowReWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + epsilonWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + yPlusLam_(ptf.yPlusLam_) +{} + + +epsilonLowReWallFunctionFvPatchScalarField:: +epsilonLowReWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + epsilonWallFunctionFvPatchScalarField(p, iF, dict), + yPlusLam_(yPlusLam(kappa_, E_)) +{} + + +epsilonLowReWallFunctionFvPatchScalarField:: +epsilonLowReWallFunctionFvPatchScalarField +( + const epsilonLowReWallFunctionFvPatchScalarField& ewfpsf +) +: + epsilonWallFunctionFvPatchScalarField(ewfpsf), + yPlusLam_(ewfpsf.yPlusLam_) +{} + + +epsilonLowReWallFunctionFvPatchScalarField:: +epsilonLowReWallFunctionFvPatchScalarField +( + const epsilonLowReWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + epsilonWallFunctionFvPatchScalarField(ewfpsf, iF), + yPlusLam_(ewfpsf.yPlusLam_) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + epsilonLowReWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..ac9f3650a2 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::epsilonLowReWallFunctionFvPatchScalarField + +Group + grpWallFunctions + +Description + This boundary condition provides a turbulence dissipation wall function + condition for low- and high-Reynolds number turbulent flow cases. + + The condition can be applied to wall boundaries, whereby it inserts near + wall epsilon values directly into the epsilon equation to act as a + constraint. + + The model operates in two modes, based on the computed laminar-to-turbulent + switch-over y+ value derived from kappa and E. + + \heading Patch usage + + \table + Property | Description | Required | Default value + Cmu | model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | model coefficient | no | 9.8 + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type epsilonLowReWallFunction; + } + \endverbatim + +SeeAlso + Foam::epsilonWallFunctionFvPatchScalarField + +SourceFiles + epsilonLowReWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef epsilonLowReWallFunctionFvPatchScalarField_H +#define epsilonLowReWallFunctionFvPatchScalarField_H + +#include "epsilonWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class epsilonLowReWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class epsilonLowReWallFunctionFvPatchScalarField +: + public epsilonWallFunctionFvPatchScalarField +{ + +protected: + + // Protected data + + //- Y+ at the edge of the laminar sublayer + scalar yPlusLam_; + + + // Protected Member Functions + + //- Calculate the Y+ at the edge of the laminar sublayer + scalar yPlusLam(const scalar kappa, const scalar E); + + //- Calculate the epsilon and G + virtual void calculate + ( + const turbulenceModel& turbulence, + const List& cornerWeights, + const fvPatch& patch, + scalarField& G, + scalarField& epsilon + ); + + +public: + + //- Runtime type information + TypeName("epsilonLowReWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + epsilonLowReWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + epsilonLowReWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // epsilonLowReWallFunctionFvPatchScalarField + // onto a new patch + epsilonLowReWallFunctionFvPatchScalarField + ( + const epsilonLowReWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + epsilonLowReWallFunctionFvPatchScalarField + ( + const epsilonLowReWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new epsilonLowReWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + epsilonLowReWallFunctionFvPatchScalarField + ( + const epsilonLowReWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new epsilonLowReWallFunctionFvPatchScalarField(*this, iF) + ); + } + + //- Destructor + virtual ~epsilonLowReWallFunctionFvPatchScalarField() + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..8cffac6db6 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModel/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -0,0 +1,590 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "turbulenceModel.H" +#include "fvPatchFieldMapper.H" +#include "fvMatrix.H" +#include "volFields.H" +#include "wallFvPatch.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void epsilonWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("epsilonWallFunctionFvPatchScalarField::checkType()") + << "Invalid wall function specification" << nl + << " Patch type for patch " << patch().name() + << " must be wall" << nl + << " Current patch type is " << patch().type() << nl << endl + << abort(FatalError); + } +} + + +void epsilonWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ + os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; + os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; +} + + +void epsilonWallFunctionFvPatchScalarField::setMaster() +{ + if (master_ != -1) + { + return; + } + + const volScalarField& epsilon = + static_cast(this->dimensionedInternalField()); + + const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); + + label master = -1; + forAll(bf, patchi) + { + if (isA(bf[patchi])) + { + epsilonWallFunctionFvPatchScalarField& epf = epsilonPatch(patchi); + + if (master == -1) + { + master = patchi; + } + + epf.master() = master; + } + } +} + + +void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() +{ + if (initialised_) + { + return; + } + + const volScalarField& epsilon = + static_cast(this->dimensionedInternalField()); + + const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); + + const fvMesh& mesh = epsilon.mesh(); + + volScalarField weights + ( + IOobject + ( + "weights", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // do not register + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) + ); + + DynamicList