diff --git a/applications/solvers/incompressible/channelFoam/Make/files b/applications/solvers/incompressible/channelFoam/Make/files new file mode 100644 index 0000000000..35d5b4e617 --- /dev/null +++ b/applications/solvers/incompressible/channelFoam/Make/files @@ -0,0 +1,3 @@ +channelFoam.C + +EXE = $(FOAM_APPBIN)/channelFoam diff --git a/applications/solvers/incompressible/channelFoam/Make/options b/applications/solvers/incompressible/channelFoam/Make/options new file mode 100644 index 0000000000..594493ce21 --- /dev/null +++ b/applications/solvers/incompressible/channelFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/turbulenceModels/incompressible/LES/LESModel \ + -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +EXE_LIBS = \ + -lincompressibleLESModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/incompressible/channelFoam/channelFoam.C b/applications/solvers/incompressible/channelFoam/channelFoam.C new file mode 100644 index 0000000000..d21267b350 --- /dev/null +++ b/applications/solvers/incompressible/channelFoam/channelFoam.C @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + channelFoam + +Description + Incompressible LES solver for flow in a channel. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "LESModel.H" +#include "IFstream.H" +#include "OFstream.H" +#include "Random.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readTransportProperties.H" + #include "createFields.H" + #include "initContinuityErrs.H" + #include "createGradP.H" + + Info<< "\nStarting time loop\n" << endl; + + for(runTime++; !runTime.end(); runTime++) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "readPISOControls.H" + + #include "CourantNo.H" + + sgsModel->correct(); + + fvVectorMatrix UEqn + ( + fvm::ddt(U) + + fvm::div(phi, U) + + sgsModel->divDevBeff(U) + == + flowDirection*gradP + ); + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } + + + // --- PISO loop + + volScalarField rUA = 1.0/UEqn.A(); + + for (int corr=0; corr sgsModel + ( + incompressible::LESModel::New(U, phi, laminarTransport) + ); diff --git a/applications/solvers/incompressible/channelFoam/createGradP.H b/applications/solvers/incompressible/channelFoam/createGradP.H new file mode 100644 index 0000000000..9bb9bb0ba2 --- /dev/null +++ b/applications/solvers/incompressible/channelFoam/createGradP.H @@ -0,0 +1,24 @@ + dimensionedScalar gradP + ( + "gradP", + dimensionSet(0, 1, -2, 0, 0), + 0.0 + ); + + + IFstream gradPFile + ( + runTime.path()/runTime.timeName()/"uniform"/"gradP.raw" + ); + + if(gradPFile.good()) + { + gradPFile >> gradP; + Info<< "Reading average pressure gradient" <divDevReff(U) + ); + + if (ocorr != nOuterCorr-1) + { + UEqn.relax(); + } + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } diff --git a/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H new file mode 100644 index 0000000000..493c4e0929 --- /dev/null +++ b/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H @@ -0,0 +1,44 @@ +{ + wordList pcorrTypes(p.boundaryField().types()); + + for (label i=0; i turbulence + ( + incompressible::turbulenceModel::New(U, phi, laminarTransport) + ); + + Info<< "Reading field rAU if present\n" << endl; + volScalarField rAU + ( + IOobject + ( + "rAU", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh, + runTime.deltaT(), + zeroGradientFvPatchScalarField::typeName + ); diff --git a/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C new file mode 100644 index 0000000000..42aae85309 --- /dev/null +++ b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + turbDyMFoam + +Description + Transient solver for incompressible, flow of Newtonian fluids + on a moving mesh using the PIMPLE (merged PISO-SIMPLE) algorithm. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "turbulenceModel.H" +#include "dynamicFvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" + +# include "createTime.H" +# include "createDynamicFvMesh.H" +# include "readPISOControls.H" +# include "initContinuityErrs.H" +# include "createFields.H" +# include "readTimeControls.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { +# include "readControls.H" +# include "CourantNo.H" + + // Make the fluxes absolute + fvc::makeAbsolute(phi, U); + +# include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + mesh.update(); + + if (mesh.changing() && correctPhi) + { +# include "correctPhi.H" + } + + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phi, U); + + if (mesh.changing() && checkMeshCourantNo) + { +# include "meshCourantNo.H" + } + + // --- PIMPLE loop + for (int ocorr=0; ocorrcorrect(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H new file mode 100644 index 0000000000..9336616a1b --- /dev/null +++ b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H @@ -0,0 +1,14 @@ +# include "readTimeControls.H" +# include "readPISOControls.H" + + bool correctPhi = false; + if (piso.found("correctPhi")) + { + correctPhi = Switch(piso.lookup("correctPhi")); + } + + bool checkMeshCourantNo = false; + if (piso.found("checkMeshCourantNo")) + { + checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); + } diff --git a/applications/solvers/incompressible/pisoFoam/Make/files b/applications/solvers/incompressible/pisoFoam/Make/files new file mode 100644 index 0000000000..d9fdfd28ce --- /dev/null +++ b/applications/solvers/incompressible/pisoFoam/Make/files @@ -0,0 +1,3 @@ +pisoFoam.C + +EXE = $(FOAM_APPBIN)/pisoFoam diff --git a/applications/solvers/incompressible/pisoFoam/Make/options b/applications/solvers/incompressible/pisoFoam/Make/options new file mode 100644 index 0000000000..419f1ffcba --- /dev/null +++ b/applications/solvers/incompressible/pisoFoam/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/incompressible/pisoFoam/createFields.H b/applications/solvers/incompressible/pisoFoam/createFields.H new file mode 100644 index 0000000000..7cae304f6f --- /dev/null +++ b/applications/solvers/incompressible/pisoFoam/createFields.H @@ -0,0 +1,42 @@ + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "createPhi.H" + + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr turbulence + ( + incompressible::turbulenceModel::New(U, phi, laminarTransport) + ); diff --git a/applications/solvers/incompressible/pisoFoam/pisoFoam.C b/applications/solvers/incompressible/pisoFoam/pisoFoam.C new file mode 100644 index 0000000000..1c8a534db2 --- /dev/null +++ b/applications/solvers/incompressible/pisoFoam/pisoFoam.C @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + turbFoam + +Description + Transient solver for incompressible flow. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" + +# include "createTime.H" +# include "createMesh.H" +# include "createFields.H" +# include "initContinuityErrs.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + for (runTime++; !runTime.end(); runTime++) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + +# include "readPISOControls.H" +# include "CourantNo.H" + + // Pressure-velocity PISO corrector + { + // Momentum predictor + + fvVectorMatrix UEqn + ( + fvm::ddt(U) + + fvm::div(phi, U) + + turbulence->divDevReff(U) + ); + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } + + // --- PISO loop + + for (int corr=0; corrcorrect(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/cavitatingFoam/CourantNo.H b/applications/solvers/multiphase/cavitatingFoam/CourantNo.H new file mode 100644 index 0000000000..014944e191 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/CourantNo.H @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + CourantNo + +Description + Calculates and outputs the mean and maximum Courant Numbers. + +\*---------------------------------------------------------------------------*/ + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; +scalar acousticCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + surfaceScalarField SfUfbyDelta = + mesh.surfaceInterpolation::deltaCoeffs()*mag(phiv); + + CoNum = max(SfUfbyDelta/mesh.magSf()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) + .value()*runTime.deltaT().value(); + + acousticCoNum = max + ( + mesh.surfaceInterpolation::deltaCoeffs()/sqrt(fvc::interpolate(psi)) + ).value()*runTime.deltaT().value(); +} + +Info<< "phiv Courant Number mean: " << meanCoNum + << " max: " << CoNum + << " acoustic max: " << acousticCoNum + << endl; + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/cavitatingFoam/Make/files b/applications/solvers/multiphase/cavitatingFoam/Make/files new file mode 100644 index 0000000000..832391f03f --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/Make/files @@ -0,0 +1,3 @@ +cavitatingFoam.C + +EXE = $(FOAM_APPBIN)/cavitatingFoam diff --git a/applications/solvers/multiphase/cavitatingFoam/Make/options b/applications/solvers/multiphase/cavitatingFoam/Make/options new file mode 100644 index 0000000000..9cb749d63c --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude + +EXE_LIBS = \ + -lincompressibleTransportModels \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lfiniteVolume \ + -lbarotropicCompressibilityModel diff --git a/applications/solvers/multiphase/cavitatingFoam/UEqn.H b/applications/solvers/multiphase/cavitatingFoam/UEqn.H new file mode 100644 index 0000000000..11eaf617bc --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/UEqn.H @@ -0,0 +1,22 @@ + surfaceScalarField muEff + ( + "muEff", + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nut()) + ); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + - fvm::laplacian(muEff, U) + //- (fvc::grad(U) & fvc::grad(muf)) + - fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + ); + + UEqn.relax(); + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C new file mode 100644 index 0000000000..36ced22ada --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + cavitatingFoam + +Description + Transient cavitation code based on the barotropic equation of state. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "barotropicCompressibilityModel.H" +#include "twoPhaseMixture.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" + +# include "createTime.H" +# include "createMesh.H" +# include "readThermodynamicProperties.H" +# include "readControls.H" +# include "createFields.H" +# include "initContinuityErrs.H" +# include "compressibleCourantNo.H" +# include "setInitialDeltaT.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { +# include "readControls.H" +# include "CourantNo.H" +# include "setDeltaT.H" + + runTime++; + Info<< "Time = " << runTime.timeName() << nl << endl; + + for (int outerCorr=0; outerCorrcorrect(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "\n end \n"; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/cavitatingFoam/continuityErrs.H b/applications/solvers/multiphase/cavitatingFoam/continuityErrs.H new file mode 100644 index 0000000000..6f1622510f --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/continuityErrs.H @@ -0,0 +1,22 @@ +{ + volScalarField thermoRho = psi*p + (1.0 - gamma)*rhol0; + + dimensionedScalar totalMass = fvc::domainIntegrate(rho); + + scalar sumLocalContErr = + ( + fvc::domainIntegrate(mag(rho - thermoRho))/totalMass + ).value(); + + scalar globalContErr = + ( + fvc::domainIntegrate(rho - thermoRho)/totalMass + ).value(); + + cumulativeContErr += globalContErr; + + Info<< "time step continuity errors : sum local = " << sumLocalContErr + << ", global = " << globalContErr + << ", cumulative = " << cumulativeContErr + << endl; +} diff --git a/applications/solvers/multiphase/cavitatingFoam/createFields.H b/applications/solvers/multiphase/cavitatingFoam/createFields.H new file mode 100644 index 0000000000..dc2f5e6961 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/createFields.H @@ -0,0 +1,85 @@ + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + volScalarField gamma + ( + IOobject + ( + "gamma", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0)) + ); + gamma.oldTime(); + + Info<< "Creating compressibilityModel\n" << endl; + autoPtr psiModel = + barotropicCompressibilityModel::New + ( + thermodynamicProperties, + gamma + ); + + const volScalarField& psi = psiModel->psi(); + + rho == max + ( + psi*p + + (1.0 - gamma)*rhol0 + + ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat, + rhoMin + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "createPhiv.H" +# include "compressibleCreatePhi.H" + + Info<< "Reading transportProperties\n" << endl; + + twoPhaseMixture twoPhaseProperties(U, phiv, "gamma"); + + // Create incompressible turbulence model + autoPtr turbulence + ( + incompressible::turbulenceModel::New(U, phiv, twoPhaseProperties) + ); diff --git a/applications/solvers/multiphase/cavitatingFoam/gammaPsi.H b/applications/solvers/multiphase/cavitatingFoam/gammaPsi.H new file mode 100644 index 0000000000..b259ddd322 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/gammaPsi.H @@ -0,0 +1,10 @@ +{ + gamma = max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0)); + + Info<< "max-min gamma: " << max(gamma).value() + << " " << min(gamma).value() << endl; + + psiModel->correct(); + + //Info<< "min a: " << 1.0/sqrt(max(psi)).value() << endl; +} diff --git a/applications/solvers/multiphase/cavitatingFoam/pEqn.H b/applications/solvers/multiphase/cavitatingFoam/pEqn.H new file mode 100644 index 0000000000..c9382dfc0f --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/pEqn.H @@ -0,0 +1,80 @@ +{ + if (nOuterCorr == 1) + { + p = + ( + rho + - (1.0 - gamma)*rhol0 + - ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat + )/psi; + } + + surfaceScalarField rhof = fvc::interpolate(rho, "rhof"); + + volScalarField rUA = 1.0/UEqn.A(); + surfaceScalarField rUAf("rUAf", rhof*fvc::interpolate(rUA)); + volVectorField HbyA = rUA*UEqn.H(); + + phiv = (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phiv); + + p.boundaryField().updateCoeffs(); + + surfaceScalarField phiGradp = rUAf*mesh.magSf()*fvc::snGrad(p); + + phiv -= phiGradp/rhof; + +# include "resetPhivPatches.H" + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + - (rhol0 + (psil - psiv)*pSat)*fvc::ddt(gamma) - pSat*fvc::ddt(psi) + + fvc::div(phiv, rho) + + fvc::div(phiGradp) + - fvm::laplacian(rUAf, p) + ); + + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phiv += (phiGradp + pEqn.flux())/rhof; + } + } + + Info<< "max-min p: " << max(p).value() + << " " << min(p).value() << endl; + + + U = HbyA - rUA*fvc::grad(p); + + // Remove the swirl component of velocity for "wedge" cases + if (piso.found("removeSwirl")) + { + label swirlCmpt(readLabel(piso.lookup("removeSwirl"))); + + Info<< "Removing swirl component-" << swirlCmpt << " of U" << endl; + U.field().replace(swirlCmpt, 0.0); + } + + U.correctBoundaryConditions(); + + Info<< "max(U) " << max(mag(U)).value() << endl; + + rho == max + ( + psi*p + + (1.0 - gamma)*rhol0 + + ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat, + rhoMin + ); + + Info<< "max-min rho: " << max(rho).value() + << " " << min(rho).value() << endl; + +# include "gammaPsi.H" + +} diff --git a/applications/solvers/multiphase/cavitatingFoam/readControls.H b/applications/solvers/multiphase/cavitatingFoam/readControls.H new file mode 100644 index 0000000000..f53e7b9eb1 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/readControls.H @@ -0,0 +1,9 @@ +#include "readTimeControls.H" + +scalar maxAcousticCo +( + readScalar(runTime.controlDict().lookup("maxAcousticCo")) +); + + +#include "readPISOControls.H" diff --git a/applications/solvers/multiphase/cavitatingFoam/readThermodynamicProperties.H b/applications/solvers/multiphase/cavitatingFoam/readThermodynamicProperties.H new file mode 100644 index 0000000000..d3fbb9307a --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/readThermodynamicProperties.H @@ -0,0 +1,27 @@ + Info<< "Reading thermodynamicProperties\n" << endl; + + IOdictionary thermodynamicProperties + ( + IOobject + ( + "thermodynamicProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + dimensionedScalar psil(thermodynamicProperties.lookup("psil")); + + dimensionedScalar rholSat(thermodynamicProperties.lookup("rholSat")); + + dimensionedScalar psiv(thermodynamicProperties.lookup("psiv")); + + dimensionedScalar pSat(thermodynamicProperties.lookup("pSat")); + + dimensionedScalar rhovSat("rhovSat", psiv*pSat); + + dimensionedScalar rhol0("rhol0", rholSat - pSat*psil); + + dimensionedScalar rhoMin(thermodynamicProperties.lookup("rhoMin")); diff --git a/applications/solvers/multiphase/cavitatingFoam/resetPhiPatches.H b/applications/solvers/multiphase/cavitatingFoam/resetPhiPatches.H new file mode 100644 index 0000000000..e7d0c2f93e --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/resetPhiPatches.H @@ -0,0 +1,15 @@ +fvsPatchScalarFieldField& phiPatches = phi.boundaryField(); +const fvPatchScalarFieldField& rhoPatches = rho.boundaryField(); +const fvPatchVectorFieldField& Upatches = U.boundaryField(); +const fvsPatchVectorFieldField& SfPatches = mesh.Sf().boundaryField(); + +forAll(phiPatches, patchI) +{ + if (phi.boundaryField().types()[patchI] == "calculated") + { + calculatedFvsPatchScalarField& phiPatch = + refCast(phiPatches[patchI]); + + phiPatch == ((rhoPatches[patchI]*Upatches[patchI]) & SfPatches[patchI]); + } +} diff --git a/applications/solvers/multiphase/cavitatingFoam/resetPhivPatches.H b/applications/solvers/multiphase/cavitatingFoam/resetPhivPatches.H new file mode 100644 index 0000000000..7e8b040bb6 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/resetPhivPatches.H @@ -0,0 +1,14 @@ +surfaceScalarField::GeometricBoundaryField& phivPatches = phiv.boundaryField(); +const volVectorField::GeometricBoundaryField& Upatches = U.boundaryField(); +const surfaceVectorField::GeometricBoundaryField& SfPatches = mesh.Sf().boundaryField(); + +forAll(phivPatches, patchI) +{ + if (phiv.boundaryField().types()[patchI] == "calculated") + { + calculatedFvsPatchScalarField& phivPatch = + refCast(phivPatches[patchI]); + + phivPatch == (Upatches[patchI] & SfPatches[patchI]); + } +} diff --git a/applications/solvers/multiphase/cavitatingFoam/rhoEqn.H b/applications/solvers/multiphase/cavitatingFoam/rhoEqn.H new file mode 100644 index 0000000000..d0bd6e1dad --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/rhoEqn.H @@ -0,0 +1,16 @@ +{ + fvScalarMatrix rhoEqn + ( + fvm::ddt(rho) + + fvm::div(phiv, rho) + ); + + rhoEqn.solve(); + + phi = rhoEqn.flux(); + + Info<< "max-min rho: " << max(rho).value() + << " " << min(rho).value() << endl; + + rho == max(rho, rhoMin); +} diff --git a/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H b/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H new file mode 100644 index 0000000000..012a5276e8 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/setDeltaT.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + setDeltaT + +Description + Reset the timestep to maintain a constant maximum courant Number. + Reduction of time-step is imediate but increase is damped to avoid + unstable oscillations. + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ + scalar maxDeltaTFact = + min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL)); + + scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); + + runTime.setDeltaT + ( + min + ( + deltaTFact*runTime.deltaT().value(), + maxDeltaT + ) + ); + + Info<< "deltaT = " << runTime.deltaT().value() << endl; +} + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H b/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H new file mode 100644 index 0000000000..237cacd05a --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/setInitialDeltaT.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + setInitialDeltaT + +Description + Set the initial timestep corresponding to the timestep adjustment + algorithm in setDeltaT + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ +# include "CourantNo.H" + + if (CoNum > SMALL) + { + scalar maxDeltaTFact = + min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL)); + + runTime.setDeltaT + ( + min + ( + maxDeltaTFact*runTime.deltaT().value(), + maxDeltaT + ) + ); + } +} + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/Make/files b/applications/solvers/multiphase/compressibleInterDyMFoam/Make/files new file mode 100644 index 0000000000..121264b1a9 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/Make/files @@ -0,0 +1,3 @@ +compressibleInterDyMFoam.C + +EXE = $(FOAM_APPBIN)/compressibleInterDyMFoam diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options b/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options new file mode 100644 index 0000000000..13d31339e4 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options @@ -0,0 +1,22 @@ +INTERFOAM = $(FOAM_SOLVERS)/multiphase/interFoam + +EXE_INC = \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude + +EXE_LIBS = \ + -linterfaceProperties \ + -lincompressibleTransportModels \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lfiniteVolume \ + -ldynamicMesh \ + -lmeshTools \ + -ldynamicFvMesh + diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H b/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H new file mode 100644 index 0000000000..90033f9826 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H @@ -0,0 +1,31 @@ + surfaceScalarField muf = + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nut()); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(rhoPhi, U) + - fvm::laplacian(muf, U) + - (fvc::grad(U) & fvc::grad(muf)) + //- fvc::div(muf*(mesh.Sf() & fvc::interpolate(fvc::grad(U)().T()))) + ); + + UEqn.relax(); + + if (momentumPredictor) + { + solve + ( + UEqn + == + fvc::reconstruct + ( + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + - fvc::snGrad(pd) + ) * mesh.magSf() + ) + ); + } diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H new file mode 100644 index 0000000000..819cd0f538 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqns.H @@ -0,0 +1,76 @@ +{ + word alphaScheme("div(phi,alpha)"); + word alpharScheme("div(phirb,alpha)"); + + surfaceScalarField phir = phic*interface.nHatf(); + + for (int gCorr=0; gCorr 0.0 && alpha1[celli] > 0.0) + { + Sp[celli] -= dgdt[celli]*alpha1[celli]; + Su[celli] += dgdt[celli]*alpha1[celli]; + } + else if (dgdt[celli] < 0.0 && alpha1[celli] < 1.0) + { + Sp[celli] += dgdt[celli]*(1.0 - alpha1[celli]); + } + } + + + surfaceScalarField phiAlpha1 = + fvc::flux + ( + phi, + alpha1, + alphaScheme + ) + + fvc::flux + ( + -fvc::flux(-phir, alpha2, alpharScheme), + alpha1, + alpharScheme + ); + + MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); + + surfaceScalarField rho1f = fvc::interpolate(rho1); + surfaceScalarField rho2f = fvc::interpolate(rho2); + rhoPhi = phiAlpha1*(rho1f - rho2f) + phi*rho2f; + + alpha2 = scalar(1) - alpha1; + } + + Info<< "Liquid phase volume fraction = " + << alpha1.weightedAverage(mesh.V()).value() + << " Min(alpha1) = " << min(alpha1).value() + << " Min(alpha2) = " << min(alpha2).value() + << endl; +} diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H new file mode 100644 index 0000000000..e161a3cbe6 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H @@ -0,0 +1,43 @@ +{ + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + surfaceScalarField phic = mag(phi/mesh.magSf()); + phic = min(interface.cAlpha()*phic, max(phic)); + + volScalarField divU = fvc::div(phi); + + if (nAlphaSubCycles > 1) + { + dimensionedScalar totalDeltaT = runTime.deltaT(); + surfaceScalarField rhoPhiSum = 0.0*rhoPhi; + + for + ( + subCycle alphaSubCycle(alpha1, nAlphaSubCycles); + !(++alphaSubCycle).end(); + ) + { +# include "alphaEqns.H" + rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; + } + + rhoPhi = rhoPhiSum; + } + else + { +# include "alphaEqns.H" + } + + if (oCorr == 0) + { + interface.correct(); + } +} diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C new file mode 100644 index 0000000000..11a1809575 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + compressibleLesInterFoam + +Description + Solver for 2 compressible, isothermal immiscible fluids using a VOF + (volume of fluid) phase-fraction based interface capturing approach. + The momentum and other fluid properties are of the "mixture" and a single + momentum equation is solved. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dynamicFvMesh.H" +#include "MULES.H" +#include "subCycle.H" +#include "interfaceProperties.H" +#include "twoPhaseMixture.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createDynamicFvMesh.H" + #include "readEnvironmentalProperties.H" + #include "readControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + #include "CourantNo.H" + + // Make the fluxes absolute + fvc::makeAbsolute(phi, U); + + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); + + // Do any mesh changes + mesh.update(); + + if (mesh.changing()) + { + Info<< "Execution time for mesh.update() = " + << runTime.elapsedCpuTime() - timeBeforeMeshUpdate + << " s" << endl; + + gh = g & mesh.C(); + ghf = g & mesh.Cf(); + } + + if (mesh.changing() && correctPhi) + { + //***HGW#include "correctPhi.H" + } + + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phi, U); + + if (mesh.changing() && checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + + turbulence->correct(); + + // --- Outer-corrector loop + for (int oCorr=0; oCorr turbulence + ( + incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) + ); diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H new file mode 100644 index 0000000000..013d8eb05f --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H @@ -0,0 +1,77 @@ +{ + volScalarField rUA = 1.0/UEqn.A(); + surfaceScalarField rUAf = fvc::interpolate(rUA); + + tmp pdEqnComp; + + if (transonic) + { + pdEqnComp = + (fvm::ddt(pd) + fvm::div(phi, pd) - fvm::Sp(fvc::div(phi), pd)); + } + else + { + pdEqnComp = + (fvm::ddt(pd) + fvc::div(phi, pd) - fvc::Sp(fvc::div(phi), pd)); + } + + + U = rUA*UEqn.H(); + + surfaceScalarField phiU + ( + "phiU", + (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) + ); + + phi = phiU + + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + )*rUAf*mesh.magSf(); + + for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pdEqnIncomp + ( + fvc::div(phi) + - fvm::laplacian(rUAf, pd) + ); + + solve + ( + ( + max(alpha1, scalar(0))*(psi1/rho1) + + max(alpha2, scalar(0))*(psi2/rho2) + ) + *pdEqnComp() + + pdEqnIncomp + ); + + if (nonOrth == nNonOrthCorr) + { + dgdt = + (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) + *(pdEqnComp & pd); + phi += pdEqnIncomp.flux(); + } + } + + U += rUA*fvc::reconstruct((phi - phiU)/rUAf); + U.correctBoundaryConditions(); + + p = max + ( + (pd + gh*(alpha1*rho10 + alpha2*rho20))/(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), + pMin + ); + + rho1 = rho10 + psi1*p; + rho2 = rho20 + psi2*p; + + Info<< "max(U) " << max(mag(U)).value() << endl; + Info<< "min(pd) " << min(pd).value() << endl; + + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phi, U); +} diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H new file mode 100644 index 0000000000..a2e4ef3747 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H @@ -0,0 +1,32 @@ + #include "readPISOControls.H" + #include "readTimeControls.H" + + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + if (nAlphaSubCycles > 1 && nOuterCorr != 1) + { + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); + } + + bool correctPhi = true; + if (piso.found("correctPhi")) + { + correctPhi = Switch(piso.lookup("correctPhi")); + } + + bool checkMeshCourantNo = false; + if (piso.found("checkMeshCourantNo")) + { + checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); + } diff --git a/applications/solvers/multiphase/compressibleInterFoam/Make/files b/applications/solvers/multiphase/compressibleInterFoam/Make/files new file mode 100644 index 0000000000..de5437219c --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/Make/files @@ -0,0 +1,3 @@ +compressibleInterFoam.C + +EXE = $(FOAM_APPBIN)/compressibleInterFoam diff --git a/applications/solvers/multiphase/compressibleInterFoam/Make/options b/applications/solvers/multiphase/compressibleInterFoam/Make/options new file mode 100644 index 0000000000..9412e3e374 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/Make/options @@ -0,0 +1,15 @@ +INTERFOAM = $(FOAM_SOLVERS)/multiphase/interFoam + +EXE_INC = \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -linterfaceProperties \ + -lincompressibleTransportModels \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lfiniteVolume diff --git a/applications/solvers/multiphase/compressibleInterFoam/UEqn.H b/applications/solvers/multiphase/compressibleInterFoam/UEqn.H new file mode 100644 index 0000000000..528e0aaafd --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/UEqn.H @@ -0,0 +1,34 @@ + surfaceScalarField muEff + ( + "muEff", + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nut()) + ); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(rhoPhi, U) + - fvm::laplacian(muEff, U) + - (fvc::grad(U) & fvc::grad(muEff)) + //- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + ); + + UEqn.relax(); + + if (momentumPredictor) + { + solve + ( + UEqn + == + fvc::reconstruct + ( + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + - fvc::snGrad(pd) + ) * mesh.magSf() + ) + ); + } diff --git a/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H b/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H new file mode 100644 index 0000000000..819cd0f538 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/alphaEqns.H @@ -0,0 +1,76 @@ +{ + word alphaScheme("div(phi,alpha)"); + word alpharScheme("div(phirb,alpha)"); + + surfaceScalarField phir = phic*interface.nHatf(); + + for (int gCorr=0; gCorr 0.0 && alpha1[celli] > 0.0) + { + Sp[celli] -= dgdt[celli]*alpha1[celli]; + Su[celli] += dgdt[celli]*alpha1[celli]; + } + else if (dgdt[celli] < 0.0 && alpha1[celli] < 1.0) + { + Sp[celli] += dgdt[celli]*(1.0 - alpha1[celli]); + } + } + + + surfaceScalarField phiAlpha1 = + fvc::flux + ( + phi, + alpha1, + alphaScheme + ) + + fvc::flux + ( + -fvc::flux(-phir, alpha2, alpharScheme), + alpha1, + alpharScheme + ); + + MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); + + surfaceScalarField rho1f = fvc::interpolate(rho1); + surfaceScalarField rho2f = fvc::interpolate(rho2); + rhoPhi = phiAlpha1*(rho1f - rho2f) + phi*rho2f; + + alpha2 = scalar(1) - alpha1; + } + + Info<< "Liquid phase volume fraction = " + << alpha1.weightedAverage(mesh.V()).value() + << " Min(alpha1) = " << min(alpha1).value() + << " Min(alpha2) = " << min(alpha2).value() + << endl; +} diff --git a/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H new file mode 100644 index 0000000000..89ba7a4e75 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H @@ -0,0 +1,43 @@ +{ + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + surfaceScalarField phic = mag(phi/mesh.magSf()); + phic = min(interface.cAlpha()*phic, max(phic)); + + volScalarField divU = fvc::div(phi); + + if (nAlphaSubCycles > 1) + { + dimensionedScalar totalDeltaT = runTime.deltaT(); + surfaceScalarField rhoPhiSum = 0.0*rhoPhi; + + for + ( + subCycle alphaSubCycle(alpha1, nAlphaSubCycles); + !(++alphaSubCycle).end(); + ) + { + #include "alphaEqns.H" + rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; + } + + rhoPhi = rhoPhiSum; + } + else + { + #include "alphaEqns.H" + } + + if (oCorr == 0) + { + interface.correct(); + } +} diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C new file mode 100644 index 0000000000..a48fd6b5d3 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + compressibleLesInterFoam + +Description + Solver for 2 compressible, isothermal immiscible fluids using a VOF + (volume of fluid) phase-fraction based interface capturing approach. + The momentum and other fluid properties are of the "mixture" and a single + momentum equation is solved. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "MULES.H" +#include "subCycle.H" +#include "interfaceProperties.H" +#include "twoPhaseMixture.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "readControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + // --- Outer-corrector loop + for (int oCorr=0; oCorrcorrect(); + + runTime.write(); + + Info<< "ExecutionTime = " + << runTime.elapsedCpuTime() + << " s\n\n" << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/createFields.H new file mode 100644 index 0000000000..1f579d245b --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/createFields.H @@ -0,0 +1,152 @@ + Info<< "Reading field pd\n" << endl; + volScalarField pd + ( + IOobject + ( + "pd", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field alpha1\n" << endl; + volScalarField alpha1 + ( + IOobject + ( + "alpha1", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Calculating field alpha1\n" << endl; + volScalarField alpha2("alpha2", scalar(1) - alpha1); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + #include "createPhi.H" + + + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + surfaceScalarField ghf("ghf", g & mesh.Cf()); + + + Info<< "Reading transportProperties\n" << endl; + twoPhaseMixture twoPhaseProperties(U, phi); + + dimensionedScalar rho10 + ( + twoPhaseProperties.subDict + ( + twoPhaseProperties.phase1Name() + ).lookup("rho0") + ); + + dimensionedScalar rho20 + ( + twoPhaseProperties.subDict + ( + twoPhaseProperties.phase2Name() + ).lookup("rho0") + ); + + dimensionedScalar psi1 + ( + twoPhaseProperties.subDict + ( + twoPhaseProperties.phase1Name() + ).lookup("psi") + ); + + dimensionedScalar psi2 + ( + twoPhaseProperties.subDict + ( + twoPhaseProperties.phase2Name() + ).lookup("psi") + ); + + dimensionedScalar pMin(twoPhaseProperties.lookup("pMin")); + + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + max + ( + (pd + gh*(alpha1*rho10 + alpha2*rho20)) + /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), + pMin + ) + ); + + volScalarField rho1 = rho10 + psi1*p; + volScalarField rho2 = rho20 + psi2*p; + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + alpha1*rho1 + alpha2*rho2 + ); + + + // Mass flux + // Initialisation does not matter because rhoPhi is reset after the + // alpha1 solution before it is used in the U equation. + surfaceScalarField rhoPhi + ( + IOobject + ( + "rho*phi", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fvc::interpolate(rho)*phi + ); + + volScalarField dgdt = + pos(alpha2)*fvc::div(phi)/max(alpha2, scalar(0.0001)); + + // Construct interface from alpha1 distribution + interfaceProperties interface(alpha1, U, twoPhaseProperties); + + // Construct incompressible turbulence model + autoPtr turbulence + ( + incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) + ); diff --git a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H new file mode 100644 index 0000000000..ebf24498ad --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H @@ -0,0 +1,74 @@ +{ + volScalarField rUA = 1.0/UEqn.A(); + surfaceScalarField rUAf = fvc::interpolate(rUA); + + tmp pdEqnComp; + + if (transonic) + { + pdEqnComp = + (fvm::ddt(pd) + fvm::div(phi, pd) - fvm::Sp(fvc::div(phi), pd)); + } + else + { + pdEqnComp = + (fvm::ddt(pd) + fvc::div(phi, pd) - fvc::Sp(fvc::div(phi), pd)); + } + + + U = rUA*UEqn.H(); + + surfaceScalarField phiU + ( + "phiU", + (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) + ); + + phi = phiU + + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + )*rUAf*mesh.magSf(); + + for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pdEqnIncomp + ( + fvc::div(phi) + - fvm::laplacian(rUAf, pd) + ); + + solve + ( + ( + max(alpha1, scalar(0))*(psi1/rho1) + + max(alpha2, scalar(0))*(psi2/rho2) + ) + *pdEqnComp() + + pdEqnIncomp + ); + + if (nonOrth == nNonOrthCorr) + { + dgdt = + (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) + *(pdEqnComp & pd); + phi += pdEqnIncomp.flux(); + } + } + + U += rUA*fvc::reconstruct((phi - phiU)/rUAf); + U.correctBoundaryConditions(); + + p = max + ( + (pd + gh*(alpha1*rho10 + alpha2*rho20))/(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), + pMin + ); + + rho1 = rho10 + psi1*p; + rho2 = rho20 + psi2*p; + + Info<< "max(U) " << max(mag(U)).value() << endl; + Info<< "min(pd) " << min(pd).value() << endl; +} diff --git a/applications/solvers/multiphase/compressibleInterFoam/readControls.H b/applications/solvers/multiphase/compressibleInterFoam/readControls.H new file mode 100644 index 0000000000..7e23354f47 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/readControls.H @@ -0,0 +1,20 @@ + #include "readPISOControls.H" + #include "readTimeControls.H" + + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + if (nAlphaSubCycles > 1 && nOuterCorr != 1) + { + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); + } diff --git a/applications/solvers/multiphase/interFoam/alphaEqn.H b/applications/solvers/multiphase/interFoam/alphaEqn.H new file mode 100644 index 0000000000..3bf24a845e --- /dev/null +++ b/applications/solvers/multiphase/interFoam/alphaEqn.H @@ -0,0 +1,35 @@ +{ + word alphaScheme("div(phi,alpha)"); + word alpharScheme("div(phirb,alpha)"); + + surfaceScalarField phic = mag(phi/mesh.magSf()); + phic = min(interface.cAlpha()*phic, max(phic)); + surfaceScalarField phir = phic*interface.nHatf(); + + for (int gCorr=0; gCorr 1) +{ + dimensionedScalar totalDeltaT = runTime.deltaT(); + surfaceScalarField rhoPhiSum = 0.0*rhoPhi; + + for + ( + subCycle alphaSubCycle(alpha1, nAlphaSubCycles); + !(++alphaSubCycle).end(); + ) + { +# include "alphaEqn.H" + rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; + } + + rhoPhi = rhoPhiSum; +} +else +{ +# include "alphaEqn.H" +} + +interface.correct(); + +rho == alpha1*rho1 + (scalar(1) - alpha1)*rho2; diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H new file mode 100644 index 0000000000..15a5291ee6 --- /dev/null +++ b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H @@ -0,0 +1,67 @@ +{ + word alphaScheme("div(phi,alpha)"); + word alpharScheme("div(phirb,alpha)"); + + surfaceScalarField phir("phir", phic*interface.nHatf()); + + for (int gCorr=0; gCorr > vDotAlphal = + twoPhaseProperties->vDotAlphal(); + const volScalarField& vDotcAlphal = vDotAlphal[0](); + const volScalarField& vDotvAlphal = vDotAlphal[1](); + + volScalarField Sp + ( + IOobject + ( + "Sp", + runTime.timeName(), + mesh + ), + vDotvAlphal - vDotcAlphal + ); + + volScalarField Su + ( + IOobject + ( + "Su", + runTime.timeName(), + mesh + ), + // Divergence term is handled explicitly to be + // consistent with the explicit transport solution + divU*alpha1 + + vDotcAlphal + ); + + //MULES::explicitSolve(alpha1, phi, phiAlpha, 1, 0); + //MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); + MULES::implicitSolve(oneField(), alpha1, phi, phiAlpha, Sp, Su, 1, 0); + + rhoPhi += + (runTime.deltaT()/totalDeltaT) + *(phiAlpha*(rho1 - rho2) + phi*rho2); + } + + Info<< "Liquid phase volume fraction = " + << alpha1.weightedAverage(mesh.V()).value() + << " Min(alpha1) = " << min(alpha1).value() + << " Max(alpha1) = " << max(alpha1).value() + << endl; +} diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H new file mode 100644 index 0000000000..dd1d828030 --- /dev/null +++ b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H @@ -0,0 +1,53 @@ +surfaceScalarField rhoPhi +( + IOobject + ( + "rhoPhi", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar("0", dimensionSet(1, 0, -1, 0, 0), 0) +); + +{ + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + surfaceScalarField phic = mag(phi/mesh.magSf()); + phic = min(interface.cAlpha()*phic, max(phic)); + + volScalarField divU = fvc::div(phi); + + dimensionedScalar totalDeltaT = runTime.deltaT(); + + if (nAlphaSubCycles > 1) + { + for + ( + subCycle alphaSubCycle(alpha1, nAlphaSubCycles); + !(++alphaSubCycle).end(); + ) + { +# include "alphaEqn.H" + } + } + else + { +# include "alphaEqn.H" + } + + if (nOuterCorr == 1) + { + interface.correct(); + } + + rho == alpha1*rho1 + (scalar(1) - alpha1)*rho2; +} diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H b/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H new file mode 100644 index 0000000000..c126025368 --- /dev/null +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H @@ -0,0 +1,19 @@ +{ + fvScalarMatrix alpha1Eqn + ( + fvm::ddt(alpha1) + + fvm::div(phi, alpha1) + - fvm::laplacian(Dab, alpha1) + ); + + alpha1Eqn.solve(); + + rhoPhi = alpha1Eqn.flux()*(rho1 - rho2) + phi*rho2; + rho = alpha1*rho1 + (scalar(1) - alpha1)*rho2; + + Info<< "Phase 1 volume fraction = " + << alpha1.weightedAverage(mesh.V()).value() + << " Min(alpha1) = " << min(alpha1).value() + << " Max(alpha1) = " << max(alpha1).value() + << endl; +} diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/src/transportModels/interfaceProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C new file mode 100644 index 0000000000..b11bbd83cf --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "alphaContactAngleFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(alphaContactAngleFvPatchScalarField, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + zeroGradientFvPatchScalarField(p, iF) +{} + + +Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField +( + const alphaContactAngleFvPatchScalarField& gcpsf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchScalarField(gcpsf, p, iF, mapper) +{} + + +Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchScalarField(p, iF) +{ + evaluate(); +} + + +Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField +( + const alphaContactAngleFvPatchScalarField& gcpsf +) +: + zeroGradientFvPatchScalarField(gcpsf) +{} + + +Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField +( + const alphaContactAngleFvPatchScalarField& gcpsf, + const DimensionedField& iF +) +: + zeroGradientFvPatchScalarField(gcpsf, iF) +{} + + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.H b/src/transportModels/interfaceProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.H new file mode 100644 index 0000000000..4036f8cb69 --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.H @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::alphaContactAngleFvPatchScalarField + +Description + Abstract base class for alphaContactAngle boundary conditions. + + Derived classes must implement the theta() fuction which returns the + wall contact angle field. + +SourceFiles + alphaContactAngleFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphaContactAngleFvPatchScalarField_H +#define alphaContactAngleFvPatchScalarField_H + +#include "zeroGradientFvPatchFields.H" +#include "fvsPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class alphaContactAngleFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class alphaContactAngleFvPatchScalarField +: + public zeroGradientFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("alphaContactAngle"); + + + // Constructors + + //- Construct from patch and internal field + alphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + alphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given alphaContactAngleFvPatchScalarField + // onto a new patch + alphaContactAngleFvPatchScalarField + ( + const alphaContactAngleFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphaContactAngleFvPatchScalarField + ( + const alphaContactAngleFvPatchScalarField& + ); + + //- Construct as copy setting internal field reference + alphaContactAngleFvPatchScalarField + ( + const alphaContactAngleFvPatchScalarField&, + const DimensionedField& + ); + + + // Member functions + + //- Return the contact angle + virtual tmp theta + ( + const fvPatchVectorField& Up, + const fvsPatchVectorField& nHat + ) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C b/src/transportModels/interfaceProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C new file mode 100644 index 0000000000..bf80fd79bd --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "constantAlphaContactAngleFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "volMesh.H" +#include "fvPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::constantAlphaContactAngleFvPatchScalarField:: +constantAlphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + alphaContactAngleFvPatchScalarField(p, iF), + theta0_(0.0) +{} + + +Foam::constantAlphaContactAngleFvPatchScalarField:: +constantAlphaContactAngleFvPatchScalarField +( + const constantAlphaContactAngleFvPatchScalarField& gcpsf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + alphaContactAngleFvPatchScalarField(gcpsf, p, iF, mapper), + theta0_(gcpsf.theta0_) +{} + + +Foam::constantAlphaContactAngleFvPatchScalarField:: +constantAlphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + alphaContactAngleFvPatchScalarField(p, iF), + theta0_(readScalar(dict.lookup("theta0"))) +{ + evaluate(); +} + + +Foam::constantAlphaContactAngleFvPatchScalarField:: +constantAlphaContactAngleFvPatchScalarField +( + const constantAlphaContactAngleFvPatchScalarField& gcpsf +) +: + alphaContactAngleFvPatchScalarField(gcpsf), + theta0_(gcpsf.theta0_) +{} + + +Foam::constantAlphaContactAngleFvPatchScalarField:: +constantAlphaContactAngleFvPatchScalarField +( + const constantAlphaContactAngleFvPatchScalarField& gcpsf, + const DimensionedField& iF +) +: + alphaContactAngleFvPatchScalarField(gcpsf, iF), + theta0_(gcpsf.theta0_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp +Foam::constantAlphaContactAngleFvPatchScalarField::theta +( + const fvPatchVectorField&, + const fvsPatchVectorField& +) const +{ + return tmp(new scalarField(size(), theta0_)); +} + + +void Foam::constantAlphaContactAngleFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("theta0") << theta0_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + constantAlphaContactAngleFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.H b/src/transportModels/interfaceProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.H new file mode 100644 index 0000000000..d81c115bd7 --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.H @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::constantAlphaContactAngleFvPatchScalarField + +Description + A constant alphaContactAngle scalar boundary condition + (alphaContactAngleFvPatchScalarField) + +SourceFiles + constantAlphaContactAngleFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constantAlphaContactAngleFvPatchScalarField_H +#define constantAlphaContactAngleFvPatchScalarField_H + +#include "alphaContactAngleFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class constantAlphaContactAngleFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class constantAlphaContactAngleFvPatchScalarField +: + public alphaContactAngleFvPatchScalarField +{ + // Private data + + //- Equilibrium contact angle + scalar theta0_; + + +public: + + //- Runtime type information + TypeName("constantAlphaContactAngle"); + + + // Constructors + + //- Construct from patch and internal field + constantAlphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + constantAlphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // constantAlphaContactAngleFvPatchScalarField + // onto a new patch + constantAlphaContactAngleFvPatchScalarField + ( + const constantAlphaContactAngleFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + constantAlphaContactAngleFvPatchScalarField + ( + const constantAlphaContactAngleFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new constantAlphaContactAngleFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + constantAlphaContactAngleFvPatchScalarField + ( + const constantAlphaContactAngleFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new constantAlphaContactAngleFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Return the equilibrium contact-angle + virtual tmp theta + ( + const fvPatchVectorField& Up, + const fvsPatchVectorField& nHat + ) const; + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C b/src/transportModels/interfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C new file mode 100644 index 0000000000..8c2009f6d0 --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dynamicAlphaContactAngleFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volMesh.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dynamicAlphaContactAngleFvPatchScalarField:: +dynamicAlphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + alphaContactAngleFvPatchScalarField(p, iF), + theta0_(0.0), + uTheta_(0.0), + thetaA_(0.0), + thetaR_(0.0) +{} + + +Foam::dynamicAlphaContactAngleFvPatchScalarField:: +dynamicAlphaContactAngleFvPatchScalarField +( + const dynamicAlphaContactAngleFvPatchScalarField& gcpsf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + alphaContactAngleFvPatchScalarField(gcpsf, p, iF, mapper), + theta0_(gcpsf.theta0_), + uTheta_(gcpsf.uTheta_), + thetaA_(gcpsf.thetaA_), + thetaR_(gcpsf.thetaR_) +{} + + +Foam::dynamicAlphaContactAngleFvPatchScalarField:: +dynamicAlphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + alphaContactAngleFvPatchScalarField(p, iF), + theta0_(readScalar(dict.lookup("theta0"))), + uTheta_(readScalar(dict.lookup("uTheta"))), + thetaA_(readScalar(dict.lookup("thetaA"))), + thetaR_(readScalar(dict.lookup("thetaR"))) +{ + evaluate(); +} + + +Foam::dynamicAlphaContactAngleFvPatchScalarField:: +dynamicAlphaContactAngleFvPatchScalarField +( + const dynamicAlphaContactAngleFvPatchScalarField& gcpsf +) +: + alphaContactAngleFvPatchScalarField(gcpsf), + theta0_(gcpsf.theta0_), + uTheta_(gcpsf.uTheta_), + thetaA_(gcpsf.thetaA_), + thetaR_(gcpsf.thetaR_) +{} + + +Foam::dynamicAlphaContactAngleFvPatchScalarField:: +dynamicAlphaContactAngleFvPatchScalarField +( + const dynamicAlphaContactAngleFvPatchScalarField& gcpsf, + const DimensionedField& iF +) +: + alphaContactAngleFvPatchScalarField(gcpsf, iF), + theta0_(gcpsf.theta0_), + uTheta_(gcpsf.uTheta_), + thetaA_(gcpsf.thetaA_), + thetaR_(gcpsf.thetaR_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp +Foam::dynamicAlphaContactAngleFvPatchScalarField::theta +( + const fvPatchVectorField& Up, + const fvsPatchVectorField& nHat +) const +{ + if (uTheta_ < SMALL) + { + return tmp(new scalarField(size(), theta0_)); + } + + vectorField nf = patch().nf(); + + // Calculated the component of the velocity parallel to the wall + vectorField Uwall = Up.patchInternalField() - Up; + Uwall -= (nf & Uwall)*nf; + + // Find the direction of the interface parallel to the wall + vectorField nWall = nHat - (nf & nHat)*nf; + + // Normalise nWall + nWall /= (mag(nWall) + SMALL); + + // Calculate Uwall resolved normal to the interface parallel to + // the interface + scalarField uwall = nWall & Uwall; + + return theta0_ + (thetaA_ - thetaR_)*tanh(uwall/uTheta_); +} + + +void Foam::dynamicAlphaContactAngleFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("theta0") << theta0_ << token::END_STATEMENT << nl; + os.writeKeyword("uTheta") << uTheta_ << token::END_STATEMENT << nl; + os.writeKeyword("thetaA") << thetaA_ << token::END_STATEMENT << nl; + os.writeKeyword("thetaR") << thetaR_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + dynamicAlphaContactAngleFvPatchScalarField + ); +} + + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.H b/src/transportModels/interfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.H new file mode 100644 index 0000000000..6c3d16965d --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.H @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::dynamicAlphaContactAngleFvPatchScalarField + +Description + A dynamic alphaContactAngle scalar boundary condition + (alphaContactAngleFvPatchScalarField) + +SourceFiles + dynamicAlphaContactAngleFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef dynamicAlphaContactAngleFvPatchScalarField_H +#define dynamicAlphaContactAngleFvPatchScalarField_H + +#include "alphaContactAngleFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class dynamicAlphaContactAngleFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class dynamicAlphaContactAngleFvPatchScalarField +: + public alphaContactAngleFvPatchScalarField +{ + // Private data + + //- Equilibrium contact angle + scalar theta0_; + + //- Dynamic contact angle velocity scale + scalar uTheta_; + + //- Limiting advancing contact angle + scalar thetaA_; + + //- Limiting receeding contact angle + scalar thetaR_; + + +public: + + //- Runtime type information + TypeName("dynamicAlphaContactAngle"); + + + // Constructors + + //- Construct from patch and internal field + dynamicAlphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + dynamicAlphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // dynamicAlphaContactAngleFvPatchScalarField + // onto a new patch + dynamicAlphaContactAngleFvPatchScalarField + ( + const dynamicAlphaContactAngleFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + dynamicAlphaContactAngleFvPatchScalarField + ( + const dynamicAlphaContactAngleFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new dynamicAlphaContactAngleFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + dynamicAlphaContactAngleFvPatchScalarField + ( + const dynamicAlphaContactAngleFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new dynamicAlphaContactAngleFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Evaluate and return dynamic contact-angle + virtual tmp theta + ( + const fvPatchVectorField& Up, + const fvsPatchVectorField& nHat + ) const; + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C b/src/transportModels/interfaceProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C new file mode 100644 index 0000000000..ff9d7210c5 --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "timeVaryingAlphaContactAngleFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::timeVaryingAlphaContactAngleFvPatchScalarField:: +timeVaryingAlphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + alphaContactAngleFvPatchScalarField(p, iF), + t0_(0.0), + thetaT0_(0.0), + te_(0.0), + thetaTe_(0.0) +{} + + +Foam::timeVaryingAlphaContactAngleFvPatchScalarField:: +timeVaryingAlphaContactAngleFvPatchScalarField +( + const timeVaryingAlphaContactAngleFvPatchScalarField& gcpsf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + alphaContactAngleFvPatchScalarField(gcpsf, p, iF, mapper), + t0_(gcpsf.t0_), + thetaT0_(gcpsf.thetaT0_), + te_(gcpsf.te_), + thetaTe_(gcpsf.te_) +{} + + +Foam::timeVaryingAlphaContactAngleFvPatchScalarField:: +timeVaryingAlphaContactAngleFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + alphaContactAngleFvPatchScalarField(p, iF), + t0_(readScalar(dict.lookup("t0"))), + thetaT0_(readScalar(dict.lookup("thetaT0"))), + te_(readScalar(dict.lookup("te"))), + thetaTe_(readScalar(dict.lookup("thetaTe"))) +{ + evaluate(); +} + + +Foam::timeVaryingAlphaContactAngleFvPatchScalarField:: +timeVaryingAlphaContactAngleFvPatchScalarField +( + const timeVaryingAlphaContactAngleFvPatchScalarField& gcpsf, + const DimensionedField& iF +) +: + alphaContactAngleFvPatchScalarField(gcpsf, iF), + t0_(gcpsf.t0_), + thetaT0_(gcpsf.thetaT0_), + te_(gcpsf.te_), + thetaTe_(gcpsf.thetaTe_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp +Foam::timeVaryingAlphaContactAngleFvPatchScalarField::theta +( + const fvPatchVectorField&, + const fvsPatchVectorField& +) const +{ + scalar t = patch().boundaryMesh().mesh().time().value(); + scalar theta0 = thetaT0_; + + if (t < t0_) + { + theta0 = thetaT0_; + } + else if (t > te_) + { + theta0 = thetaTe_; + } + else + { + theta0 = thetaT0_ + (t - t0_)*(thetaTe_ - thetaT0_)/(te_ - t0_); + } + + return tmp(new scalarField(size(), theta0)); +} + + +void Foam::timeVaryingAlphaContactAngleFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl; + os.writeKeyword("thetaT0") << thetaT0_ << token::END_STATEMENT << nl; + os.writeKeyword("te") << te_ << token::END_STATEMENT << nl; + os.writeKeyword("thetaTe") << thetaTe_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + timeVaryingAlphaContactAngleFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.H b/src/transportModels/interfaceProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.H new file mode 100644 index 0000000000..a2a071357e --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::timeVaryingAlphaContactAngleFvPatchScalarField + +Description + A time-varying alphaContactAngle scalar boundary condition + (alphaContactAngleFvPatchScalarField) + +SourceFiles + timeVaryingAlphaContactAngleFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef timeVaryingAlphaContactAngleFvPatchScalarField_H +#define timeVaryingAlphaContactAngleFvPatchScalarField_H + +#include "alphaContactAngleFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class timeVaryingAlphaContactAngleFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class timeVaryingAlphaContactAngleFvPatchScalarField +: + public alphaContactAngleFvPatchScalarField +{ + // Private data + + // Equilibrium contact angle control parameters + scalar t0_; + scalar thetaT0_; + scalar te_; + scalar thetaTe_; + + +public: + + //- Runtime type information + TypeName("timeVaryingAlphaContactAngle"); + + + // Constructors + + //- Construct from patch and internal field + timeVaryingAlphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + timeVaryingAlphaContactAngleFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given timeVaryingAlphaContactAngleFvPatchScalarField + // onto a new patch + timeVaryingAlphaContactAngleFvPatchScalarField + ( + const timeVaryingAlphaContactAngleFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new timeVaryingAlphaContactAngleFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + timeVaryingAlphaContactAngleFvPatchScalarField + ( + const timeVaryingAlphaContactAngleFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new timeVaryingAlphaContactAngleFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Evaluate and return the time-varying equilibrium contact-angle + virtual tmp theta + ( + const fvPatchVectorField& Up, + const fvsPatchVectorField& nHat + ) const; + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaFixedPressure/alphaFixedPressureFvPatchScalarField.C b/src/transportModels/interfaceProperties/alphaFixedPressure/alphaFixedPressureFvPatchScalarField.C new file mode 100644 index 0000000000..85d7f47105 --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaFixedPressure/alphaFixedPressureFvPatchScalarField.C @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "alphaFixedPressureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::alphaFixedPressureFvPatchScalarField:: +alphaFixedPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + p_(p.size(), 0.0) +{} + + +Foam::alphaFixedPressureFvPatchScalarField:: +alphaFixedPressureFvPatchScalarField +( + const alphaFixedPressureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + p_(ptf.p_, mapper) +{} + + +Foam::alphaFixedPressureFvPatchScalarField:: +alphaFixedPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF), + p_("p", dict, p.size()) +{ + if (dict.found("value")) + { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchField::operator=(p_); + } +} + + +Foam::alphaFixedPressureFvPatchScalarField:: +alphaFixedPressureFvPatchScalarField +( + const alphaFixedPressureFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf), + p_(tppsf.p_) +{} + + +Foam::alphaFixedPressureFvPatchScalarField:: +alphaFixedPressureFvPatchScalarField +( + const alphaFixedPressureFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF), + p_(tppsf.p_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::alphaFixedPressureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + scalarField::autoMap(m); + p_.autoMap(m); +} + + +void Foam::alphaFixedPressureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const alphaFixedPressureFvPatchScalarField& tiptf = + refCast(ptf); + + p_.rmap(tiptf.p_, addr); +} + + +void Foam::alphaFixedPressureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const dictionary& environmentalProperties + = db().lookupObject("environmentalProperties"); + + dimensionedVector g(environmentalProperties.lookup("g")); + + const fvPatchField& rho = + patch().lookupPatchField("rho"); + + operator==(p_ - rho*(g.value() & patch().Cf())); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::alphaFixedPressureFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + p_.writeEntry("p", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + alphaFixedPressureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/src/transportModels/interfaceProperties/alphaFixedPressure/alphaFixedPressureFvPatchScalarField.H b/src/transportModels/interfaceProperties/alphaFixedPressure/alphaFixedPressureFvPatchScalarField.H new file mode 100644 index 0000000000..1a7200b1ce --- /dev/null +++ b/src/transportModels/interfaceProperties/alphaFixedPressure/alphaFixedPressureFvPatchScalarField.H @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::alphaFixedPressureFvPatchScalarField + +Description + A fixed-pressure alphaContactAngle boundary + +SourceFiles + alphaFixedPressureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphaFixedPressureFvPatchScalarField_H +#define alphaFixedPressureFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class alphaFixedPressureFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class alphaFixedPressureFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Fixed pressure + scalarField p_; + + +public: + + //- Runtime type information + TypeName("alphaFixedPressure"); + + + // Constructors + + //- Construct from patch and internal field + alphaFixedPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + alphaFixedPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given alphaFixedPressureFvPatchScalarField + // onto a new patch + alphaFixedPressureFvPatchScalarField + ( + const alphaFixedPressureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphaFixedPressureFvPatchScalarField + ( + const alphaFixedPressureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new alphaFixedPressureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + alphaFixedPressureFvPatchScalarField + ( + const alphaFixedPressureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new alphaFixedPressureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the alphaFixed pressure + const scalarField& p() const + { + return p_; + } + + //- Return reference to the alphaFixed pressure to allow adjustment + scalarField& p() + { + return p_; + } + + + // 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& + ); + + + // Evaluation 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/compressible/Allwmake b/src/turbulenceModels/compressible/Allwmake new file mode 100755 index 0000000000..4686db7027 --- /dev/null +++ b/src/turbulenceModels/compressible/Allwmake @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +#wmake libso turbulenceModel +wmake libso RAS +wmake libso LES + +# ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C b/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C new file mode 100644 index 0000000000..28f31e7164 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "DeardorffDiffStress.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(DeardorffDiffStress, 0); +addToRunTimeSelectionTable(LESModel, DeardorffDiffStress, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +DeardorffDiffStress::DeardorffDiffStress +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel(typeName, rho, U, phi, thermoPhysicalModel), + GenSGSStress(rho, U, phi, thermoPhysicalModel), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.094 + ) + ), + cm_ + ( + dimensioned::lookupOrAddToDict + ( + "cm", + coeffDict(), + 4.13 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void DeardorffDiffStress::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + + GenSGSStress::correct(gradU); + + volSymmTensorField D = symm(gradU); + + volSymmTensorField P = -rho()*twoSymm(B_ & gradU); + + volScalarField K = 0.5*tr(B_); + + solve + ( + fvm::ddt(rho(), B_) + + fvm::div(phi(), B_) + - fvm::laplacian(DBEff(), B_) + + fvm::Sp(cm_*rho()*sqrt(K)/delta(), B_) + == + P + + 0.8*rho()*K*D + - (2*ce_ - 0.667*cm_)*I*rho()*epsilon() + ); + + + // Bounding the component kinetic energies + + forAll(B_, celli) + { + B_[celli].component(symmTensor::XX) = + max(B_[celli].component(symmTensor::XX), 1.0e-10); + B_[celli].component(symmTensor::YY) = + max(B_[celli].component(symmTensor::YY), 1.0e-10); + B_[celli].component(symmTensor::ZZ) = + max(B_[celli].component(symmTensor::ZZ), 1.0e-10); + } + + K = 0.5*tr(B_); + bound(K, k0()); + + muSgs_ = ck_*rho()*sqrt(K)*delta(); + muSgs_.correctBoundaryConditions(); +} + + +bool DeardorffDiffStress::read() +{ + if (GenSGSStress::read()) + { + ck_.readIfPresent(coeffDict()); + cm_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.H b/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.H new file mode 100644 index 0000000000..bfbcb2a41b --- /dev/null +++ b/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.H @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::DeardorffDiffStress + +Description + Differential SGS Stress Equation Model for compressible flows + + The DSEM uses a model version of the full balance equation for the SGS + stress tensor to simulate the behaviour of B. + Thus, + @verbatim + d/dt(rho*B) + div(rho*U*B) - div(muSgs*grad(B)) + = + P - c1*rho*epsilon/k*B - 0.667*(1 - c1)*rho*epsilon*I - c2*(P - 0.333*trP*I) + + where + + k = 0.5*trB, + epsilon = ce*k^3/2/delta, + epsilon/k = ce*k^1/2/delta + P = -rho*(B'L + L'B) + muSgs = ck*rho*sqrt(k)*delta + muEff = muSgs + mu + @endverbatim + +SourceFiles + DeardorffDiffStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleDeardorffDiffStress_H +#define compressibleDeardorffDiffStress_H + +#include "GenSGSStress.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class DeardorffDiffStress Declaration +\*---------------------------------------------------------------------------*/ + +class DeardorffDiffStress +: + public GenSGSStress +{ + // Private data + + dimensionedScalar ck_; + dimensionedScalar cm_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + DeardorffDiffStress(const DeardorffDiffStress&); + DeardorffDiffStress& operator=(const DeardorffDiffStress&); + + +public: + + //- Runtime type information + TypeName("DeardorffDiffStress"); + + // Constructors + + //- Constructor from components + DeardorffDiffStress + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + ~DeardorffDiffStress() + {} + + + // Member Functions + + //- Return the effective diffusivity for B + tmp DBEff() const + { + return tmp + ( + new volScalarField("DBEff", muSgs_ + mu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C new file mode 100644 index 0000000000..c3843bb8f1 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +GenEddyVisc::GenEddyVisc +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel + ( + word("GenEddyVisc"), rho, U, phi, thermoPhysicalModel + ), + + ce_ + ( + dimensioned::lookupOrAddToDict + ( + "ce", + coeffDict(), + 1.048 + ) + ), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + muSgs_ + ( + IOobject + ( + "muSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) +{ +// printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp GenEddyVisc::B() const +{ + return ((2.0/3.0)*I)*k_ - (muSgs_/rho())*dev(twoSymm(fvc::grad(U()))); +} + + +tmp GenEddyVisc::devRhoBeff() const +{ + return -muEff()*dev(twoSymm(fvc::grad(U()))); +} + + +tmp GenEddyVisc::divDevRhoBeff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +void GenEddyVisc::correct(const tmp& gradU) +{ + LESModel::correct(gradU); +} + + +bool GenEddyVisc::read() +{ + if (LESModel::read()) + { + ce_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H new file mode 100644 index 0000000000..cd501e9f68 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::GenEddyVisc + +Description + General base class for all compressible models that can be implemented as + an eddy viscosity, i.e. algebraic and one-equation models. + + Contains fields for k (SGS turbulent kinetic energy), gamma + (modelled viscosity) and epsilon (SGS dissipation). + +SourceFiles + GenEddyVisc.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleGenEddyVisc_H +#define compressibleGenEddyVisc_H + +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class GenEddyVisc Declaration +\*---------------------------------------------------------------------------*/ + +class GenEddyVisc +: + virtual public LESModel +{ + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + GenEddyVisc(const GenEddyVisc&); + GenEddyVisc& operator=(const GenEddyVisc&); + + +protected: + + dimensionedScalar ce_; + + volScalarField k_; + volScalarField muSgs_; + + +public: + + // Constructors + + //- Construct from components + GenEddyVisc + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + virtual ~GenEddyVisc() + {} + + + // Member Functions + + //- Return SGS kinetic energy + virtual tmp k() const + { + return k_; + } + + //- Return sub-grid disipation rate + virtual tmp epsilon() const + { + return ce_*k_*sqrt(k_)/delta(); + } + + //- Return viscosity + virtual tmp muSgs() const + { + return muSgs_; + } + + //- Return thermal conductivity + virtual tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", muSgs_ + alpha()) + ); + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const; + + //- Return the deviatoric part of the effective sub-grid + // turbulence stress tensor including the laminar stress + virtual tmp devRhoBeff() const; + + //- Returns div(rho*dev(B)). + // This is the additional term due to the filtering of the NSE. + virtual tmp divDevRhoBeff(volVectorField& U) const; + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C new file mode 100644 index 0000000000..7ef8ebee76 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "GenSGSStress.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +GenSGSStress::GenSGSStress +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel + ( + word("GenSGSStress"), + rho, + U, + phi, + thermoPhysicalModel + ), + + ce_ + ( + dimensioned::lookupOrAddToDict + ( + "ce", + coeffDict(), + 1.048 + ) + ), + + B_ + ( + IOobject + ( + "B", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + muSgs_ + ( + IOobject + ( + "muSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) +{ +// printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp GenSGSStress::devRhoBeff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + rho()*B_ - mu()*dev(twoSymm(fvc::grad(U()))) + ) + ); +} + + +tmp GenSGSStress::divDevRhoBeff(volVectorField& U) const +{ + return + ( + fvc::div(rho()*B_ + 0.05*muSgs_*fvc::grad(U)) + + fvc::laplacian(0.95*muSgs_, U, "laplacian(muEff,U)") + - fvm::laplacian(muEff(), U) + - fvc::div(mu()*dev2(fvc::grad(U)().T())) + ); +} + + +void GenSGSStress::correct(const tmp& gradU) +{ + LESModel::correct(gradU); +} + + +bool GenSGSStress::read() +{ + if (LESModel::read()) + { + ce_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H new file mode 100644 index 0000000000..c071a7a01c --- /dev/null +++ b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::GenSGSStress + +Description + General base class for all compressible models that directly + solve for the SGS stress tensor B. + + Contains tensor fields B (the SGS stress tensor) as well as scalar + fields for k (SGS turbulent energy) gamma (SGS viscosity) and epsilon + (SGS dissipation). + +SourceFiles + GenSGSStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleGenSGSStress_H +#define compressibleGenSGSStress_H + +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class GenSGSStress Declaration +\*---------------------------------------------------------------------------*/ + +class GenSGSStress +: + virtual public LESModel +{ + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + GenSGSStress(const GenSGSStress&); + GenSGSStress& operator=(const GenSGSStress&); + + +protected: + + dimensionedScalar ce_; + + volSymmTensorField B_; + volScalarField muSgs_; + + +public: + + // Constructors + + //- Constructor from components + GenSGSStress + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + virtual ~GenSGSStress() + {} + + + // Member Functions + + //- Return the SGS turbulent kinetic energy. + virtual tmp k() const + { + return 0.5*tr(B_); + } + + //- Return the SGS turbulent dissipation. + virtual tmp epsilon() const + { + volScalarField K = k(); + return ce_*K*sqrt(K)/delta(); + } + + //- Return the SGS viscosity. + virtual tmp muSgs() const + { + return muSgs_; + } + + //- Return thermal conductivity + virtual tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", muSgs_ + alpha()) + ); + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const + { + return B_; + } + + //- Return the deviatoric part of the effective sub-grid + // turbulence stress tensor including the laminar stress + virtual tmp devRhoBeff() const; + + //- Returns divergence of B : i.e. the additional term in the + // filtered NSE. + virtual tmp divDevRhoBeff(volVectorField& U) const; + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/LESModel/LESModel.C b/src/turbulenceModels/compressible/LES/LESModel/LESModel.C new file mode 100644 index 0000000000..8591c4c7b4 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/LESModel/LESModel.C @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LESModel.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(LESModel, 0); +defineRunTimeSelectionTable(LESModel, dictionary); + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void LESModel::printCoeffs() +{ + if (printCoeffs_) + { + Info<< type() << "Coeffs" << coeffDict_ << endl; + } +} + + +// * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * // + +LESModel::LESModel +( + const word& type, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + IOdictionary + ( + IOobject + ( + "LESProperties", + U.time().constant(), + U.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + + runTime_(U.time()), + mesh_(U.mesh()), + + rho_(rho), + U_(U), + phi_(phi), + thermoPhysicalModel_(thermoPhysicalModel), + + printCoeffs_(lookupOrDefault("printCoeffs", false)), + coeffDict_(subDict(type + "Coeffs")), + + k0_("k0", dimVelocity*dimVelocity, SMALL), + + delta_(LESdelta::New("delta", U.mesh(), *this)) +{ + readIfPresent("k0", k0_); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void LESModel::correct(const tmp&) +{ + delta_().correct(); +} + + +void LESModel::correct() +{ + correct(fvc::grad(U_)); +} + + +bool LESModel::read() +{ + if (regIOobject::read()) + { + coeffDict_ = subDict(type() + "Coeffs"); + + delta_().read(*this); + + readIfPresent("k0", k0_); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/LESModel/LESModel.H b/src/turbulenceModels/compressible/LES/LESModel/LESModel.H new file mode 100644 index 0000000000..ecef2d8f77 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/LESModel/LESModel.H @@ -0,0 +1,293 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::compressible::LESModels + +Description + Namespace for compressible LES models. + + +Class + Foam::compressible::LESModel + +Description + Class for all compressible flow LES SGS models. + + This class defines the basic interface for a compressible flow SGS model, + and encapsulates data of value to all possible models. In particular + this includes references to all the dependent fields (rho, U, phi), + the physical viscosity mu, and the turbulenceProperties dictionary + which contains the model selection and model coefficients. + +SourceFiles + LESModel.C + newLESModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleLESModel_H +#define compressibleLESModel_H + +#include "LESdelta.H" +#include "fvm.H" +#include "fvc.H" +#include "fvMatrices.H" +#include "basicThermo.H" +#include "bound.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class LESModel Declaration +\*---------------------------------------------------------------------------*/ + +class LESModel +: + public IOdictionary +{ + +protected: + + // Protected data + + const Time& runTime_; + const fvMesh& mesh_; + + +private: + + // Private data + + const volScalarField& rho_; + const volVectorField& U_; + const surfaceScalarField& phi_; + + const basicThermo& thermoPhysicalModel_; + + Switch printCoeffs_; + dictionary coeffDict_; + + dimensionedScalar k0_; + + autoPtr delta_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + LESModel(const LESModel&); + LESModel& operator=(const LESModel&); + + +protected: + + // Protected Member Functions + + //- Print model coefficients + virtual void printCoeffs(); + + +public: + + //- Runtime type information + TypeName("LESModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + LESModel, + dictionary, + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ), + (rho, U, phi, thermoPhysicalModel) + ); + + + // Constructors + + //- Construct from components + LESModel + ( + const word& type, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Selectors + + //- Return a reference to the selected LES model + static autoPtr New + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + virtual ~LESModel() + {} + + + // Member Functions + + // Access + + //- Access function to the density field + inline const volScalarField& rho() const + { + return rho_; + } + + //- Access function to velocity field + inline const volVectorField& U() const + { + return U_; + } + + //- Access function to flux field + inline const surfaceScalarField& phi() const + { + return phi_; + } + + //- Access function to the thermophysical properties model + inline const basicThermo& thermo() const + { + return thermoPhysicalModel_; + } + + //- Access the dictionary which provides info. about choice of + // models, and all related data (particularly model coefficients). + inline dictionary& coeffDict() + { + return coeffDict_; + } + + //- Access function to filter width + inline const volScalarField& delta() const + { + return delta_(); + } + + //- Return the value of k0 which k is not allowed to be less than + const dimensionedScalar& k0() const + { + return k0_; + } + + //- Allow k0 to be changed + dimensionedScalar& k0() + { + return k0_; + } + + //- Access function to laminar viscosity + tmp mu() const + { + return thermoPhysicalModel_.mu(); + } + + //- Access function to laminar thermal conductivity + tmp alpha() const + { + return thermoPhysicalModel_.alpha(); + } + + + //- Return the SGS turbulent kinetic energy. + virtual tmp k() const = 0; + + //- Return the SGS turbulent dissipation. + virtual tmp epsilon() const = 0; + + //- Return the effective viscosity + virtual tmp muSgs() const = 0; + + //- Return the effective viscosity + virtual tmp muEff() const + { + return tmp + ( + new volScalarField("muEff", muSgs() + mu()) + ); + } + + //- Return the SGS thermal conductivity. + virtual tmp alphaEff() const = 0; + + //- Return the sub-grid stress tensor. + virtual tmp B() const = 0; + + //- Return the deviatoric part of the effective sub-grid + // turbulence stress tensor including the laminar stress + virtual tmp devRhoBeff() const = 0; + + //- Returns div(rho*dev(B)). + // This is the additional term due to the filtering of the NSE. + virtual tmp divDevRhoBeff(volVectorField& U) const = 0; + + //- Correct Eddy-Viscosity and related properties. + // This calls correct(const tmp& gradU) by supplying + // gradU calculated locally. + void correct(); + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + virtual bool read() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/LESModel/newLESModel.C b/src/turbulenceModels/compressible/LES/LESModel/newLESModel.C new file mode 100644 index 0000000000..b411074b17 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/LESModel/newLESModel.C @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +autoPtr LESModel::New +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +{ + word LESModelTypeName; + + // Enclose the creation of the turbulencePropertiesDict to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary turbulencePropertiesDict + ( + IOobject + ( + "LESProperties", + U.time().constant(), + U.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + turbulencePropertiesDict.lookup("LESModel") >> LESModelTypeName; + } + + Info<< "Selecting LES turbulence model " << LESModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(LESModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "LESModel::New(const volVectorField& U, const " + "surfaceScalarField& phi, const basicThermo&)" + ) << "Unknown LESModel type " << LESModelTypeName + << endl << endl + << "Valid LESModel types are :" << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(rho, U, phi, thermoPhysicalModel)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/Make/files b/src/turbulenceModels/compressible/LES/Make/files new file mode 100644 index 0000000000..dc31f55cae --- /dev/null +++ b/src/turbulenceModels/compressible/LES/Make/files @@ -0,0 +1,19 @@ +LESModel/LESModel.C +LESModel/newLESModel.C +GenEddyVisc/GenEddyVisc.C +GenSGSStress/GenSGSStress.C + +Smagorinsky/Smagorinsky.C +oneEqEddy/oneEqEddy.C +lowReOneEqEddy/lowReOneEqEddy.C +dynOneEqEddy/dynOneEqEddy.C +DeardorffDiffStress/DeardorffDiffStress.C +SpalartAllmaras/SpalartAllmaras.C + +/* Wall functions */ +wallFunctions=derivedFvPatchFields/wallFunctions + +muSgsWallFunctions=$(wallFunctions)/muSgsWallFunctions +$(muSgsWallFunctions)/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C + +LIB = $(FOAM_LIBBIN)/libcompressibleLESModels diff --git a/src/turbulenceModels/compressible/LES/Make/options b/src/turbulenceModels/compressible/LES/Make/options new file mode 100644 index 0000000000..4ccb52fba2 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/Make/options @@ -0,0 +1,11 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I../../LES/LESdeltas/lnInclude \ + -I../../LES/LESfilters/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude + +LIB_LIBS = \ + -lLESdeltas \ + -lLESfilters \ + -lmeshTools diff --git a/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C new file mode 100644 index 0000000000..547fd60f5e --- /dev/null +++ b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "Smagorinsky.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Smagorinsky, 0); +addToRunTimeSelectionTable(LESModel, Smagorinsky, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +Smagorinsky::Smagorinsky +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel(typeName, rho, U, phi, thermoPhysicalModel), + GenEddyVisc(rho, U, phi, thermoPhysicalModel), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.02 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Smagorinsky::correct(const tmp& gradU) +{ + GenEddyVisc::correct(gradU); + + volSymmTensorField D = symm(gradU); + + volScalarField a = ce_/delta(); + volScalarField b = (2.0/3.0)*tr(D); + volScalarField c = 2*ck_*delta()*(dev(D) && D); + + k_ = sqr((-b + sqrt(sqr(b) + 4*a*c))/(2*a)); + + muSgs_ = ck_*rho()*delta()*sqrt(k_); + muSgs_.correctBoundaryConditions(); +} + + +bool Smagorinsky::read() +{ + if (GenEddyVisc::read()) + { + ck_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.H b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.H new file mode 100644 index 0000000000..e5d786f94a --- /dev/null +++ b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::Smagorinsky + +Description + The choric Smagorinsky Model for compressible flows. + + Algebraic eddy viscosity SGS model founded on the assumption that + local equilibrium prevails. + Thus, + @verbatim + + B = 2/3*k*I - 2*nuSgs*dev(D) + + where + + D = symm(grad(U)); + k from rho*D:B + ce*rho*k^3/2/delta = 0 + muSgs = ck*rho*sqrt(k)*delta + @endverbatim + +SourceFiles + Smagorinsky.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleSmagorinsky_H +#define compressibleSmagorinsky_H + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class Smagorinsky Declaration +\*---------------------------------------------------------------------------*/ + +class Smagorinsky +: + public GenEddyVisc +{ + // Private data + + dimensionedScalar ck_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + Smagorinsky(const Smagorinsky&); + Smagorinsky& operator=(const Smagorinsky&); + + +public: + + //- Runtime type information + TypeName("Smagorinsky"); + + // Constructors + + //- Construct from components + Smagorinsky + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + ~Smagorinsky() + {} + + + // Member Functions + + //- Correct Eddy-Viscosity and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C new file mode 100644 index 0000000000..568598a065 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C @@ -0,0 +1,329 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpalartAllmaras.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(SpalartAllmaras, 0); +addToRunTimeSelectionTable(LESModel, SpalartAllmaras, dictionary); + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +tmp SpalartAllmaras::fv1() const +{ + volScalarField chi3 = pow3(nuTilda_/(mu()/rho())); + return chi3/(chi3 + pow3(Cv1_)); +} + + +tmp SpalartAllmaras::fv2() const +{ + volScalarField chi = nuTilda_/(mu()/rho()); + //return scalar(1) - chi/(scalar(1) + chi*fv1()); + return 1.0/pow3(scalar(1) + chi/Cv2_); +} + + +tmp SpalartAllmaras::fv3() const +{ + volScalarField chi = nuTilda_/(mu()/rho()); + volScalarField chiByCv2 = (1/Cv2_)*chi; + + return + (scalar(1) + chi*fv1()) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); +} + + +tmp SpalartAllmaras::fw(const volScalarField& Stilda) const +{ + volScalarField r = min + ( + nuTilda_ + /( + max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL)) + *sqr(kappa_*dTilda_) + ), + scalar(10.0) + ); + r.boundaryField() == 0.0; + + volScalarField g = r + Cw2_*(pow6(r) - r); + + return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +SpalartAllmaras::SpalartAllmaras +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel(typeName, rho, U, phi, thermoPhysicalModel), + + alphaNut_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaNut", + coeffDict(), + 1.5 + ) + ), + + Cb1_ + ( + dimensioned::lookupOrAddToDict + ( + "Cb1", + coeffDict(), + 0.1355 + ) + ), + Cb2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cb2", + coeffDict(), + 0.622 + ) + ), + Cv1_ + ( + dimensioned::lookupOrAddToDict + ( + "Cv1", + coeffDict(), + 7.1 + ) + ), + Cv2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cv2", + coeffDict(), + 5.0 + ) + ), + CDES_ + ( + dimensioned::lookupOrAddToDict + ( + "CDES", + coeffDict(), + 0.65 + ) + ), + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.07 + ) + ), + kappa_ + ( + dimensioned::lookupOrAddToDict + ( + "kappa", + *this, + 0.4187 + ) + ), + Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)), + Cw2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cw2", + coeffDict(), + 0.3 + ) + ), + Cw3_ + ( + dimensioned::lookupOrAddToDict + ( + "Cw3", + coeffDict(), + 2.0 + ) + ), + + nuTilda_ + ( + IOobject + ( + "nuTilda", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + dTilda_(min(CDES_*delta(), wallDist(mesh_).y())), + muSgs_ + ( + IOobject + ( + "muSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) + +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp SpalartAllmaras::B() const +{ + return ((2.0/3.0)*I)*k() - (muSgs_/rho())*dev(twoSymm(fvc::grad(U()))); +} + + +tmp SpalartAllmaras::devRhoBeff() const +{ + return -muEff()*dev(twoSymm(fvc::grad(U()))); +} + + +tmp SpalartAllmaras::epsilon() const +{ + return 2*muEff()/rho()*magSqr(symm(fvc::grad(U()))); +} + + +tmp SpalartAllmaras::divDevRhoBeff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +void SpalartAllmaras::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + LESModel::correct(gradU); + + if (mesh_.changing()) + { + dTilda_ = min(CDES_*delta(), wallDist(mesh_).y()); + } + + volScalarField Stilda = + fv3()*::sqrt(2.0)*mag(skew(gradU)) + fv2()*nuTilda_/sqr(kappa_*dTilda_); + + solve + ( + fvm::ddt(rho(), nuTilda_) + + fvm::div(phi(), nuTilda_) + - fvm::laplacian + ( + alphaNut_*(nuTilda_*rho() + mu()), + nuTilda_, + "laplacian(DnuTildaEff,nuTilda)" + ) + - alphaNut_*rho()*Cb2_*magSqr(fvc::grad(nuTilda_)) + == + rho()*Cb1_*Stilda*nuTilda_ + - fvm::Sp(rho()*Cw1_*fw(Stilda)*nuTilda_/sqr(dTilda_), nuTilda_) + ); + + bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0)); + + nuTilda_.correctBoundaryConditions(); + muSgs_.internalField() = rho()*fv1()*nuTilda_.internalField(); + muSgs_.correctBoundaryConditions(); +} + + +bool SpalartAllmaras::read() +{ + if (LESModel::read()) + { + alphaNut_.readIfPresent(coeffDict()); + Cb1_.readIfPresent(coeffDict()); + Cb2_.readIfPresent(coeffDict()); + Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_); + Cw2_.readIfPresent(coeffDict()); + Cw3_.readIfPresent(coeffDict()); + Cv1_.readIfPresent(coeffDict()); + Cv2_.readIfPresent(coeffDict()); + CDES_.readIfPresent(coeffDict()); + ck_.readIfPresent(coeffDict()); + kappa_.readIfPresent(*this); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H new file mode 100644 index 0000000000..67a1d7b8a8 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::SpalartAllmaras + +Description + SpalartAllmaras for compressible flows + +SourceFiles + SpalartAllmaras.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleSpalartAllmaras_H +#define compressibleSpalartAllmaras_H + +#include "LESModel.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class SpalartAllmaras Declaration +\*---------------------------------------------------------------------------*/ + +class SpalartAllmaras +: + public LESModel +{ + // Private data + + dimensionedScalar alphaNut_; + + dimensionedScalar Cb1_; + dimensionedScalar Cb2_; + dimensionedScalar Cv1_; + dimensionedScalar Cv2_; + dimensionedScalar CDES_; + dimensionedScalar ck_; + dimensionedScalar kappa_; + dimensionedScalar Cw1_; + dimensionedScalar Cw2_; + dimensionedScalar Cw3_; + + + // Private member functions + + tmp fv1() const; + tmp fv2() const; + tmp fv3() const; + tmp fw(const volScalarField& Stilda) const; + + // Disallow default bitwise copy construct and assignment + SpalartAllmaras(const SpalartAllmaras&); + SpalartAllmaras& operator=(const SpalartAllmaras&); + + volScalarField nuTilda_; + volScalarField dTilda_; + volScalarField muSgs_; + + +public: + + //- Runtime type information + TypeName("SpalartAllmaras"); + + + // Constructors + + //- Constructor from components + SpalartAllmaras + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + ~SpalartAllmaras() + {} + + + // Member Functions + + //- Return SGS kinetic energy + tmp k() const + { + return sqr(muSgs()/rho()/ck_/dTilda_); + } + + //- Return sub-grid disipation rate + tmp epsilon() const; + + tmp nuTilda() const + { + return nuTilda_; + } + + //- Return SGS viscosity + tmp muSgs() const + { + return muSgs_; + } + + //- Return thermal conductivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", muSgs_ + alpha()) + ); + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const; + + //- Return the deviatoric part of the effective sub-grid + // turbulence stress tensor including the laminar stress + virtual tmp devRhoBeff() const; + + //- Returns div(rho*dev(B)). + // This is the additional term due to the filtering of the NSE. + tmp divDevRhoBeff(volVectorField& U) const; + + //- Correct nuTilda and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..e210c32c73 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H" +#include "LESModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +muSgsSpalartAllmarasWallFunctionFvPatchScalarField:: +muSgsSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +muSgsSpalartAllmarasWallFunctionFvPatchScalarField:: +muSgsSpalartAllmarasWallFunctionFvPatchScalarField +( + const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +muSgsSpalartAllmarasWallFunctionFvPatchScalarField:: +muSgsSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + Istream& is +) +: + fixedValueFvPatchScalarField(p, iF, is) +{} + + +muSgsSpalartAllmarasWallFunctionFvPatchScalarField:: +muSgsSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +muSgsSpalartAllmarasWallFunctionFvPatchScalarField:: +muSgsSpalartAllmarasWallFunctionFvPatchScalarField +( + const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +muSgsSpalartAllmarasWallFunctionFvPatchScalarField:: +muSgsSpalartAllmarasWallFunctionFvPatchScalarField +( + const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void muSgsSpalartAllmarasWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const LESModel& sgsModel + = db().lookupObject("LESProperties"); + + scalar kappa = readScalar(sgsModel.lookup("kappa")); + + scalar E = readScalar(sgsModel.subDict("wallFunctionCoeffs").lookup("E")); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + scalarField& muSgsw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(muSgsw, facei) + { + scalar magUpara = magUp[facei]; + + scalar utau = sqrt + ( + (muSgsw[facei] + muw[facei]) + *magFaceGradU[facei]/rhow[facei] + ); + + if(utau > 0) + { + int iter = 0; + scalar err = GREAT; + + do + { + scalar kUu = kappa*magUpara/utau; + scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); + + scalar f = + - utau/(ry[facei]*muw[facei]/rhow[facei]) + + magUpara/utau + + 1/E*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + + scalar df = + - 1.0/(ry[facei]*muw[facei]/rhow[facei]) + - magUpara/sqr(utau) + - 1/E*kUu*fkUu/utau; + + scalar utauNew = utau - f/df; + err = mag((utau - utauNew)/utau); + utau = utauNew; + + } while (utau > VSMALL && err > 0.01 && ++iter < 10); + + muSgsw[facei] = + max(rhow[facei]*sqr(utau)/magFaceGradU[facei] - muw[facei],0.0); + } + else + { + muSgsw[facei] = 0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + muSgsSpalartAllmarasWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..9d3210c1d4 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsSpalartAllmarasWallFunction/muSgsSpalartAllmarasWallFunctionFvPatchScalarField.H @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels:: + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + +Description + Spalart Allmaas wall function boundary condition for compressible flows + +SourceFiles + muSgsSpalartAllmarasWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef muSgsSpalartAllmarasWallFunctionFvPatchScalarField_H +#define muSgsSpalartAllmarasWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class muSgsSpalartAllmarasWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class muSgsSpalartAllmarasWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + +public: + + //- Runtime type information + TypeName("muSgsSpalartAllmarasWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and Istream + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + Istream& + ); + + //- Construct from patch, internal field and dictionary + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // muSgsSpalartAllmarasWallFunctionFvPatchScalarField + // onto a new patch + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new muSgsSpalartAllmarasWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new muSgsSpalartAllmarasWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C b/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C new file mode 100644 index 0000000000..96bf8abbc9 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "dynOneEqEddy.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(dynOneEqEddy, 0); +addToRunTimeSelectionTable(LESModel, dynOneEqEddy, dictionary); + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +dimensionedScalar dynOneEqEddy::ck_(const volSymmTensorField& D) const +{ + volScalarField KK = 0.5*(filter_(magSqr(U())) - magSqr(filter_(U()))); + + volSymmTensorField LL = dev(filter_(sqr(U())) - (sqr(filter_(U())))); + + volSymmTensorField MM = + delta()*(filter_(sqrt(k_)*D) - 2*sqrt(KK + filter_(k_))*filter_(D)); + + return average(LL && MM)/average(magSqr(MM)); +} + + +dimensionedScalar dynOneEqEddy::ce_(const volSymmTensorField& D) const +{ + volScalarField KK = 0.5*(filter_(magSqr(U())) - magSqr(filter_(U()))); + + volScalarField mm = + pow(KK + filter_(k_), 1.5)/(2*delta()) - filter_(pow(k_, 1.5))/delta(); + + volScalarField ee = + 2*delta()*ck_(D)* + ( + filter_(sqrt(k_)*magSqr(D)) + - 2*sqrt(KK + filter_(k_))*magSqr(filter_(D)) + ); + + return average(ee*mm)/average(mm*mm); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +dynOneEqEddy::dynOneEqEddy +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel(typeName, rho, U, phi, thermoPhysicalModel), + GenEddyVisc(rho, U, phi, thermoPhysicalModel), + + filterPtr_(LESfilter::New(U.mesh(), coeffDict())), + filter_(filterPtr_()) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +dynOneEqEddy::~dynOneEqEddy() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void dynOneEqEddy::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + + GenEddyVisc::correct(gradU); + + volSymmTensorField D = dev(symm(gradU)); + volScalarField divU = fvc::div(phi()/fvc::interpolate(rho())); + volScalarField G = 2*muSgs_*(gradU && D); + + solve + ( + fvm::ddt(rho(), k_) + + fvm::div(phi(), k_) + - fvm::laplacian(DkEff(), k_) + == + G + - fvm::SuSp(2.0/3.0*rho()*divU, k_) + - fvm::Sp(ce_(D)*rho()*sqrt(k_)/delta(), k_) + ); + + bound(k_, dimensionedScalar("0", k_.dimensions(), 1.0e-10)); + + muSgs_ = ck_(D)*rho()*sqrt(k_)*delta(); + muSgs_.correctBoundaryConditions(); +} + + +bool dynOneEqEddy::read() +{ + if (GenEddyVisc::read()) + { + filter_.read(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.H b/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.H new file mode 100644 index 0000000000..3ffeb9c5db --- /dev/null +++ b/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::dynOneEqEddy + +Description + One Equation Eddy Viscosity Model for compressible flows. + + Eddy viscosity SGS model using a modeled balance equation to simulate + the behaviour of k. + Thus + @verbatim + d/dt(k) + div(U*k) - div(nuSgs*grad(k)) + = + -rho*B*L - ce*rho*k^3/2/delta + + and + + B = 2/3*k*I - 2*nuSgs*dev(D) + + where + + D = symm(grad(U)); + nuSgs = ck*sqrt(k)*delta + @endverbatim + +SourceFiles + dynOneEqEddy.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleDynOneEqEddy_H +#define compressibleDynOneEqEddy_H + +#include "GenEddyVisc.H" +#include "LESfilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class dynOneEqEddy Declaration +\*---------------------------------------------------------------------------*/ + +class dynOneEqEddy +: + public GenEddyVisc +{ + // Private data + + autoPtr filterPtr_; + LESfilter& filter_; + + + // Private Member Functions + + //- Calculate ck, ce by filtering the velocity field U. + dimensionedScalar ck_(const volSymmTensorField& D) const; + dimensionedScalar ce_(const volSymmTensorField& D) const; + + // Disallow default bitwise copy construct and assignment + dynOneEqEddy(const dynOneEqEddy&); + dynOneEqEddy& operator=(const dynOneEqEddy&); + + +public: + + //- Runtime type information + TypeName("dynOneEqEddy"); + + + // Constructors + + //- Constructor from components + dynOneEqEddy + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + ~dynOneEqEddy(); + + + // Member Functions + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", muSgs_ + mu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C b/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C new file mode 100644 index 0000000000..a626068335 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "lowReOneEqEddy.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defineTypeNameAndDebug(lowReOneEqEddy, 0); +addToRunTimeSelectionTable(LESModel, lowReOneEqEddy, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +lowReOneEqEddy::lowReOneEqEddy +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel(typeName, rho, U, phi, thermoPhysicalModel), + GenEddyVisc(rho, U, phi, thermoPhysicalModel), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.07 + ) + ), + beta_ + ( + dimensioned::lookupOrAddToDict + ( + "beta", + coeffDict(), + 0.01 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void lowReOneEqEddy::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + + GenEddyVisc::correct(gradU); + + volScalarField divU = fvc::div(phi()/fvc::interpolate(rho())); + volScalarField G = 2*muSgs_*(gradU && dev(symm(gradU))); + + solve + ( + fvm::ddt(rho(), k_) + + fvm::div(phi(), k_) + - fvm::laplacian(DkEff(), k_) + == + G + - fvm::SuSp(2.0/3.0*rho()*divU, k_) + - fvm::Sp(ce_*rho()*sqrt(k_)/delta(), k_) + ); + + bound(k_, k0()); + + // High Re eddy viscosity + muSgs_ = ck_*rho()*sqrt(k_)*delta(); + + // low Re no corrected eddy viscosity + muSgs_ -= (mu()/beta_)*(scalar(1) - exp(-beta_*muSgs_/mu())); + + muSgs_.correctBoundaryConditions(); +} + + +bool lowReOneEqEddy::read() +{ + if (GenEddyVisc::read()) + { + ck_.readIfPresent(coeffDict()); + beta_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.H b/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.H new file mode 100644 index 0000000000..44d74f8ea9 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.H @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::lowReOneEqEddy + +Description + One Equation Eddy Viscosity Model for compressible flow + + @verbatim + d/dt(rho*k) + div(rho*U*k) - div(muEff*grad(k)) + = + -rho*B*L - ce*rho*k^3/2/delta + + and + + B = 2/3*k*I - 2*nuSgs*dev(D) + + where + + nuSgsHiRe = ck*sqrt(k)*delta + nuSgs = (nu/beta)*(1 - exp(-beta*nuSgsHiRe/nu)); + @endverbatim + +SourceFiles + lowReOneEqEddy.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleLowReOneEqEddy_H +#define compressibleLowReOneEqEddy_H + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class lowReOneEqEddy Declaration +\*---------------------------------------------------------------------------*/ + +class lowReOneEqEddy +: + public GenEddyVisc +{ + // Private data + + dimensionedScalar ck_; + dimensionedScalar beta_; + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + lowReOneEqEddy(const lowReOneEqEddy&); + lowReOneEqEddy& operator=(const lowReOneEqEddy&); + + +public: + + //- Runtime type information + TypeName("lowReOneEqEddy"); + + + // Constructors + + //- Constructor from components + lowReOneEqEddy + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + ~lowReOneEqEddy() + {} + + + // Member Functions + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", muSgs_ + mu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C b/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C new file mode 100644 index 0000000000..bf4103e430 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "oneEqEddy.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(oneEqEddy, 0); +addToRunTimeSelectionTable(LESModel, oneEqEddy, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +oneEqEddy::oneEqEddy +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel +) +: + LESModel(typeName, rho, U, phi, thermoPhysicalModel), + GenEddyVisc(rho, U, phi, thermoPhysicalModel), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.094 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void oneEqEddy::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + + GenEddyVisc::correct(gradU); + + volScalarField divU = fvc::div(phi()/fvc::interpolate(rho())); + volScalarField G = 2*muSgs_*(gradU && dev(symm(gradU))); + + fvScalarMatrix kEqn + ( + fvm::ddt(rho(), k_) + + fvm::div(phi(), k_) + - fvm::laplacian(DkEff(), k_) + == + G + - fvm::SuSp(2.0/3.0*rho()*divU, k_) + - fvm::Sp(ce_*rho()*sqrt(k_)/delta(), k_) + ); + + kEqn.relax(); + kEqn.solve(); + + bound(k_, k0()); + + muSgs_ = ck_*rho()*sqrt(k_)*delta(); + muSgs_.correctBoundaryConditions(); +} + + +bool oneEqEddy::read() +{ + if (GenEddyVisc::read()) + { + ck_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.H b/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.H new file mode 100644 index 0000000000..edd2c04d37 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.H @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::LESModels::oneEqEddy + +Description + One Equation Eddy Viscosity Model for incompressible flows + + Eddy viscosity SGS model using a modeled balance equation to simulate the + behaviour of k, hence, + @verbatim + d/dt(rho*k) + div(rho*U*k) - div(muEff*grad(k)) + = + -rho*D:B - ce*rho*k^3/2/delta + + and + + B = 2/3*k*I - 2*nuSgs*dev(D) + + where + + D = symm(grad(U)); + muSgs = ck*rho*sqrt(k)*delta + @endverbatim + + +SourceFiles + oneEqEddy.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleOneEqEddy_H +#define compressibleOneEqEddy_H + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class oneEqEddy Declaration +\*---------------------------------------------------------------------------*/ + +class oneEqEddy +: + public GenEddyVisc +{ + // Private data + + dimensionedScalar ck_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + oneEqEddy(const oneEqEddy&); + oneEqEddy& operator=(const oneEqEddy&); + + +public: + + //- Runtime type information + TypeName("oneEqEddy"); + + + // Constructors + + //- Constructor from components + oneEqEddy + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + const basicThermo& thermoPhysicalModel + ); + + + // Destructor + + ~oneEqEddy() + {} + + + // Member Functions + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", muSgs_ + mu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LRR/LRR.C b/src/turbulenceModels/compressible/RAS/LRR/LRR.C new file mode 100644 index 0000000000..a22d495249 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/LRR/LRR.C @@ -0,0 +1,476 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LRR.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +#include "backwardsCompatibilityWallFunctions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(LRR, 0); +addToRunTimeSelectionTable(RASModel, LRR, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +LRR::LRR +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.09 + ) + ), + Clrr1_ + ( + dimensioned::lookupOrAddToDict + ( + "Clrr1", + coeffDict_, + 1.8 + ) + ), + Clrr2_ + ( + dimensioned::lookupOrAddToDict + ( + "Clrr2", + coeffDict_, + 0.6 + ) + ), + C1_ + ( + dimensioned::lookupOrAddToDict + ( + "C1", + coeffDict_, + 1.44 + ) + ), + C2_ + ( + dimensioned::lookupOrAddToDict + ( + "C2", + coeffDict_, + 1.92 + ) + ), + Cs_ + ( + dimensioned::lookupOrAddToDict + ( + "Cs", + coeffDict_, + 0.25 + ) + ), + Ceps_ + ( + dimensioned::lookupOrAddToDict + ( + "Ceps", + coeffDict_, + 0.15 + ) + ), + couplingFactor_ + ( + dimensioned::lookupOrAddToDict + ( + "couplingFactor", + coeffDict_, + 0.0 + ) + ), + alphaR_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaR", + coeffDict_, + 1.22 + ) + ), + alphaEps_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaEps", + coeffDict_, + 0.76923 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + + R_ + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + autoCreateR("R", mesh_) + ), + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateK("k", mesh_) + ), + epsilon_ + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateEpsilon("epsilon", mesh_) + ), + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) + ) +{ + if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) + { + FatalErrorIn + ( + "LRR::LRR" + "( const volScalarField&, const volVectorField&" + ", const surfaceScalarField&, incompressibleTransportModel&)" + ) << "couplingFactor = " << couplingFactor_ + << " is not in range 0 - 1" << nl + << exit(FatalError); + } + + mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp LRR::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp LRR::divDevRhoReff(volVectorField& U) const +{ + if (couplingFactor_.value() > 0.0) + { + return + ( + fvc::div(rho_*R_ + couplingFactor_*mut_*fvc::grad(U)) + + fvc::laplacian((1.0 - couplingFactor_)*mut_, U) + - fvm::laplacian(muEff(), U) + - fvc::div(mu()*dev2(fvc::grad(U)().T())) + ); + } + else + { + return + ( + fvc::div(rho_*R_) + + fvc::laplacian(mut_, U) + - fvm::laplacian(muEff(), U) + - fvc::div(mu()*dev2(fvc::grad(U)().T())) + ); + } +} + + +bool LRR::read() +{ + if (RASModel::read()) + { + Cmu_.readIfPresent(coeffDict_); + Clrr1_.readIfPresent(coeffDict_); + Clrr2_.readIfPresent(coeffDict_); + C1_.readIfPresent(coeffDict_); + C2_.readIfPresent(coeffDict_); + Cs_.readIfPresent(coeffDict_); + Ceps_.readIfPresent(coeffDict_); + alphaR_.readIfPresent(coeffDict_); + alphaEps_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + couplingFactor_.readIfPresent(coeffDict_); + + if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) + { + FatalErrorIn("LRR::read()") + << "couplingFactor = " << couplingFactor_ + << " is not in range 0 - 1" << nl + << exit(FatalError); + } + + return true; + } + else + { + return false; + } +} + + +void LRR::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + return; + } + + RASModel::correct(); + + volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_)); + volScalarField G("G", 0.5*tr(P)); + + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); + + // Dissipation equation + tmp epsEqn + ( + fvm::ddt(rho_, epsilon_) + + fvm::div(phi_, epsilon_) + //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_) + - fvm::laplacian(DepsilonEff(), epsilon_) + == + C1_*rho_*G*epsilon_/k_ + - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_) + ); + + epsEqn().relax(); + + epsEqn().boundaryManipulate(epsilon_.boundaryField()); + + solve(epsEqn); + bound(epsilon_, epsilon0_); + + + // Reynolds stress equation + + const fvPatchList& patches = mesh_.boundary(); + + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (typeid(curPatch) == typeid(wallFvPatch)) + { + forAll(curPatch, facei) + { + label faceCelli = curPatch.faceCells()[facei]; + P[faceCelli] + *= min(G[faceCelli]/(0.5*tr(P[faceCelli]) + SMALL), 100.0); + } + } + } + + + tmp REqn + ( + fvm::ddt(rho_, R_) + + fvm::div(phi_, R_) + //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_) + - fvm::laplacian(DREff(), R_) + + fvm::Sp(Clrr1_*rho_*epsilon_/k_, R_) + == + rho_*P + - (2.0/3.0*(1 - Clrr1_)*I)*rho_*epsilon_ + - Clrr2_*rho_*dev(P) + ); + + REqn().relax(); + solve(REqn); + + R_.max + ( + dimensionedSymmTensor + ( + "zero", + R_.dimensions(), + symmTensor + ( + k0_.value(), -GREAT, -GREAT, + k0_.value(), -GREAT, + k0_.value() + ) + ) + ); + + k_ = 0.5*tr(R_); + bound(k_, k0_); + + + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + + // Correct wall shear stresses + + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (typeid(curPatch) == typeid(wallFvPatch)) + { + symmTensorField& Rw = R_.boundaryField()[patchi]; + + const scalarField& rhow = rho_.boundaryField()[patchi]; + const scalarField& mutw = mut_.boundaryField()[patchi]; + + vectorField snGradU = U_.boundaryField()[patchi].snGrad(); + + const vectorField& faceAreas + = mesh_.Sf().boundaryField()[patchi]; + + const scalarField& magFaceAreas + = mesh_.magSf().boundaryField()[patchi]; + + forAll(curPatch, facei) + { + // Calculate near-wall velocity gradient + tensor gradUw + = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei]; + + // Calculate near-wall shear-stress tensor + tensor tauw = -(mutw[facei]/rhow[facei])*2*dev(symm(gradUw)); + + // Reset the shear components of the stress tensor + Rw[facei].xy() = tauw.xy(); + Rw[facei].xz() = tauw.xz(); + Rw[facei].yz() = tauw.yz(); + } + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LRR/LRR.H b/src/turbulenceModels/compressible/RAS/LRR/LRR.H new file mode 100644 index 0000000000..0dc2ed2ad8 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/LRR/LRR.H @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::LRR + +Description + Launder, Reece and Rodi Reynolds-stress turbulence model for + compressible flows. + + The default model coefficients correspond to the following: + @verbatim + LRRCoeffs + { + Cmu 0.09; + Clrr1 1.8; + Clrr2 0.6; + C1 1.44; + C2 1.92; + Cs 0.25; + Ceps 0.15; + alphah 1.0; // only for compressible + alphaEps 0.76923; + alphaR 1.22; // only for compressible + couplingFactor 0.0; // only for incompressible + } + @endverbatim + +SourceFiles + LRR.C + LRRcorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleLRR_H +#define compressibleLRR_H + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class LRR Declaration +\*---------------------------------------------------------------------------*/ + +class LRR +: + public RASModel +{ + // Private data + + dimensionedScalar Cmu_; + + dimensionedScalar Clrr1_; + dimensionedScalar Clrr2_; + + dimensionedScalar C1_; + dimensionedScalar C2_; + dimensionedScalar Cs_; + dimensionedScalar Ceps_; + + dimensionedScalar couplingFactor_; + + dimensionedScalar alphaR_; + dimensionedScalar alphaEps_; + dimensionedScalar alphah_; + + volSymmTensorField R_; + volScalarField k_; + volScalarField epsilon_; + volScalarField mut_; + volScalarField alphat_; + + +public: + + //- Runtime type information + TypeName("LRR"); + + // Constructors + + //- from components + LRR + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~LRR(){} + + + // Member Functions + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for R + tmp DREff() const + { + return tmp + ( + new volScalarField("DREff", alphaR_*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for epsilon + tmp DepsilonEff() const + { + return tmp + ( + new volScalarField("DepsilonEff", alphaEps_*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return epsilon_; + } + + //- Return the Reynolds stress tensor + tmp R() const + { + return R_; + } + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C new file mode 100644 index 0000000000..0181605fb1 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -0,0 +1,514 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LaunderGibsonRSTM.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" +#include "wallDist.H" +#include "wallDistReflection.H" + +#include "backwardsCompatibilityWallFunctions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(LaunderGibsonRSTM, 0); +addToRunTimeSelectionTable(RASModel, LaunderGibsonRSTM, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +LaunderGibsonRSTM::LaunderGibsonRSTM +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.09 + ) + ), + Clg1_ + ( + dimensioned::lookupOrAddToDict + ( + "Clg1", + coeffDict_, + 1.8 + ) + ), + Clg2_ + ( + dimensioned::lookupOrAddToDict + ( + "Clg2", + coeffDict_, + 0.6 + ) + ), + C1_ + ( + dimensioned::lookupOrAddToDict + ( + "C1", + coeffDict_, + 1.44 + ) + ), + C2_ + ( + dimensioned::lookupOrAddToDict + ( + "C2", + coeffDict_, + 1.92 + ) + ), + Cs_ + ( + dimensioned::lookupOrAddToDict + ( + "Cs", + coeffDict_, + 0.25 + ) + ), + Ceps_ + ( + dimensioned::lookupOrAddToDict + ( + "Ceps", + coeffDict_, + 0.15 + ) + ), + C1Ref_ + ( + dimensioned::lookupOrAddToDict + ( + "C1Ref", + coeffDict_, + 0.5 + ) + ), + C2Ref_ + ( + dimensioned::lookupOrAddToDict + ( + "C2Ref", + coeffDict_, + 0.3 + ) + ), + couplingFactor_ + ( + dimensioned::lookupOrAddToDict + ( + "couplingFactor", + coeffDict_, + 0.0 + ) + ), + alphaR_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaR", + coeffDict_, + 1.22 + ) + ), + alphaEps_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaEps", + coeffDict_, + 0.76923 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + + y_(mesh_), + + R_ + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + autoCreateR("R", mesh_) + ), + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateK("k", mesh_) + ), + epsilon_ + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateEpsilon("epsilon", mesh_) + ), + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) + ) +{ + if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) + { + FatalErrorIn + ( + "LaunderGibsonRSTM::LaunderGibsonRSTM" + "(const volScalarField&, const volVectorField&" + ", const surfaceScalarField&, basicThermo&)" + ) << "couplingFactor = " << couplingFactor_ + << " is not in range 0 - 1" << nl + << exit(FatalError); + } + + mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp LaunderGibsonRSTM::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp LaunderGibsonRSTM::divDevRhoReff(volVectorField& U) const +{ + if (couplingFactor_.value() > 0.0) + { + return + ( + fvc::div(rho_*R_ + couplingFactor_*mut_*fvc::grad(U)) + + fvc::laplacian((1.0 - couplingFactor_)*mut_, U) + - fvm::laplacian(muEff(), U) + - fvc::div(mu()*dev2(fvc::grad(U)().T())) + ); + } + else + { + return + ( + fvc::div(rho_*R_) + + fvc::laplacian(mut_, U) + - fvm::laplacian(muEff(), U) + - fvc::div(mu()*dev2(fvc::grad(U)().T())) + ); + } +} + + +bool LaunderGibsonRSTM::read() +{ + if (RASModel::read()) + { + Cmu_.readIfPresent(coeffDict_); + Clg1_.readIfPresent(coeffDict_); + Clg2_.readIfPresent(coeffDict_); + C1_.readIfPresent(coeffDict_); + C2_.readIfPresent(coeffDict_); + Cs_.readIfPresent(coeffDict_); + Ceps_.readIfPresent(coeffDict_); + C1Ref_.readIfPresent(coeffDict_); + C2Ref_.readIfPresent(coeffDict_); + alphaR_.readIfPresent(coeffDict_); + alphaEps_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + + couplingFactor_.readIfPresent(coeffDict_); + + if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) + { + FatalErrorIn("LaunderGibsonRSTM::read()") + << "couplingFactor = " << couplingFactor_ + << " is not in range 0 - 1" << nl + << exit(FatalError); + } + + return true; + } + else + { + return false; + } +} + + +void LaunderGibsonRSTM::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + return; + } + + RASModel::correct(); + + if (mesh_.changing()) + { + y_.correct(); + } + + volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_)); + volScalarField G("G", 0.5*tr(P)); + + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); + + // Dissipation equation + tmp epsEqn + ( + fvm::ddt(rho_, epsilon_) + + fvm::div(phi_, epsilon_) + //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_) + - fvm::laplacian(DepsilonEff(), epsilon_) + == + C1_*rho_*G*epsilon_/k_ + - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_) + ); + + epsEqn().relax(); + + epsEqn().boundaryManipulate(epsilon_.boundaryField()); + + solve(epsEqn); + bound(epsilon_, epsilon0_); + + + // Reynolds stress equation + + const fvPatchList& patches = mesh_.boundary(); + + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (typeid(curPatch) == typeid(wallFvPatch)) + { + forAll(curPatch, facei) + { + label faceCelli = curPatch.faceCells()[facei]; + P[faceCelli] *= + min(G[faceCelli]/(0.5*tr(P[faceCelli]) + SMALL), 100.0); + } + } + } + + volSymmTensorField reflect = C1Ref_*epsilon_/k_*R_ - C2Ref_*Clg2_*dev(P); + + tmp REqn + ( + fvm::ddt(rho_, R_) + + fvm::div(phi_, R_) + //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_) + - fvm::laplacian(DREff(), R_) + + fvm::Sp(Clg1_*rho_*epsilon_/k_, R_) + == + rho_*P + + (2.0/3.0*(Clg1_ - 1)*I)*rho_*epsilon_ + - Clg2_*rho_*dev(P) + + // wall reflection terms + + symm + ( + I*((y_.n() & reflect) & y_.n()) + - 1.5*(y_.n()*(reflect & y_.n()) + + (y_.n() & reflect)*y_.n()) + )*pow(Cmu_, 0.75)*rho_*pow(k_, 1.5)/(kappa_*y_*epsilon_) + ); + + REqn().relax(); + solve(REqn); + + R_.max + ( + dimensionedSymmTensor + ( + "zero", + R_.dimensions(), + symmTensor + ( + k0_.value(), -GREAT, -GREAT, + k0_.value(), -GREAT, + k0_.value() + ) + ) + ); + + k_ == 0.5*tr(R_); + bound(k_, k0_); + + + // Re-calculate turbulent viscosity + mut_ == Cmu_*rho_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + // Correct wall shear stresses + + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (typeid(curPatch) == typeid(wallFvPatch)) + { + symmTensorField& Rw = R_.boundaryField()[patchi]; + + const scalarField& mutw = mut_.boundaryField()[patchi]; + const scalarField& rhow = rho_.boundaryField()[patchi]; + + vectorField snGradU = U_.boundaryField()[patchi].snGrad(); + + const vectorField& faceAreas + = mesh_.Sf().boundaryField()[patchi]; + + const scalarField& magFaceAreas + = mesh_.magSf().boundaryField()[patchi]; + + forAll(curPatch, facei) + { + // Calculate near-wall velocity gradient + tensor gradUw + = (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei]; + + // Calculate near-wall shear-stress tensor + tensor tauw = -(mutw[facei]/rhow[facei])*2*dev(symm(gradUw)); + + // Reset the shear components of the stress tensor + Rw[facei].xy() = tauw.xy(); + Rw[facei].xz() = tauw.xz(); + Rw[facei].yz() = tauw.yz(); + } + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H new file mode 100644 index 0000000000..4fa0e9315e --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.H @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::LaunderGibsonRSTM + +Description + Launder-Gibson Reynolds stress turbulence model for compressible flows. + + The default model coefficients correspond to the following: + @verbatim + LaunderGibsonRSTMCoeffs + { + Cmu 0.09; + Clg1 1.8; + Clg2 0.6; + C1 1.44; + C2 1.92; + C1Ref 0.5; + C2Ref 0.3; + Cs 0.25; + Ceps 0.15; + alphah 1.0; // only for compressible + alphaEps 0.76923; + alphaR 1.22; + couplingFactor 0.0; + } + @endverbatim + +SourceFiles + LaunderGibsonRSTM.C + LaunderGibsonRSTMcorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleLaunderGibsonRSTM_H +#define compressibleLaunderGibsonRSTM_H + +#include "RASModel.H" +#include "wallDistReflection.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class LaunderGibsonRSTM Declaration +\*---------------------------------------------------------------------------*/ + +class LaunderGibsonRSTM +: + public RASModel +{ + // Private data + + dimensionedScalar Cmu_; + + dimensionedScalar Clg1_; + dimensionedScalar Clg2_; + + dimensionedScalar C1_; + dimensionedScalar C2_; + dimensionedScalar Cs_; + dimensionedScalar Ceps_; + + dimensionedScalar C1Ref_; + dimensionedScalar C2Ref_; + + dimensionedScalar couplingFactor_; + + dimensionedScalar alphaR_; + dimensionedScalar alphaEps_; + dimensionedScalar alphah_; + + wallDistReflection y_; + + volSymmTensorField R_; + volScalarField k_; + volScalarField epsilon_; + volScalarField mut_; + volScalarField alphat_; + + +public: + + //- Runtime type information + TypeName("LaunderGibsonRSTM"); + + // Constructors + + //- from components + LaunderGibsonRSTM + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~LaunderGibsonRSTM(){} + + + // Member Functions + + // Access + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for R + tmp DREff() const + { + return tmp + ( + new volScalarField("DREff", alphaR_*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for epsilon + tmp DepsilonEff() const + { + return tmp + ( + new volScalarField("DepsilonEff", alphaEps_*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return epsilon_; + } + + //- Return the Reynolds stress tensor + tmp R() const + { + return R_; + } + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C new file mode 100644 index 0000000000..b577410097 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -0,0 +1,331 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LaunderSharmaKE.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(LaunderSharmaKE, 0); +addToRunTimeSelectionTable(RASModel, LaunderSharmaKE, dictionary); + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +tmp LaunderSharmaKE::fMu() const +{ + return exp(-3.4/sqr(scalar(1) + rho_*sqr(k_)/(mu()*epsilon_)/50.0)); +} + + +tmp LaunderSharmaKE::f2() const +{ + return + scalar(1) + - 0.3*exp(-min(sqr(rho_*sqr(k_)/(mu()*epsilon_)), scalar(50.0))); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +LaunderSharmaKE::LaunderSharmaKE +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.09 + ) + ), + C1_ + ( + dimensioned::lookupOrAddToDict + ( + "C1", + coeffDict_, + 1.44 + ) + ), + C2_ + ( + dimensioned::lookupOrAddToDict + ( + "C2", + coeffDict_, + 1.92 + ) + ), + C3_ + ( + dimensioned::lookupOrAddToDict + ( + "C3", + coeffDict_, + -0.33 + ) + ), + alphak_ + ( + dimensioned::lookupOrAddToDict + ( + "alphak", + coeffDict_, + 1.0 + ) + ), + alphaEps_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaEps", + coeffDict_, + 0.76923 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + epsilon_ + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + Cmu_*fMu()*rho_*sqr(k_)/(epsilon_ + epsilonSmall_) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp LaunderSharmaKE::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))), + k_.boundaryField().types() + ) + ); +} + + +tmp LaunderSharmaKE::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -muEff()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp LaunderSharmaKE::divDevRhoReff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +bool LaunderSharmaKE::read() +{ + if (RASModel::read()) + { + Cmu_.readIfPresent(coeffDict_); + C1_.readIfPresent(coeffDict_); + C2_.readIfPresent(coeffDict_); + C3_.readIfPresent(coeffDict_); + alphak_.readIfPresent(coeffDict_); + alphaEps_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + + return true; + } + else + { + return false; + } +} + + +void LaunderSharmaKE::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_); + return; + } + + RASModel::correct(); + + // Calculate parameters and coefficients for Launder-Sharma low-Reynolds + // number model + + volScalarField E = 2.0*mu()*mut_*fvc::magSqrGradGrad(U_)/rho_; + volScalarField D = 2.0*mu()*magSqr(fvc::grad(sqrt(k_)))/rho_; + + volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_)); + + if (mesh_.moving()) + { + divU += fvc::div(mesh_.phi()); + } + + tmp tgradU = fvc::grad(U_); + volScalarField G = mut_*(tgradU() && dev(twoSymm(tgradU()))); + tgradU.clear(); + + + // Dissipation equation + + tmp epsEqn + ( + fvm::ddt(rho_, epsilon_) + + fvm::div(phi_, epsilon_) + - fvm::laplacian(DepsilonEff(), epsilon_) + == + C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_) + - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_) + //+ 0.75*1.5*flameKproduction*epsilon_/k_ + + E + ); + + epsEqn().relax(); + solve(epsEqn); + bound(epsilon_, epsilon0_); + + + // Turbulent kinetic energy equation + + tmp kEqn + ( + fvm::ddt(rho_, k_) + + fvm::div(phi_, k_) + - fvm::laplacian(DkEff(), k_) + == + G - fvm::SuSp(2.0/3.0*rho_*divU, k_) + - fvm::Sp(rho_*(epsilon_ + D)/k_, k_) + //+ flameKproduction + ); + + kEqn().relax(); + solve(kEqn); + bound(k_, k0_); + + + // Re-calculate viscosity + mut_ = Cmu_*fMu()*rho_*sqr(k_)/epsilon_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.H b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.H new file mode 100644 index 0000000000..731e0cdb02 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.H @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::LaunderSharmaKE + +Description + Launder and Sharma low-Reynolds k-epsilon turbulence model for + compressible and combusting flows. + + The default model coefficients correspond to the following: + @verbatim + LaunderSharmaKECoeffs + { + Cmu 0.09; + C1 1.44; + C2 1.92; + C3 -0.33; + alphah 1.0; // only for compressible + alphahk 1.0; // only for compressible + alphaEps 0.76923; + } + @endverbatim + +SourceFiles + LaunderSharmaKE.C + LaunderSharmaKECorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleLaunderSharmaKE_H +#define compressibleLaunderSharmaKE_H + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class LaunderSharmaKE Declaration +\*---------------------------------------------------------------------------*/ + +class LaunderSharmaKE +: + public RASModel +{ + // Private data + + dimensionedScalar Cmu_; + dimensionedScalar C1_; + dimensionedScalar C2_; + dimensionedScalar C3_; + dimensionedScalar alphak_; + dimensionedScalar alphaEps_; + dimensionedScalar alphah_; + + volScalarField k_; + volScalarField epsilon_; + volScalarField mut_; + + + // Private member functions + + tmp fMu() const; + tmp f2() const; + + +public: + + //- Runtime type information + TypeName("LaunderSharmaKE"); + + // Constructors + + //- from components + LaunderSharmaKE + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~LaunderSharmaKE(){} + + + // Member Functions + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", alphak_*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for epsilon + tmp DepsilonEff() const + { + return tmp + ( + new volScalarField("DepsilonEff", alphaEps_*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*mut_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return epsilon_; + } + + //- Return the Reynolds stress tensor + tmp R() const; + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/Make/files b/src/turbulenceModels/compressible/RAS/Make/files new file mode 100644 index 0000000000..0598d06a00 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/Make/files @@ -0,0 +1,43 @@ +/* RAS turbulence models */ +RASModel/RASModel.C +RASModel/newRASModel.C +laminar/laminar.C +kEpsilon/kEpsilon.C +RNGkEpsilon/RNGkEpsilon.C +LaunderSharmaKE/LaunderSharmaKE.C +LRR/LRR.C +LaunderGibsonRSTM/LaunderGibsonRSTM.C +realizableKE/realizableKE.C +SpalartAllmaras/SpalartAllmaras.C +kOmegaSST/kOmegaSST.C + +/* Wall functions */ +wallFunctions = derivedFvPatchFields/wallFunctions + +alphatWallFunctions = $(wallFunctions)/alphatWallFunctions +$(alphatWallFunctions)/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C + +mutWallFunctions = $(wallFunctions)/mutWallFunctions +$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C + +epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions +$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C + +omegaWallFunctions = $(wallFunctions)/omegaWallFunctions +$(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C + +kQRWallFunctions = $(wallFunctions)/kQRWallFunctions +$(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C + +/* Patch fields */ +derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C +derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C +derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C + +backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C + +LIB = $(FOAM_LIBBIN)/libcompressibleRASModels diff --git a/src/turbulenceModels/compressible/RAS/Make/options b/src/turbulenceModels/compressible/RAS/Make/options new file mode 100644 index 0000000000..6c12c9d781 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/Make/options @@ -0,0 +1,8 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools diff --git a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C new file mode 100644 index 0000000000..c1bbdc1684 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C @@ -0,0 +1,228 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "RASModel.H" +#include "wallDist.H" +#include "wallFvPatch.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(RASModel, 0); +defineRunTimeSelectionTable(RASModel, dictionary); + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void RASModel::printCoeffs() +{ + if (printCoeffs_) + { + Info<< type() << "Coeffs" << coeffDict_ << nl + << "wallFunctionCoeffs" << wallFunctionDict_ << endl; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +RASModel::RASModel +( + const word& type, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + IOdictionary + ( + IOobject + ( + "RASProperties", + U.time().constant(), + U.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + + runTime_(U.time()), + mesh_(U.mesh()), + + rho_(rho), + U_(U), + phi_(phi), + thermophysicalModel_(thermophysicalModel), + + turbulence_(lookup("turbulence")), + printCoeffs_(lookupOrDefault("printCoeffs", false)), + coeffDict_(subDict(type + "Coeffs")), + + wallFunctionDict_(subDict("wallFunctionCoeffs")), + kappa_ + ( + dimensioned::lookupOrAddToDict + ( + "kappa", + subDict("wallFunctionCoeffs"), + 0.4187 + ) + ), + E_ + ( + dimensioned::lookupOrAddToDict + ( + "E", + subDict("wallFunctionCoeffs"), + 9.0 + ) + ), + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + wallFunctionDict_, + 0.09 + ) + ), + Prt_ + ( + dimensioned::lookupOrAddToDict + ( + "Prt", + wallFunctionDict_, + 0.85 + ) + ), + + yPlusLam_(yPlusLam(kappa_.value(), E_.value())), + + k0_("k0", dimVelocity*dimVelocity, SMALL), + epsilon0_("epsilon", k0_.dimensions()/dimTime, SMALL), + epsilonSmall_("epsilonSmall", epsilon0_.dimensions(), SMALL), + + y_(mesh_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const +{ + scalar ypl = 11.0; + + for (int i=0; i<10; i++) + { + ypl = log(E*ypl)/kappa; + } + + return ypl; +} + + +tmp RASModel::yPlus(const label patchNo) const +{ + const fvPatch& curPatch = mesh_.boundary()[patchNo]; + + tmp tYp(new scalarField(curPatch.size())); + scalarField& Yp = tYp(); + + if (isType(curPatch)) + { + Yp = pow(Cmu_.value(), 0.25) + *y_[patchNo] + *sqrt(k()().boundaryField()[patchNo].patchInternalField()) + /( + mu().boundaryField()[patchNo].patchInternalField() + /rho_.boundaryField()[patchNo] + ); + } + else + { + WarningIn + ( + "tmp RASModel::yPlus(const label patchNo) const" + ) << "Patch " << patchNo << " is not a wall. Returning null field" + << nl << endl; + + Yp.setSize(0); + } + + return tYp; +} + + +void RASModel::correct() +{ + if (mesh_.changing()) + { + y_.correct(); + } +} + + +bool RASModel::read() +{ + if (regIOobject::read()) + { + lookup("turbulence") >> turbulence_; + coeffDict_ = subDict(type() + "Coeffs"); + + wallFunctionDict_ = subDict("wallFunctionCoeffs"); + kappa_.readIfPresent(wallFunctionDict_); + E_.readIfPresent(wallFunctionDict_); + Cmu_.readIfPresent(wallFunctionDict_); + Prt_.readIfPresent(wallFunctionDict_); + + yPlusLam_ = yPlusLam(kappa_.value(), E_.value()); + + k0_.readIfPresent(*this); + epsilon0_.readIfPresent(*this); + epsilonSmall_.readIfPresent(*this); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H new file mode 100644 index 0000000000..1be29e6e79 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H @@ -0,0 +1,339 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::compressible::RASModels + +Description + Namespace for compressible RAS turbulence models. + + +Class + Foam::compressible::RASModel + +Description + Abstract base class for turbulence models for compressible and combusting + flows. + +SourceFiles + RASModel.C + newTurbulenceModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleRASModel_H +#define compressibleRASModel_H + +#include "volFields.H" +#include "surfaceFields.H" +#include "nearWallDist.H" +#include "fvm.H" +#include "fvc.H" +#include "fvMatrices.H" +#include "basicThermo.H" +#include "IOdictionary.H" +#include "Switch.H" +#include "bound.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class RASModel Declaration +\*---------------------------------------------------------------------------*/ + +class RASModel +: + public IOdictionary +{ + +protected: + + // Protected data + + const Time& runTime_; + const fvMesh& mesh_; + + const volScalarField& rho_; + const volVectorField& U_; + const surfaceScalarField& phi_; + + basicThermo& thermophysicalModel_; + + Switch turbulence_; + Switch printCoeffs_; + dictionary coeffDict_; + + dictionary wallFunctionDict_; + dimensionedScalar kappa_; + dimensionedScalar E_; + dimensionedScalar Cmu_; + dimensionedScalar Prt_; + + scalar yPlusLam_; + + dimensionedScalar k0_; + dimensionedScalar epsilon0_; + dimensionedScalar epsilonSmall_; + + nearWallDist y_; + + + // Protected member functions + + //- Print model coefficients + virtual void printCoeffs(); + + //- Return the laminar thermal conductivity + const volScalarField& alpha() const + { + return thermophysicalModel_.alpha(); + } + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + RASModel(const RASModel&); + + //- Disallow default bitwise assignment + void operator=(const RASModel&); + + +public: + + //- Runtime type information + TypeName("RASModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + RASModel, + dictionary, + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermoPhysicalModel + ), + (rho, U, phi, thermoPhysicalModel) + ); + + + // Constructors + + //- Construct from components + RASModel + ( + const word& type, + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermoPhysicalModel + ); + + + // Selectors + + //- Return a reference to the selected turbulence model + static autoPtr New + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermoPhysicalModel + ); + + + // Destructor + + virtual ~RASModel() + {} + + + // Member Functions + + // Access + + //- Return the value of k0 which k is not allowed to be less than + const dimensionedScalar& k0() const + { + return k0_; + } + + //- Return the value of epsilon0 which epsilon is not allowed to be + // less than + const dimensionedScalar& epsilon0() const + { + return epsilon0_; + } + + //- Return the value of epsilonSmall which is added to epsilon when + // calculating nut + const dimensionedScalar& epsilonSmall() const + { + return epsilonSmall_; + } + + + //- Allow k0 to be changed + dimensionedScalar& k0() + { + return k0_; + } + + //- Allow epsilon0 to be changed + dimensionedScalar& epsilon0() + { + return epsilon0_; + } + + //- Allow epsilonSmall to be changed + dimensionedScalar& epsilonSmall() + { + return epsilonSmall_; + } + + + //- Return kappa for use in wall-functions + dimensionedScalar kappa() const + { + return kappa_; + } + + //- Return E for use in wall-functions + dimensionedScalar E() const + { + return E_; + } + + //- Return Cmu for use in wall-functions + dimensionedScalar Cmu() const + { + return Cmu_; + } + + //- Return turbulent Prandtl number for use in wall-functions + dimensionedScalar Prt() const + { + return Prt_; + } + + //- Return the near wall distances + const nearWallDist& y() const + { + return y_; + } + + //- Calculate y+ at the edge of the laminar sublayer + scalar yPlusLam(const scalar kappa, const scalar E) const; + + //- Return y+ at the edge of the laminar sublayer + // for use in wall-functions + scalar yPlusLam() const + { + return yPlusLam_; + } + + //- Const access to the coefficients dictionary + const dictionary& coeffDict() const + { + return coeffDict_; + } + + //- Const access to the wall functions coefficients dictionary + const dictionary& walLFunctionDict() const + { + return wallFunctionDict_; + } + + + //- Return the laminar viscosity + const volScalarField& mu() const + { + return thermophysicalModel_.mu(); + } + + //- Return the turbulence viscosity + virtual tmp mut() const = 0; + + //- Return the effective viscosity + virtual tmp muEff() const + { + return tmp + ( + new volScalarField("muEff", mut() + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + virtual tmp alphaEff() const = 0; + + //- Return the turbulence kinetic energy + virtual tmp k() const = 0; + + //- Return the turbulence kinetic energy dissipation rate + virtual tmp epsilon() const = 0; + + //- Return the Reynolds stress tensor + virtual tmp R() const = 0; + + //- 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; + + //- Return yPlus for the given patch + virtual tmp yPlus(const label patchI) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + virtual void correct() = 0; + + //- Read turbulenceProperties dictionary + virtual bool read() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/RASModel/newRASModel.C b/src/turbulenceModels/compressible/RAS/RASModel/newRASModel.C new file mode 100644 index 0000000000..339e9ad2d2 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/RASModel/newRASModel.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +autoPtr RASModel::New +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +{ + word RASModelTypeName; + + // Enclose the creation of the turbulencePropertiesDict to ensure it is + // deleted before the RASModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary turbulencePropertiesDict + ( + IOobject + ( + "RASProperties", + U.time().constant(), + U.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + turbulencePropertiesDict.lookup("RASModel") + >> RASModelTypeName; + } + + Info<< "Selecting RAS turbulence model " << RASModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(RASModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "RASModel::New(const volScalarField&, " + "const volVectorField&, const surfaceScalarField&, " + "basicThermo&)" + ) << "Unknown RASModel type " << RASModelTypeName + << endl << endl + << "Valid RASModel types are :" << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter()(rho, U, phi, thermophysicalModel) + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C new file mode 100644 index 0000000000..8f6ba82321 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C @@ -0,0 +1,368 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "RNGkEpsilon.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +#include "backwardsCompatibilityWallFunctions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(RNGkEpsilon, 0); +addToRunTimeSelectionTable(RASModel, RNGkEpsilon, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// from components +RNGkEpsilon::RNGkEpsilon +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.0845 + ) + ), + C1_ + ( + dimensioned::lookupOrAddToDict + ( + "C1", + coeffDict_, + 1.42 + ) + ), + C2_ + ( + dimensioned::lookupOrAddToDict + ( + "C2", + coeffDict_, + 1.68 + ) + ), + C3_ + ( + dimensioned::lookupOrAddToDict + ( + "C3", + coeffDict_, + -0.33 + ) + ), + alphak_ + ( + dimensioned::lookupOrAddToDict + ( + "alphak", + coeffDict_, + 1.39 + ) + ), + alphaEps_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaEps", + coeffDict_, + 1.39 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + eta0_ + ( + dimensioned::lookupOrAddToDict + ( + "eta0", + coeffDict_, + 4.38 + ) + ), + beta_ + ( + dimensioned::lookupOrAddToDict + ( + "beta", + coeffDict_, + 0.012 + ) + ), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateK("k", mesh_) + ), + epsilon_ + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateEpsilon("epsilon", mesh_) + ), + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) + ) +{ + mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp RNGkEpsilon::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))), + k_.boundaryField().types() + ) + ); +} + + +tmp RNGkEpsilon::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -muEff()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp RNGkEpsilon::divDevRhoReff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +bool RNGkEpsilon::read() +{ + if (RASModel::read()) + { + Cmu_.readIfPresent(coeffDict_); + C1_.readIfPresent(coeffDict_); + C2_.readIfPresent(coeffDict_); + C3_.readIfPresent(coeffDict_); + alphak_.readIfPresent(coeffDict_); + alphaEps_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + eta0_.readIfPresent(coeffDict_); + beta_.readIfPresent(coeffDict_); + + return true; + } + else + { + return false; + } +} + + +void RNGkEpsilon::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + return; + } + + RASModel::correct(); + + volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_)); + + if (mesh_.moving()) + { + divU += fvc::div(mesh_.phi()); + } + + tmp tgradU = fvc::grad(U_); + volScalarField S2 = (tgradU() && dev(twoSymm(tgradU()))); + tgradU.clear(); + + volScalarField G("G", mut_*S2); + + volScalarField eta = sqrt(mag(S2))*k_/epsilon_; + volScalarField eta3 = eta*sqr(eta); + + volScalarField R = + ((eta*(-eta/eta0_ + scalar(1)))/(beta_*eta3 + scalar(1))); + + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); + + // Dissipation equation + tmp epsEqn + ( + fvm::ddt(rho_, epsilon_) + + fvm::div(phi_, epsilon_) + - fvm::laplacian(DepsilonEff(), epsilon_) + == + (C1_ - R)*G*epsilon_/k_ + - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_) + - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_) + ); + + epsEqn().relax(); + + epsEqn().boundaryManipulate(epsilon_.boundaryField()); + + solve(epsEqn); + bound(epsilon_, epsilon0_); + + + // Turbulent kinetic energy equation + + tmp kEqn + ( + fvm::ddt(rho_, k_) + + fvm::div(phi_, k_) + - fvm::laplacian(DkEff(), k_) + == + G - fvm::SuSp(2.0/3.0*rho_*divU, k_) + - fvm::Sp(rho_*(epsilon_)/k_, k_) + ); + + kEqn().relax(); + solve(kEqn); + bound(k_, k0_); + + + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.H b/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.H new file mode 100644 index 0000000000..98445ced1d --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.H @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::RNGkEpsilon + +Description + Renormalisation group k-epsilon turbulence model for compressible flows. + + The default model coefficients correspond to the following: + @verbatim + RNGkEpsilonCoeffs + { + Cmu 0.0845; + C1 1.42; + C2 1.68; + C3 -0.33; // only for compressible + alphah 1.0; // only for compressible + alphak 1.39; + alphaEps 1.39; + eta0 4.38; + beta 0.012; + } + @endverbatim + +SourceFiles + RNGkEpsilon.C + RNGkEpsilonCorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleRNGkEpsilon_H +#define compressibleRNGkEpsilon_H + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class RNGkEpsilon Declaration +\*---------------------------------------------------------------------------*/ + +class RNGkEpsilon +: + public RASModel +{ + // Private data + + dimensionedScalar Cmu_; + dimensionedScalar C1_; + dimensionedScalar C2_; + dimensionedScalar C3_; + dimensionedScalar alphak_; + dimensionedScalar alphaEps_; + dimensionedScalar alphah_; + dimensionedScalar eta0_; + dimensionedScalar beta_; + + volScalarField k_; + volScalarField epsilon_; + volScalarField mut_; + volScalarField alphat_; + + +public: + + //- Runtime type information + TypeName("RNGkEpsilon"); + + // Constructors + + //- from components + RNGkEpsilon + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~RNGkEpsilon(){} + + + // Member Functions + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", alphak_*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for epsilon + tmp DepsilonEff() const + { + return tmp + ( + new volScalarField("DepsilonEff", alphaEps_*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return epsilon_; + } + + //- Return the Reynolds stress tensor + tmp R() const; + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the effective stress tensor including the laminar stress + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C new file mode 100644 index 0000000000..d0757ab142 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C @@ -0,0 +1,353 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpalartAllmaras.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(SpalartAllmaras, 0); +addToRunTimeSelectionTable(RASModel, SpalartAllmaras, dictionary); + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +tmp SpalartAllmaras::chi() const +{ + return rho_*nuTilda_/mu(); +} + + +tmp SpalartAllmaras::fv1(const volScalarField& chi) const +{ + volScalarField chi3 = pow3(chi); + return chi3/(chi3 + pow3(Cv1_)); +} + + +tmp SpalartAllmaras::fv2 +( + const volScalarField& chi, + const volScalarField& fv1 +) const +{ + return 1.0 - chi/(1.0 + chi*fv1); + //return 1.0/pow3(scalar(1) + chi/Cv2); +} + + +tmp SpalartAllmaras::fv3 +( + const volScalarField& chi, + const volScalarField& fv1 +) const +{ + volScalarField chiByCv2 = (1/Cv2_)*chi; + + return + (scalar(1) + chi*fv1) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); +} + + +tmp SpalartAllmaras::fw(const volScalarField& Stilda) const +{ + volScalarField r = min + ( + nuTilda_ + /( + max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL)) + *sqr(kappa_*d_) + ), + scalar(10.0) + ); + r.boundaryField() == 0.0; + + volScalarField g = r + Cw2_*(pow6(r) - r); + + return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +SpalartAllmaras::SpalartAllmaras +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + alphaNut_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaNut", + coeffDict_, + 1.5 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + + Cb1_ + ( + dimensioned::lookupOrAddToDict + ( + "Cb1", + coeffDict_, + 0.1355 + ) + ), + Cb2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cb2", + coeffDict_, + 0.622 + ) + ), + Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)), + Cw2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cw2", + coeffDict_, + 0.3 + ) + ), + Cw3_ + ( + dimensioned::lookupOrAddToDict + ( + "Cw3", + coeffDict_, + 2.0 + ) + ), + Cv1_ + ( + dimensioned::lookupOrAddToDict + ( + "Cv1", + coeffDict_, + 7.1 + ) + ), + Cv2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cv2", + coeffDict_, + 5.0 + ) + ), + + nuTilda_ + ( + IOobject + ( + "nuTilda", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + d_(mesh_) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp SpalartAllmaras::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*k() - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp SpalartAllmaras::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -muEff()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp SpalartAllmaras::divDevRhoReff(volVectorField& U) const +{ + volScalarField muEff_ = muEff(); + + return + ( + - fvm::laplacian(muEff_, U) + - fvc::div(muEff_*dev2(fvc::grad(U)().T())) + ); +} + + +bool SpalartAllmaras::read() +{ + if (RASModel::read()) + { + alphaNut_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + + Cb1_.readIfPresent(coeffDict_); + Cb2_.readIfPresent(coeffDict_); + Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_); + Cw2_.readIfPresent(coeffDict_); + Cw3_.readIfPresent(coeffDict_); + Cv1_.readIfPresent(coeffDict_); + Cv2_.readIfPresent(coeffDict_); + + return true; + } + else + { + return false; + } +} + + +void SpalartAllmaras::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ = rho_*nuTilda_*fv1(chi()); + return; + } + + RASModel::correct(); + + if (mesh_.changing()) + { + d_.correct(); + } + + volScalarField chi = this->chi(); + volScalarField fv1 = this->fv1(chi); + + volScalarField Stilda = + fv3(chi, fv1)*::sqrt(2.0)*mag(skew(fvc::grad(U_))) + + fv2(chi, fv1)*nuTilda_/sqr(kappa_*d_); + + tmp nuTildaEqn + ( + fvm::ddt(rho_, nuTilda_) + + fvm::div(phi_, nuTilda_) + - fvm::laplacian(DnuTildaEff(), nuTilda_) + - alphaNut_*Cb2_*rho_*magSqr(fvc::grad(nuTilda_)) + == + Cb1_*rho_*Stilda*nuTilda_ + - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_*rho_/sqr(d_), nuTilda_) + ); + + nuTildaEqn().relax(); + solve(nuTildaEqn); + bound(nuTilda_, dimensionedScalar("0", nuTilda_.dimensions(), 0.0)); + nuTilda_.correctBoundaryConditions(); + + mut_.internalField() = fv1*nuTilda_.internalField()*rho_.internalField(); + mut_.correctBoundaryConditions(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H new file mode 100644 index 0000000000..da3aa6fc2e --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H @@ -0,0 +1,245 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::SpalartAllmaras + +Description + Spalart-Allmaras one-eqn mixing-length model for compressible + external flows. + + Reference: + @verbatim + "A One-Equation Turbulence Model for Aerodynamic Flows" + P.R. Spalart, + S.R. Allmaras, + La Recherche A´rospatiale, No. 1, 1994, pp. 5–21. + + Extended according to: + + "An Unstructured Grid Generation and Adaptive Solution Technique + for High Reynolds Number Compressible Flows" + G.A. Ashford, + Ph.D. thesis, University of Michigan, 1996. + @endverbatim + + The default model coefficients correspond to the following: + @verbatim + SpalartAllmarasCoeffs + { + Cb1 0.1355; + Cb2 0.622; + Cw2 0.3; + Cw3 2.0; + Cv1 7.1; + Cv2 5.0; + alphaNut 1.5; + alphah 1.0; // only for compressible + } + @endverbatim + +SourceFiles + SpalartAllmaras.C + SpalartAllmarasCorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleSpalartAllmaras_H +#define combressibleSpalartAllmaras_H + +#include "RASModel.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class SpalartAllmaras Declaration +\*---------------------------------------------------------------------------*/ + +class SpalartAllmaras +: + public RASModel +{ + // Private data + + dimensionedScalar alphaNut_; + dimensionedScalar alphah_; + + dimensionedScalar Cb1_; + dimensionedScalar Cb2_; + dimensionedScalar Cw1_; + dimensionedScalar Cw2_; + dimensionedScalar Cw3_; + dimensionedScalar Cv1_; + dimensionedScalar Cv2_; + + volScalarField nuTilda_; + volScalarField mut_; + + wallDist d_; + + + // Private member functions + + tmp chi() const; + tmp fv1(const volScalarField& chi) const; + tmp fv2 + ( + const volScalarField& chi, + const volScalarField& fv1 + ) const; + tmp fv3 + ( + const volScalarField& chi, + const volScalarField& fv1 + ) const; + tmp fw(const volScalarField& Stilda) const; + + +public: + + //- Runtime type information + TypeName("SpalartAllmaras"); + + + // Constructors + + //- from components + SpalartAllmaras + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~SpalartAllmaras() + {} + + + // Member Functions + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for nuTilda + tmp DnuTildaEff() const + { + return tmp + ( + new volScalarField + ( + "DnuTildaEff", + alphaNut_*rho_*nuTilda_ + mu() + ) + ); + } + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*mut_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return tmp + ( + new volScalarField + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_ + ), + mesh_, + dimensionedScalar("0", dimensionSet(0, 2, -2, 0, 0), 0) + ) + ); + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return tmp + ( + new volScalarField + ( + IOobject + ( + "epslion", + runTime_.timeName(), + mesh_ + ), + mesh_, + dimensionedScalar("0", dimensionSet(0, 2, -3, 0, 0), 0) + ) + ); + } + + //- Return the Reynolds stress tensor + tmp R() const; + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C new file mode 100644 index 0000000000..19df95a3d5 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -0,0 +1,286 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "backwardsCompatibilityWallFunctions.H" + +#include "calculatedFvPatchField.H" +#include "alphatWallFunctionFvPatchScalarField.H" +#include "mutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "kQRWallFunctionFvPatchField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +tmp autoCreateAlphat +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject alphatHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (alphatHeader.headerOk()) + { + return tmp(new volScalarField(alphatHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList alphatBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + alphatBoundaryTypes[patchI] = + RASModels::alphatWallFunctionFvPatchScalarField::typeName; + } + else + { + alphatBoundaryTypes[patchI] = + calculatedFvPatchField::typeName; + } + } + + tmp alphat + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + alphatBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + alphat().write(); + + return alphat; + } +} + + +tmp autoCreateMut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject mutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (mutHeader.headerOk()) + { + return tmp(new volScalarField(mutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList mutBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + mutBoundaryTypes[patchI] = + RASModels::mutWallFunctionFvPatchScalarField::typeName; + } + else + { + mutBoundaryTypes[patchI] = + calculatedFvPatchField::typeName; + } + } + + tmp mut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + mutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + mut().write(); + + return mut; + } +} + + +tmp autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) +{ + return + autoCreateWallFunctionField + < + scalar, + RASModels::epsilonWallFunctionFvPatchScalarField + > + ( + fieldName, + mesh + ); +} + + +tmp autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) +{ + return + autoCreateWallFunctionField + < + scalar, + RASModels::omegaWallFunctionFvPatchScalarField + > + ( + fieldName, + mesh + ); +} + + +tmp autoCreateK +( + const word& fieldName, + const fvMesh& mesh +) +{ + return + autoCreateWallFunctionField + < + scalar, + RASModels::kQRWallFunctionFvPatchField + > + ( + fieldName, + mesh + ); +} + + +tmp autoCreateQ +( + const word& fieldName, + const fvMesh& mesh +) +{ + return + autoCreateWallFunctionField + < + scalar, + RASModels::kQRWallFunctionFvPatchField + > + ( + fieldName, + mesh + ); +} + + +tmp autoCreateR +( + const word& fieldName, + const fvMesh& mesh +) +{ + return + autoCreateWallFunctionField + < + symmTensor, + RASModels::kQRWallFunctionFvPatchField + > + ( + fieldName, + mesh + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // + diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H new file mode 100644 index 0000000000..bcc812a6b4 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H @@ -0,0 +1,123 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible + +Description + Auto creation of fields to provide backwards compatibility with + runtime selectable wall functions + +SourceFiles + backwardsCompatibilityWallFunctions.C + backwardsCompatibilityWallFunctionsTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef backwardsCompatibilityWallFunctions_H +#define backwardsCompatibilityWallFunctions_H + +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + //- mut + tmp autoCreateMut + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- alphat + tmp autoCreateAlphat + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- k + tmp autoCreateK + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Q + tmp autoCreateQ + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- R + tmp autoCreateR + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "backwardsCompatibilityWallFunctionsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C new file mode 100644 index 0000000000..d6b489ffea --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "backwardsCompatibilityWallFunctions.H" +#include "Time.H" + +#include "wallPolyPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +tmp > +autoCreateWallFunctionField +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject mutHeader + ( + "mut", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ + ); + + typedef GeometricField fieldType; + + if (mutHeader.headerOk()) + { + return tmp + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh + ) + ); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + // Read existing epsilon field + tmp fieldOrig + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh + ) + ); + + PtrList > newPatchFields(mesh.boundary().size()); + + forAll(newPatchFields, patchI) + { + if (isType(mesh.boundaryMesh()[patchI])) + { + newPatchFields.set + ( + patchI, + new PatchType + ( + mesh.boundary()[patchI], + fieldOrig().dimensionedInternalField() + ) + ); + newPatchFields[patchI] == fieldOrig().boundaryField()[patchI]; + } + else + { + newPatchFields.set + ( + patchI, + fieldOrig().boundaryField()[patchI].clone() + ); + } + } + + tmp fieldNew + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + fieldOrig().dimensions(), + fieldOrig().internalField(), + newPatchFields + ) + ); + + Info<< " Writing backup of original " << fieldName << " to " + << fieldName << ".old" << endl; + fieldOrig().rename(fieldName + ".old"); + fieldOrig().write(); + + Info<< " Writing updated " << fieldName << endl; + fieldNew().write(); + + return fieldNew; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000..9cd3901fe3 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,203 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "turbulentHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(p, iF), + q_(p.size(), 0.0), + rhoName_("undefinedRho") +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), + q_(ptf.q_, mapper), + rhoName_(ptf.rhoName_) +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchScalarField(p, iF), + q_("q", dict, p.size()), + rhoName_(dict.lookup("rho")) +{ + fvPatchField::operator=(patchInternalField()); + gradient() = 0.0; +} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf +) +: + fixedGradientFvPatchScalarField(thftpsf), + q_(thftpsf.q_), + rhoName_(thftpsf.rhoName_) +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(thftpsf, iF), + q_(thftpsf.q_), + rhoName_(thftpsf.rhoName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedGradientFvPatchScalarField::autoMap(m); + q_.autoMap(m); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedGradientFvPatchScalarField::rmap(ptf, addr); + + const turbulentHeatFluxTemperatureFvPatchScalarField& thftptf = + refCast + ( + ptf + ); + + q_.rmap(thftptf.q_, addr); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const label patchI = patch().index(); + + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalarField alphaEffp = ras.alphaEff()().boundaryField()[patchI]; + + const basicThermo& thermo = + db().lookupObject("thermophysicalProperties"); + +// const scalarField& Tp = thermo.T().boundaryField()[patchI]; + const scalarField& Tp = *this; + + const scalarField Cpp = thermo.Cp(Tp, patchI); + + const scalarField& rhop = + patch().lookupPatchField(rhoName_); + + const scalar Ap = gSum(patch().magSf()); + + gradient() = q_/(Ap*rhop*Cpp*alphaEffp); + + fixedGradientFvPatchScalarField::updateCoeffs(); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + q_.writeEntry("q", os); + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + gradient().writeEntry("gradient", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentHeatFluxTemperatureFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // + diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 0000000000..c2ee7be012 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::turbulentHeatFluxTemperatureFvPatchScalarField + +Description + Fixed heat flux boundary condition for temperature. + +SourceFiles + turbulentHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentHeatFluxTemperatureFvPatchScalarFields_H +#define turbulentHeatFluxTemperatureFvPatchScalarFields_H + +#include "fvPatchFields.H" +#include "fixedGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentHeatFluxTemperatureFvPatchScalarField +: + public fixedGradientFvPatchScalarField +{ +// Private data + + //- Heat flux [W] + scalarField q_; + + //- Name of density field + word rhoName_; + + +public: + + //- Runtime type information + TypeName("turbulentHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentHeatFluxTemperatureFvPatchScalarField onto + // a new patch + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentHeatFluxTemperatureFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // 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& + ); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C new file mode 100644 index 0000000000..01b341748d --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "turbulentMixingLengthDissipationRateInletFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + mixingLength_(0.001) +{} + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(ptf, p, iF, mapper), + mixingLength_(ptf.mixingLength_) +{} + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF, dict), + mixingLength_(readScalar(dict.lookup("mixingLength"))) +{} + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf +) +: + fixedValueFvPatchField(ptf), + mixingLength_(ptf.mixingLength_) +{} + +turbulentMixingLengthDissipationRateInletFvPatchScalarField:: +turbulentMixingLengthDissipationRateInletFvPatchScalarField +( + const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(ptf, iF), + mixingLength_(ptf.mixingLength_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentMixingLengthDissipationRateInletFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Lookup Cmu corresponding to the turbulence model selected + const compressible::RASModel& RAS = + db().lookupObject("RASProperties"); + scalar Cmu = readScalar(RAS.coeffDict().lookup("Cmu")); + + scalar Cmu75 = pow(Cmu, 0.75); + + const fvPatchField& k = + patch().lookupPatchField("k"); + + operator==(Cmu75*k*sqrt(k)/mixingLength_); + + fixedValueFvPatchField::updateCoeffs(); +} + + +void turbulentMixingLengthDissipationRateInletFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchField::write(os); + os.writeKeyword("mixingLength") + << mixingLength_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentMixingLengthDissipationRateInletFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H new file mode 100644 index 0000000000..8b13df2af0 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible:: + turbulentMixingLengthDissipationRateInletFvPatchScalarField + +Description + Calculate epsilon via the mixing length [m] + + Example of the boundary condition specification: + @verbatim + inlet + { + type turbulentMixingLengthDissipationRateInlet; + mixingLength 0.005; // 5 mm + value uniform 200; // placeholder + } + @endverbatim + +SourceFiles + turbulentMixingLengthDissipationRateInletFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleturbulentMixingLengthDissipationRateInletFvPatchField_H +#define compressibleturbulentMixingLengthDissipationRateInletFvPatchField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentMixingLengthDissipationRateInletFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentMixingLengthDissipationRateInletFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- turbulent length scale + scalar mixingLength_; + +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 compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C new file mode 100644 index 0000000000..92f01a9a7b --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "turbulentMixingLengthFrequencyInletFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + mixingLength_(0.0), + kName_("undefined-k") +{} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(ptf, p, iF, mapper), + mixingLength_(ptf.mixingLength_), + kName_(ptf.kName_) +{} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF, dict), + mixingLength_(readScalar(dict.lookup("mixingLength"))), + kName_(dict.lookup("k")) +{} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf +) +: + fixedValueFvPatchField(ptf), + mixingLength_(ptf.mixingLength_), + kName_(ptf.kName_) +{} + +turbulentMixingLengthFrequencyInletFvPatchScalarField:: +turbulentMixingLengthFrequencyInletFvPatchScalarField +( + const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(ptf, iF), + mixingLength_(ptf.mixingLength_), + kName_(ptf.kName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Lookup Cmu corresponding to the turbulence model selected + const compressible::RASModel& RAS = + db().lookupObject("RASProperties"); + scalar Cmu = readScalar(RAS.coeffDict().lookup("Cmu")); + + scalar Cmu25 = pow(Cmu, 0.25); + + const fvPatchField& kp = + patch().lookupPatchField(kName_); + + operator==(sqrt(kp)/(Cmu25*mixingLength_)); + + fixedValueFvPatchField::updateCoeffs(); +} + + +void turbulentMixingLengthFrequencyInletFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchField::write(os); + os.writeKeyword("mixingLength") + << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentMixingLengthFrequencyInletFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H new file mode 100644 index 0000000000..ebba209f1e --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::turbulentMixingLengthFrequencyInletFvPatchScalarField + +Description + Calculate omega via the mixing length + + Example of the boundary condition specification: + @verbatim + inlet + { + type turbulentMixingLengthFrequencyInlet; + mixingLength 0.005; // 5 mm + k k; // turbulent k field + value uniform 5; // initial value + } + @endverbatim + +SourceFiles + turbulentMixingLengthFrequencyInletFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleturbulentMixingLengthFrequencyInletFvPatchScalarField_H +#define compressibleturbulentMixingLengthFrequencyInletFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentMixingLengthFrequencyInletFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentMixingLengthFrequencyInletFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Turbulent length scale + scalar mixingLength_; + + //- 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 compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..a34631cc3c --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "alphatWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const alphatWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const alphatWallFunctionFvPatchScalarField& awfpsf +) +: + fixedValueFvPatchScalarField(awfpsf) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const alphatWallFunctionFvPatchScalarField& awfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(awfpsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void alphatWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + const scalar Prt = ras.Prt().value(); + + const scalarField& mutw = + patch().lookupPatchField("mut"); + + operator==(mutw/Prt); +} + + +void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, alphatWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..d94775a342 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::alphatWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent thermal diffusivity when using wall + functions + - replicates OpenFOAM v1.5 (and earlier) behaviour + +SourceFiles + alphatWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphatWallFunctionFvPatchScalarField_H +#define alphatWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class alphatWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class alphatWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("alphatWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + alphatWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + alphatWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // alphatWallFunctionFvPatchScalarField + // onto a new patch + alphatWallFunctionFvPatchScalarField + ( + const alphatWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphatWallFunctionFvPatchScalarField + ( + const alphatWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new alphatWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + alphatWallFunctionFvPatchScalarField + ( + const alphatWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new alphatWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..b22c101340 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private 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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(p, iF) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedInternalValueFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedInternalValueFvPatchField(p, iF, dict) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ewfpsf +) +: + fixedInternalValueFvPatchField(ewfpsf) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(ewfpsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void epsilonWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar Cmu75 = pow(Cmu, 0.75); + const scalar kappa = ras.kappa().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + volScalarField& G = const_cast + (db().lookupObject("G")); + + volScalarField& epsilon = const_cast + (db().lookupObject("epsilon")); + + const volScalarField& k = db().lookupObject("k"); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + const scalarField& mutw = + patch().lookupPatchField("mut"); + + const fvPatchVectorField& Uw = + patch().lookupPatchField("U"); + + const scalarField magGradUw = mag(Uw.snGrad()); + + // Set epsilon and G + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = + Cmu25*y[faceI]*sqrt(k[faceCellI]) + /(muw[faceI]/rhow[faceI]); + + epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceI]); + + if (yPlus > yPlusLam) + { + G[faceCellI] = + (mutw[faceI] + muw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[faceCellI]) + /(kappa*y[faceI]); + } + else + { + G[faceCellI] = 0.0; + } + } + + // TODO: perform averaging for cells sharing more than one boundary face +} + + +void epsilonWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes commsType +) +{ + fixedInternalValueFvPatchField::evaluate(commsType); +} + + +void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fixedInternalValueFvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + epsilonWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..2cb6b336bf --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::epsilonWallFunctionFvPatchScalarField + +Description + Boundary condition for epsilon when using wall functions + - calculates epsilon and G + - epsilon values added directly into the matrix to act as a constraint + +SourceFiles + epsilonWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef epsilonWallFunctionFvPatchScalarField_H +#define epsilonWallFunctionFvPatchScalarField_H + +#include "fixedInternalValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class epsilonWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class epsilonWallFunctionFvPatchScalarField +: + public fixedInternalValueFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("epsilonWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + epsilonWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + epsilonWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // epsilonWallFunctionFvPatchScalarField + // onto a new patch + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new epsilonWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new epsilonWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Evaluate the patchField + virtual void evaluate(const Pstream::commsTypes); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C new file mode 100644 index 0000000000..9f6a7d71f9 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kQRWallFunctionFvPatchField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void kQRWallFunctionFvPatchField::checkType() +{ + if (!isA(this->patch())) + { + FatalErrorIn("kQRWallFunctionFvPatchField::checkType()") + << "Invalid wall function specification" << nl + << " Patch type for patch " << this->patch().name() + << " must be wall" << nl + << " Current patch type is " << this->patch().type() + << nl << endl << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(p, iF) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const kQRWallFunctionFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchField(p, iF, dict) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const kQRWallFunctionFvPatchField& tkqrwfpf +) +: + zeroGradientFvPatchField(tkqrwfpf) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const kQRWallFunctionFvPatchField& tkqrwfpf, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(tkqrwfpf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void kQRWallFunctionFvPatchField::evaluate +( + const Pstream::commsTypes commsType +) +{ + zeroGradientFvPatchField::evaluate(commsType); +} + + +template +void kQRWallFunctionFvPatchField::write(Ostream& os) const +{ + zeroGradientFvPatchField::write(os); + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H new file mode 100644 index 0000000000..05ed2fbcb8 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::kQRWallFunctionFvPatchField + +Description + Boundary condition for turbulence k, Q, and R when using wall functions. + Simply acts as a zero gradient condition. + +SourceFiles + kQRWallFunctionFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kQRWallFunctionFvPatchField_H +#define kQRWallFunctionFvPatchField_H + +#include "zeroGradientFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class kQRWallFunctionFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class kQRWallFunctionFvPatchField +: + public zeroGradientFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("kQRWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + kQRWallFunctionFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + kQRWallFunctionFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // kQRWallFunctionFvPatchField + // onto a new patch + kQRWallFunctionFvPatchField + ( + const kQRWallFunctionFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + kQRWallFunctionFvPatchField + ( + const kQRWallFunctionFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new kQRWallFunctionFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + kQRWallFunctionFvPatchField + ( + const kQRWallFunctionFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new kQRWallFunctionFvPatchField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::Pstream::blocking + ); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "kQRWallFunctionFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C new file mode 100644 index 0000000000..6942ba56b1 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kQRWallFunctionFvPatchFields.H" +#include "fvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(kQRWallFunction); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H new file mode 100644 index 0000000000..e1297548be --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#ifndef kQRWallFunctionFvPatchFields_H +#define kQRWallFunctionFvPatchFields_H + +#include "kQRWallFunctionFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(kQRWallFunction) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..67ad5536df --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mutRoughWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +scalar mutRoughWallFunctionFvPatchScalarField::fnRough +( + const scalar KsPlus, + const scalar Cs, + const scalar kappa +) const +{ + // Set deltaB based on non-dimensional roughness height + scalar deltaB = 0.0; + if (KsPlus < 90.0) + { + deltaB = + 1.0/kappa + *log((KsPlus - 2.25)/87.75 + Cs*KsPlus) + *sin(0.4258*(log(KsPlus) - 0.811)); + } + else + { + deltaB = 1.0/kappa*log(1.0 + Cs*KsPlus); + } + + return exp(min(deltaB*kappa, 50.0)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + Ks_(p.size(), 0.0), + Cs_(p.size(), 0.0) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const mutRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + Ks_(ptf.Ks_, mapper), + Cs_(ptf.Cs_, mapper) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + Ks_("Ks", dict, p.size()), + Cs_("Cs", dict, p.size()) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const mutRoughWallFunctionFvPatchScalarField& nrwfpsf +) +: + fixedValueFvPatchScalarField(nrwfpsf), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const mutRoughWallFunctionFvPatchScalarField& nrwfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(nrwfpsf, iF), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutRoughWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + Ks_.autoMap(m); + Cs_.autoMap(m); +} + + +void mutRoughWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const mutRoughWallFunctionFvPatchScalarField& nrwfpsf = + refCast(ptf); + + Cs_.rmap(nrwfpsf.Cs_, addr); + Ks_.rmap(nrwfpsf.Ks_, addr); +} + + +void mutRoughWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& k = db().lookupObject("k"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + scalarField& mutw = *this; + + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uStar = Cmu25*sqrt(k[faceCellI]); + + scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]); + + scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]); + + scalar Edash = E; + scalar yPlusLamNew = yPlusLam; + if (KsPlus > 2.25) + { + Edash = E/fnRough(KsPlus, Cs_[faceI], kappa); + yPlusLam = ras.yPlusLam(kappa, Edash); + } + + if (debug) + { + Info<< "yPlus = " << yPlus + << ", KsPlus = " << KsPlus + << ", Edash = " << Edash + << ", yPlusLam = " << yPlusLam + << endl; + } + + if (yPlus > yPlusLamNew) + { + mutw[faceI] = muw[faceI]*(yPlus*kappa/log(Edash*yPlus) - 1); + } + else + { + mutw[faceI] = 0.0; + } + } +} + + +void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + Cs_.writeEntry("Cs", os); + Ks_.writeEntry("Ks", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, mutRoughWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..830e320646 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::nutRoughWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) viscosity when using wall + functions for rough walls. + + Manipulates the E parameter to account for roughness effects, based on + KsPlus. + + - roughness height = sand-grain roughness (0 for smooth walls) + - roughness constant = 0.5-1.0 (0.5 default) + +SourceFiles + mutRoughWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutRoughWallFunctionFvPatchScalarField_H +#define mutRoughWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutRoughWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutRoughWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Roughness height + scalarField Ks_; + + //- Roughness constant + scalarField Cs_; + + + // Private member functions + + //- Compute the roughness function + scalar fnRough + ( + const scalar KsPlus, + const scalar Cs, + const scalar kappa + ) const; + + +public: + + //- Runtime type information + TypeName("mutRoughWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutRoughWallFunctionFvPatchScalarField + // onto a new patch + mutRoughWallFunctionFvPatchScalarField + ( + const mutRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutRoughWallFunctionFvPatchScalarField + ( + const mutRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutRoughWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutRoughWallFunctionFvPatchScalarField + ( + const mutRoughWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutRoughWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // 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& + ); + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..8cff5793be --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,314 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + roughnessHeight_(pTraits::zero), + roughnessConstant_(pTraits::zero), + roughnessFudgeFactor_(pTraits::zero) +{} + + +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + roughnessHeight_(ptf.roughnessHeight_), + roughnessConstant_(ptf.roughnessConstant_), + roughnessFudgeFactor_(ptf.roughnessFudgeFactor_) +{} + + +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))), + roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))), + roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor"))) +{} + + +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf), + roughnessHeight_(tppsf.roughnessHeight_), + roughnessConstant_(tppsf.roughnessConstant_), + roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_) +{} + + +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF), + roughnessHeight_(tppsf.roughnessHeight_), + roughnessConstant_(tppsf.roughnessConstant_), + roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& rasModel + = db().lookupObject("RASProperties"); + + const scalar kappa = rasModel.kappa().value(); + const scalar E = rasModel.E().value(); + const scalar yPlusLam = 11.225; + + // The reciprical of the distance to the adjacent cell centre. + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + const fvPatchScalarField& rho = + patch().lookupPatchField("rho"); + + // The flow velocity at the adjacent cell centre. + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& muw = + patch().lookupPatchField("mu"); + scalarField& mutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + if(roughnessHeight_ > 0.0) + { + // Rough Walls. + const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; + static const scalar c_2 = 2.25/(90 - 2.25); + static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); + static const scalar c_4 = c_3*log(2.25); + + //if (KsPlusBasedOnYPlus_) + { + // If KsPlus is based on YPlus the extra term added to the law + // of the wall will depend on yPlus. + forAll(mutw, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = rho[facei]*magUpara/(muw[facei]*ry[facei]); + const scalar kappaRe = kappa*Re; + + scalar yPlus = yPlusLam; + const scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + scalar dKsPlusdYPlus = roughnessHeight_*ry[facei]; + + // Enforce the roughnessHeight to be less than the distance to + // the first cell centre. + if(dKsPlusdYPlus > 1) + { + dKsPlusdYPlus = 1; + } + + // Fudge factor to get results to be similar to fluent + // (at least difference between rough and smooth). + dKsPlusdYPlus *= roughnessFudgeFactor_; + + do + { + yPlusLast = yPlus; + + // The non-dimensional roughness height. + scalar KsPlus = yPlus*dKsPlusdYPlus; + + // The extra term in the law-of-the-wall. + scalar G = 0.0; + + scalar yPlusGPrime = 0.0; + + if (KsPlus >= 90) + { + const scalar t_1 = 1 + roughnessConstant_*KsPlus; + G = log(t_1); + yPlusGPrime = roughnessConstant_*KsPlus/t_1; + } + else if (KsPlus > 2.25) + { + const scalar t_1 = c_1*KsPlus - c_2; + const scalar t_2 = c_3*log(KsPlus) - c_4; + const scalar sint_2 = sin(t_2); + const scalar logt_1 = log(t_1); + G = logt_1*sint_2; + yPlusGPrime = + (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); + } + + scalar denom = 1.0 + log(E* yPlus) - G - yPlusGPrime; + if(mag(denom) > VSMALL) + { + yPlus = (kappaRe + yPlus*(1 - yPlusGPrime))/denom; + if( yPlus < 0 ) + { + yPlus = 0; + } + } + else + { + // Ensure immediate end and mutw = 0. + yPlus = 0; + } + + } while + ( + mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 + && ++iter < 10 + && yPlus > VSMALL + ); + + if (yPlus > yPlusLam) + { + mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); + } + else + { + mutw[facei] = 0.0; + } + } + } + } + else + { + // Smooth Walls. + forAll(mutw, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = rho[facei]*magUpara/(muw[facei]*ry[facei]); + const scalar kappaRe = kappa*Re; + + scalar yPlus = yPlusLam; + const scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yPlus; + yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); + + } while + ( + mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 + && ++iter < 10 + ); + + if (yPlus > yPlusLam) + { + mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); + } + else + { + mutw[facei] = 0.0; + } + } + } +} + + +void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write +( + Ostream& os +) const +{ + fixedValueFvPatchScalarField::write(os); + os.writeKeyword("roughnessHeight") + << roughnessHeight_ << token::END_STATEMENT << nl; + os.writeKeyword("roughnessConstant") + << roughnessConstant_ << token::END_STATEMENT << nl; + os.writeKeyword("roughnessFudgeFactor") + << roughnessFudgeFactor_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..7341cea241 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels:: + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for rough walls + +SourceFiles + mutSpalartAllamarasStandardWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H +#define mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ +Class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + scalar roughnessHeight_; + scalar roughnessConstant_; + scalar roughnessFudgeFactor_; + + +public: + + //- Runtime type information + TypeName("mutSpalartAllmarasStandardRoughWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + // onto a new patch + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return the fluctuation scale + const scalar& roughnessHeight() const + { + return roughnessHeight_; + } + + //- Return reference to the fluctuation scale to allow adjustment + scalar& roughnessHeight() + { + return roughnessHeight_; + } + + + //- Return the fluctuation scale + const scalar& roughnessConstant() const + { + return roughnessConstant_; + } + + //- Return reference to the fluctuation scale to allow adjustment + scalar& roughnessConstant() + { + return roughnessConstant_; + } + + //- Return the fluctuation scale + const scalar& roughnessFudgeFactor() const + { + return roughnessFudgeFactor_; + } + + //- Return reference to the fluctuation scale to allow adjustment + scalar& roughnessFudgeFactor() + { + return roughnessFudgeFactor_; + } + + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); + + + //- Write + virtual void write(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..669d0e72f8 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + scalar kappa = ras.kappa().value(); + scalar E = ras.E().value(); + scalar yPlusLam = ras.yPlusLam(); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + scalarField& mutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(mutw, faceI) + { + scalar magUpara = magUp[faceI]; + + scalar kappaRe = kappa*magUpara/((muw[faceI]/rhow[faceI])*ry[faceI]); + + scalar yPlus = yPlusLam; + scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yPlus; + yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); + + } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); + + if (yPlus > yPlusLam) + { + mutw[faceI] = muw[faceI]*(yPlus*kappa/log(E*yPlus) - 1); + } + else + { + mutw[faceI] = 0.0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..c55a1fb0c6 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels:: + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for walls + +SourceFiles + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H +#define mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("mutSpalartAllmarasStandardWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + // onto a new patch + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..f9e92d19ba --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mutSpalartAllmarasWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + scalar kappa = ras.kappa().value(); + scalar E = ras.E().value(); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + scalarField& mutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(mutw, faceI) + { + scalar magUpara = magUp[faceI]; + + scalar utau = + sqrt((mutw[faceI] + muw[faceI])*magFaceGradU[faceI]/rhow[faceI]); + + if (utau > VSMALL) + { + int iter = 0; + scalar err = GREAT; + + do + { + scalar kUu = min(kappa*magUpara/utau, 50); + scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); + + scalar f = + - utau/(ry[faceI]*(muw[faceI]/rhow[faceI])) + + magUpara/utau + + 1/E*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + + scalar df = + 1.0/(ry[faceI]*(muw[faceI]/rhow[faceI])) + + magUpara/sqr(utau) + + 1/E*kUu*fkUu/utau; + + scalar utauNew = utau + f/df; + err = mag((utau - utauNew)/utau); + utau = utauNew; + + } while (utau > VSMALL && err > 0.01 && ++iter < 10); + + mutw[faceI] = max + ( + rhow[faceI]*sqr(max(utau, 0))/magFaceGradU[faceI]- muw[faceI], + 0.0 + ); + } + else + { + mutw[faceI] = 0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..8967a243c2 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels:: + mutSpalartAllmarasWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for walls + +SourceFiles + mutSpalartAllmarasWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutSpalartAllmarasWallFunctionFvPatchScalarField_H +#define mutSpalartAllmarasWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutSpalartAllmarasWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutSpalartAllmarasWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ +public: + + //- Runtime type information + TypeName("mutSpalartAllmarasWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutSpalartAllmarasWallFunctionFvPatchScalarField + // onto a new patch + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutSpalartAllmarasWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutSpalartAllmarasWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..f73e5b2a89 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mutWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const volScalarField& k = db().lookupObject("k"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + scalarField& mutw = *this; + + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = + Cmu25*y[faceI]*sqrt(k[faceCellI]) + /(muw[faceI]/rhow[faceI]); + + if (yPlus > yPlusLam) + { + mutw[faceI] = muw[faceI]*(yPlus*kappa/log(E*yPlus) - 1); + } + else + { + mutw[faceI] = 0.0; + } + } +} + + +void mutWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, mutWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..815e50ca70 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::mutWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) viscosity when using wall + functions + - replicates OpenFOAM v1.5 (and earlier) behaviour + +SourceFiles + mutWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutWallFunctionFvPatchScalarField_H +#define mutWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("mutWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutWallFunctionFvPatchScalarField + // onto a new patch + mutWallFunctionFvPatchScalarField + ( + const mutWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutWallFunctionFvPatchScalarField + ( + const mutWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutWallFunctionFvPatchScalarField + ( + const mutWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..5b0ee67630 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "omegaWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void omegaWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("omegaWallFunctionFvPatchScalarField::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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(p, iF) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedInternalValueFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedInternalValueFvPatchField(p, iF, dict) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ewfpsf +) +: + fixedInternalValueFvPatchField(ewfpsf) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(ewfpsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void omegaWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + + const scalar kappa = ras.kappa().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + volScalarField& G = const_cast + (db().lookupObject("G")); + + volScalarField& omega = const_cast + (db().lookupObject("omega")); + + const scalarField& k = db().lookupObject("k"); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + const scalarField& mutw = + patch().lookupPatchField("mut"); + + const fvPatchVectorField& Uw = + patch().lookupPatchField("U"); + + const scalarField magGradUw = mag(Uw.snGrad()); + + // Set epsilon and G + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = + Cmu25*y[faceI]*sqrt(k[faceCellI]) + /(muw[faceI]/rhow[faceI]); + + omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceI]); + + if (yPlus > yPlusLam) + { + G[faceCellI] = + (mutw[faceI] + muw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[faceCellI]) + /(kappa*y[faceI]); + } + else + { + G[faceCellI] = 0.0; + } + } + + // TODO: perform averaging for cells sharing more than one boundary face +} + + +void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fixedInternalValueFvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + omegaWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..266e7987d5 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::omegaWallFunctionFvPatchScalarField + +Description + Replaces functionality in wallFunctionsI.H + +SourceFiles + omegaWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef omegaWallFunctionFvPatchScalarField_H +#define omegaWallFunctionFvPatchScalarField_H + +#include "fixedInternalValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class omegaWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class omegaWallFunctionFvPatchScalarField +: + public fixedInternalValueFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("omegaWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + omegaWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + omegaWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // omegaWallFunctionFvPatchScalarField + // onto a new patch + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new omegaWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new omegaWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/include/wallDissipationI.H b/src/turbulenceModels/compressible/RAS/include/wallDissipationI.H new file mode 100644 index 0000000000..5eb3f49171 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/include/wallDissipationI.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + wallDissipation + +Description + Set wall dissipation in the epsilon matrix + +\*---------------------------------------------------------------------------*/ + +{ + const fvPatchList& patches = mesh_.boundary(); + + forAll(patches, patchi) + { + const fvPatch& p = patches[patchi]; + + if (isType(p)) + { + epsEqn().setValues + ( + p.faceCells(), + epsilon_.boundaryField()[patchi].patchInternalField() + ); + } + } +} + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/include/wallFunctionsI.H b/src/turbulenceModels/compressible/RAS/include/wallFunctionsI.H new file mode 100644 index 0000000000..19aa023b1c --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/include/wallFunctionsI.H @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + wallFunctions + +Description + Calculate wall dissipation from wall-functions. + +\*---------------------------------------------------------------------------*/ + +{ + labelList cellBoundaryFaceCount(epsilon_.size(), 0); + + scalar Cmu25 = pow(Cmu_.value(), 0.25); + scalar Cmu75 = pow(Cmu_.value(), 0.75); + + const fvPatchList& patches = mesh_.boundary(); + + //- Initialise the near-wall G field to zero + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (isType(curPatch)) + { + forAll(curPatch, facei) + { + label faceCelli = curPatch.faceCells()[facei]; + + epsilon_[faceCelli] = 0.0; + G[faceCelli] = 0.0; + } + } + } + + //- Accumulate the wall face contributions to epsilon and G + // Increment cellBoundaryFaceCount for each face for averaging + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (isType(curPatch)) + { +# include "checkPatchFieldTypes.H" + + const scalarField& rhow = rho_.boundaryField()[patchi]; + + const scalarField& muw = mu().boundaryField()[patchi]; + const scalarField& mutw = mut_.boundaryField()[patchi]; + + scalarField magFaceGradU = + mag(U_.boundaryField()[patchi].snGrad()); + + forAll(curPatch, facei) + { + label faceCelli = curPatch.faceCells()[facei]; + + scalar yPlus = + Cmu25*RASModel::y_[patchi][facei] + *sqrt(k_[faceCelli]) + /(muw[facei]/rhow[facei]); + + // For corner cells (with two boundary or more faces), + // epsilon and G in the near-wall cell are calculated + // as an average + + cellBoundaryFaceCount[faceCelli]++; + + epsilon_[faceCelli] += + Cmu75*pow(k_[faceCelli], 1.5) + /(kappa_.value()*RASModel::y_[patchi][facei]); + + if (yPlus > yPlusLam_) + { + G[faceCelli] += + (mutw[facei] + muw[facei]) + *magFaceGradU[facei] + *Cmu25*sqrt(k_[faceCelli]) + /(kappa_.value()*RASModel::y_[patchi][facei]); + } + } + } + } + + + // Perform the averaging + + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (isType(curPatch)) + { + forAll(curPatch, facei) + { + label faceCelli = curPatch.faceCells()[facei]; + + epsilon_[faceCelli] /= cellBoundaryFaceCount[faceCelli]; + G[faceCelli] /= cellBoundaryFaceCount[faceCelli]; + } + } + } +} + + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/include/wallViscosityI.H b/src/turbulenceModels/compressible/RAS/include/wallViscosityI.H new file mode 100644 index 0000000000..38992cb513 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/include/wallViscosityI.H @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + wallViscosity + +Description + Calculate wall viscosity from wall-functions. + +\*---------------------------------------------------------------------------*/ + +{ + scalar Cmu25 = pow(Cmu_.value(), 0.25); + + const fvPatchList& patches = mesh_.boundary(); + + forAll(patches, patchi) + { + const fvPatch& curPatch = patches[patchi]; + + if (isType(curPatch)) + { + const scalarField& rhow = rho_.boundaryField()[patchi]; + + const scalarField& muw = mu().boundaryField()[patchi]; + scalarField& mutw = mut_.boundaryField()[patchi]; + + forAll(curPatch, facei) + { + label faceCelli = curPatch.faceCells()[facei]; + + scalar yPlus = + Cmu25*RASModel::y_[patchi][facei] + *sqrt(k_[faceCelli])/(muw[facei]/rhow[facei]); + + if (yPlus > yPlusLam_) + { + mutw[facei] = + muw[facei] + *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1); + } + else + { + mutw[facei] = 0.0; + } + } + } + } +} + + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C b/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C new file mode 100644 index 0000000000..cb0fecc03d --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C @@ -0,0 +1,341 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kEpsilon.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +#include "backwardsCompatibilityWallFunctions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(kEpsilon, 0); +addToRunTimeSelectionTable(RASModel, kEpsilon, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +kEpsilon::kEpsilon +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.09 + ) + ), + C1_ + ( + dimensioned::lookupOrAddToDict + ( + "C1", + coeffDict_, + 1.44 + ) + ), + C2_ + ( + dimensioned::lookupOrAddToDict + ( + "C2", + coeffDict_, + 1.92 + ) + ), + C3_ + ( + dimensioned::lookupOrAddToDict + ( + "C3", + coeffDict_, + -0.33 + ) + ), + alphak_ + ( + dimensioned::lookupOrAddToDict + ( + "alphak", + coeffDict_, + 1.0 + ) + ), + alphaEps_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaEps", + coeffDict_, + 0.76923 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateK("k", mesh_) + ), + epsilon_ + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateEpsilon("epsilon", mesh_) + ), + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) + ) +{ + mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp kEpsilon::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))), + k_.boundaryField().types() + ) + ); +} + + +tmp kEpsilon::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -muEff()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp kEpsilon::divDevRhoReff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) + - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +bool kEpsilon::read() +{ + if (RASModel::read()) + { + Cmu_.readIfPresent(coeffDict_); + C1_.readIfPresent(coeffDict_); + C2_.readIfPresent(coeffDict_); + C3_.readIfPresent(coeffDict_); + alphak_.readIfPresent(coeffDict_); + alphaEps_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + + return true; + } + else + { + return false; + } +} + + +void kEpsilon::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + return; + } + + RASModel::correct(); + + volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_)); + + if (mesh_.moving()) + { + divU += fvc::div(mesh_.phi()); + } + + tmp tgradU = fvc::grad(U_); + volScalarField G("G", mut_*(tgradU() && dev(twoSymm(tgradU())))); + tgradU.clear(); + + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); + + // Dissipation equation + tmp epsEqn + ( + fvm::ddt(rho_, epsilon_) + + fvm::div(phi_, epsilon_) + - fvm::laplacian(DepsilonEff(), epsilon_) + == + C1_*G*epsilon_/k_ + - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_) + - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_) + ); + + epsEqn().relax(); + + epsEqn().boundaryManipulate(epsilon_.boundaryField()); + + solve(epsEqn); + bound(epsilon_, epsilon0_); + + + // Turbulent kinetic energy equation + + tmp kEqn + ( + fvm::ddt(rho_, k_) + + fvm::div(phi_, k_) + - fvm::laplacian(DkEff(), k_) + == + G + - fvm::SuSp((2.0/3.0)*rho_*divU, k_) + - fvm::Sp(rho_*epsilon_/k_, k_) + ); + + kEqn().relax(); + solve(kEqn); + bound(k_, k0_); + + + // Re-calculate viscosity + mut_ == rho_*Cmu_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.H b/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.H new file mode 100644 index 0000000000..76d952d40d --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::kEpsilon + +Description + Standard k-epsilon turbulence model for compressible flows + + The default model coefficients correspond to the following: + @verbatim + kEpsilonCoeffs + { + Cmu 0.09; + C1 1.44; + C2 1.92; + C3 -0.33; // only for compressible + alphak 1.0; // only for compressible + alphaEps 0.76923; + alphah 1.0; // only for compressible + } + @endverbatim + +SourceFiles + kEpsilon.C + kEpsilonCorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressiblekEpsilon_H +#define compressiblekEpsilon_H + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class kEpsilon Declaration +\*---------------------------------------------------------------------------*/ + +class kEpsilon +: + public RASModel +{ + // Private data + + // Model coefficients + + dimensionedScalar Cmu_; + dimensionedScalar C1_; + dimensionedScalar C2_; + dimensionedScalar C3_; + dimensionedScalar alphak_; + dimensionedScalar alphaEps_; + dimensionedScalar alphah_; + + // Fields + + volScalarField k_; + volScalarField epsilon_; + volScalarField mut_; + volScalarField alphat_; + + +public: + + //- Runtime type information + TypeName("kEpsilon"); + + // Constructors + + //- from components + kEpsilon + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~kEpsilon() + {} + + + // Member Functions + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", alphak_*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for epsilon + tmp DepsilonEff() const + { + return tmp + ( + new volScalarField("DepsilonEff", alphaEps_*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return epsilon_; + } + + //- Return the Reynolds stress tensor + tmp R() const; + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C new file mode 100644 index 0000000000..1181169f87 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C @@ -0,0 +1,467 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "kOmegaSST.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +#include "backwardsCompatibilityWallFunctions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(kOmegaSST, 0); +addToRunTimeSelectionTable(RASModel, kOmegaSST, dictionary); + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +tmp kOmegaSST::F1(const volScalarField& CDkOmega) const +{ + volScalarField CDkOmegaPlus = max + ( + CDkOmega, + dimensionedScalar("1.0e-10", dimless/sqr(dimTime), 1.0e-10) + ); + + volScalarField arg1 = min + ( + min + ( + max + ( + (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_), + scalar(500)*(mu()/rho_)/(sqr(y_)*omega_) + ), + (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_)) + ), + scalar(10) + ); + + return tanh(pow4(arg1)); +} + +tmp kOmegaSST::F2() const +{ + volScalarField arg2 = min + ( + max + ( + (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_), + scalar(500)*(mu()/rho_)/(sqr(y_)*omega_) + ), + scalar(100) + ); + + return tanh(sqr(arg2)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +kOmegaSST::kOmegaSST +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + alphaK1_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaK1", + coeffDict_, + 0.85034 + ) + ), + alphaK2_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaK2", + coeffDict_, + 1.0 + ) + ), + alphaOmega1_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaOmega1", + coeffDict_, + 0.5 + ) + ), + alphaOmega2_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaOmega2", + coeffDict_, + 0.85616 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + gamma1_ + ( + dimensioned::lookupOrAddToDict + ( + "gamma1", + coeffDict_, + 0.5532 + ) + ), + gamma2_ + ( + dimensioned::lookupOrAddToDict + ( + "gamma2", + coeffDict_, + 0.4403 + ) + ), + beta1_ + ( + dimensioned::lookupOrAddToDict + ( + "beta1", + coeffDict_, + 0.075 + ) + ), + beta2_ + ( + dimensioned::lookupOrAddToDict + ( + "beta2", + coeffDict_, + 0.0828 + ) + ), + betaStar_ + ( + dimensioned::lookupOrAddToDict + ( + "betaStar", + coeffDict_, + 0.09 + ) + ), + a1_ + ( + dimensioned::lookupOrAddToDict + ( + "a1", + coeffDict_, + 0.31 + ) + ), + c1_ + ( + dimensioned::lookupOrAddToDict + ( + "c1", + coeffDict_, + 10.0 + ) + ), + + omega0_("omega0", dimless/dimTime, SMALL), + omegaSmall_("omegaSmall", dimless/dimTime, SMALL), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.09 + ) + ), + + y_(mesh_), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateK("k", mesh_) + ), + omega_ + ( + IOobject + ( + "omega", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateOmega("omega", mesh_) + ), + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) + ) +{ + mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp kOmegaSST::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))), + k_.boundaryField().types() + ) + ); +} + + +tmp kOmegaSST::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -muEff()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp kOmegaSST::divDevRhoReff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +bool kOmegaSST::read() +{ + if (RASModel::read()) + { + alphaK1_.readIfPresent(coeffDict_); + alphaK2_.readIfPresent(coeffDict_); + alphaOmega1_.readIfPresent(coeffDict_); + alphaOmega2_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + gamma1_.readIfPresent(coeffDict_); + gamma2_.readIfPresent(coeffDict_); + beta1_.readIfPresent(coeffDict_); + beta2_.readIfPresent(coeffDict_); + betaStar_.readIfPresent(coeffDict_); + a1_.readIfPresent(coeffDict_); + c1_.readIfPresent(coeffDict_); + Cmu_.readIfPresent(coeffDict_); + + return true; + } + else + { + return false; + } +} + + +void kOmegaSST::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ == + a1_*rho_*k_ + /max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + return; + } + + RASModel::correct(); + + volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_)); + + if (mesh_.changing()) + { + y_.correct(); + } + + if (mesh_.moving()) + { + divU += fvc::div(mesh_.phi()); + } + + tmp tgradU = fvc::grad(U_); + volScalarField S2 = magSqr(symm(tgradU())); + volScalarField GbyMu = (tgradU() && dev(twoSymm(tgradU()))); + volScalarField G("G", mut_*GbyMu); + tgradU.clear(); + + // Update omega and G at the wall + omega_.boundaryField().updateCoeffs(); + + volScalarField CDkOmega = + (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_; + + volScalarField F1 = this->F1(CDkOmega); + volScalarField rhoGammaF1 = rho_*gamma(F1); + + // Turbulent frequency equation + tmp omegaEqn + ( + fvm::ddt(rho_, omega_) + + fvm::div(phi_, omega_) + - fvm::laplacian(DomegaEff(F1), omega_) + == + rhoGammaF1*GbyMu + - fvm::SuSp((2.0/3.0)*rhoGammaF1*divU, omega_) + - fvm::Sp(rho_*beta(F1)*omega_, omega_) + - fvm::SuSp + ( + rho_*(F1 - scalar(1))*CDkOmega/omega_, + omega_ + ) + ); + + omegaEqn().relax(); + + omegaEqn().boundaryManipulate(omega_.boundaryField()); + + solve(omegaEqn); + bound(omega_, omega0_); + + // Turbulent kinetic energy equation + tmp kEqn + ( + fvm::ddt(rho_, k_) + + fvm::div(phi_, k_) + - fvm::laplacian(DkEff(F1), k_) + == + min(G, (c1_*betaStar_)*rho_*k_*omega_) + - fvm::SuSp(2.0/3.0*rho_*divU, k_) + - fvm::Sp(rho_*betaStar_*omega_, k_) + ); + + kEqn().relax(); + solve(kEqn); + bound(k_, k0_); + + + // Re-calculate viscosity + mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2)); + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H new file mode 100644 index 0000000000..3f9c1486d3 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H @@ -0,0 +1,303 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::kOmegaSST + +Description + Implementation of the k-omega-SST turbulence model for compressible flows. + + Turbulence model described in: + @verbatim + Menter, F., Esch, T. + "Elements of Industrial Heat Transfer Prediction" + 16th Brazilian Congress of Mechanical Engineering (COBEM), + Nov. 2001 + @endverbatim + + Note that this implementation is written in terms of alpha diffusion + coefficients rather than the more traditional sigma (alpha = 1/sigma) so + that the blending can be applied to all coefficuients in a consistent + manner. The paper suggests that sigma is blended but this would not be + consistent with the blending of the k-epsilon and k-omega models. + + Also note that the error in the last term of equation (2) relating to + sigma has been corrected. + + Wall-functions are applied in this implementation by using equations (14) + to specify the near-wall omega as appropriate. + + The blending functions (15) and (16) are not currently used because of the + uncertainty in their origin, range of applicability and that is y+ becomes + sufficiently small blending u_tau in this manner clearly becomes nonsense. + + The default model coefficients correspond to the following: + @verbatim + kOmegaSST + { + Cmu 0.09; + alphaK1 0.85034; + alphaK2 1.0; + alphaOmega1 0.5; + alphaOmega2 0.85616; + alphah 1.0; // only for compressible + beta1 0.075; + beta2 0.0828; + betaStar 0.09; + gamma1 0.5532; + gamma2 0.4403; + a1 0.31; + c1 10.0; + } + @endverbatim + +SourceFiles + kOmegaSST.C + kOmegaWallFunctionsI.H + kOmegaWallViscosityI.H + wallOmegaI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef compressiblekOmegaSST_H +#define compressiblekOmegaSST_H + +#include "RASModel.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class kOmega Declaration +\*---------------------------------------------------------------------------*/ + +class kOmegaSST +: + public RASModel +{ + // Private data + + dimensionedScalar alphaK1_; + dimensionedScalar alphaK2_; + + dimensionedScalar alphaOmega1_; + dimensionedScalar alphaOmega2_; + + dimensionedScalar alphah_; + + dimensionedScalar gamma1_; + dimensionedScalar gamma2_; + + dimensionedScalar beta1_; + dimensionedScalar beta2_; + + dimensionedScalar betaStar_; + + dimensionedScalar a1_; + dimensionedScalar c1_; + + dimensionedScalar omega0_; + dimensionedScalar omegaSmall_; + + dimensionedScalar Cmu_; + + wallDist y_; + + volScalarField k_; + volScalarField omega_; + volScalarField mut_; + volScalarField alphat_; + + + // Private member functions + + tmp F1(const volScalarField& CDkOmega) const; + tmp F2() const; + + tmp blend + ( + const volScalarField& F1, + const dimensionedScalar& psi1, + const dimensionedScalar& psi2 + ) const + { + return F1*(psi1 - psi2) + psi2; + } + + tmp alphaK + ( + const volScalarField& F1 + ) const + { + return blend(F1, alphaK1_, alphaK2_); + } + + tmp alphaOmega + ( + const volScalarField& F1 + ) const + { + return blend(F1, alphaOmega1_, alphaOmega2_); + } + + tmp beta + ( + const volScalarField& F1 + ) const + { + return blend(F1, beta1_, beta2_); + } + + tmp gamma + ( + const volScalarField& F1 + ) const + { + return blend(F1, gamma1_, gamma2_); + } + + +public: + + //- Runtime type information + TypeName("kOmegaSST"); + + + // Constructors + + //- Construct from components + kOmegaSST + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~kOmegaSST() + {} + + + // Member Functions + + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for k + tmp DkEff(const volScalarField& F1) const + { + return tmp + ( + new volScalarField("DkEff", alphaK(F1)*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for omega + tmp DomegaEff(const volScalarField& F1) const + { + return tmp + ( + new volScalarField("DomegaEff", alphaOmega(F1)*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + tmp omega() const + { + return omega_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + mesh_.time().timeName(), + mesh_ + ), + betaStar_*k_*omega_, + omega_.boundaryField().types() + ) + ); + } + + //- Return the Reynolds stress tensor + tmp R() const; + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/laminar/laminar.C b/src/turbulenceModels/compressible/RAS/laminar/laminar.C new file mode 100644 index 0000000000..7a24cacc7a --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/laminar/laminar.C @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "laminar.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(laminar, 0); +addToRunTimeSelectionTable(RASModel, laminar, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +laminar::laminar +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp laminar::mut() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("mut", mu().dimensions(), 0.0) + ) + ); +} + + +tmp laminar::k() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("k", sqr(U_.dimensions()), 0.0) + ) + ); +} + + +tmp laminar::epsilon() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar + ( + "epsilon", sqr(U_.dimensions())/dimTime, 0.0 + ) + ) + ); +} + + +tmp laminar::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedSymmTensor + ( + "R", sqr(U_.dimensions()), symmTensor::zero + ) + ) + ); +} + + +tmp laminar::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -mu()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp laminar::divDevRhoReff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +bool laminar::read() +{ + return RASModel::read(); +} + + +void laminar::correct() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/laminar/laminar.H b/src/turbulenceModels/compressible/RAS/laminar/laminar.H new file mode 100644 index 0000000000..dda7f73117 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/laminar/laminar.H @@ -0,0 +1,135 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::laminar + +Description + Dummy turbulence model for laminar compressible flow. + +SourceFiles + laminar.C + laminarCorrect.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibleLaminar_H +#define compressibleLaminar_H + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class laminar Declaration +\*---------------------------------------------------------------------------*/ + +class laminar +: + public RASModel +{ + +public: + + //- Runtime type information + TypeName("laminar"); + + // Constructors + + //- from components + laminar + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~laminar() + {} + + + // Member Functions + + //- Return the turbulence viscosity, i.e. 0 for laminar flow + tmp mut() const; + + //- Return the effective viscosity, i.e. the laminar viscosity + tmp muEff() const + { + return tmp(new volScalarField("muEff", mu())); + } + + //- Return the effective turbulent thermal diffusivity, + // i.e. the laminar thermal diffusivity + tmp alphaEff() const + { + return tmp(new volScalarField("alphaEff", alpha())); + } + + //- Return the turbulence kinetic energy, i.e. 0 for laminar flow + tmp k() const; + + //- Return the turbulence kinetic energy dissipation rate, + // i.e. 0 for laminar flow + tmp epsilon() const; + + //- Return the Reynolds stress tensor, i.e. 0 for laminar flow + tmp R() const; + + //- Return the effective stress tensor, i.e. the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Correct the laminar viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C b/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C new file mode 100644 index 0000000000..1e762433f3 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C @@ -0,0 +1,380 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "realizableKE.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +#include "backwardsCompatibilityWallFunctions.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(realizableKE, 0); +addToRunTimeSelectionTable(RASModel, realizableKE, dictionary); + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +tmp realizableKE::rCmu +( + const volTensorField& gradU, + const volScalarField& S2, + const volScalarField& magS +) +{ + tmp tS = dev(symm(gradU)); + const volSymmTensorField& S = tS(); + + volScalarField W = + (2*sqrt(2.0))*((S&S)&&S) + /( + magS*S2 + + dimensionedScalar("small", dimensionSet(0, 0, -3, 0, 0), SMALL) + ); + + tS.clear(); + + volScalarField phis = + (1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1))); + volScalarField As = sqrt(6.0)*cos(phis); + volScalarField Us = sqrt(S2/2.0 + magSqr(skew(gradU))); + + return 1.0/(A0_ + As*Us*k_/(epsilon_ + epsilonSmall_)); +} + + +tmp realizableKE::rCmu +( + const volTensorField& gradU +) +{ + volScalarField S2 = 2*magSqr(dev(symm(gradU))); + volScalarField magS = sqrt(S2); + return rCmu(gradU, S2, magS); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +realizableKE::realizableKE +( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel +) +: + RASModel(typeName, rho, U, phi, thermophysicalModel), + + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + coeffDict_, + 0.09 + ) + ), + A0_ + ( + dimensioned::lookupOrAddToDict + ( + "A0", + coeffDict_, + 4.0 + ) + ), + C2_ + ( + dimensioned::lookupOrAddToDict + ( + "C2", + coeffDict_, + 1.9 + ) + ), + alphak_ + ( + dimensioned::lookupOrAddToDict + ( + "alphak", + coeffDict_, + 1.0 + ) + ), + alphaEps_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaEps", + coeffDict_, + 0.833333 + ) + ), + alphah_ + ( + dimensioned::lookupOrAddToDict + ( + "alphah", + coeffDict_, + 1.0 + ) + ), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateK("k", mesh_) + ), + epsilon_ + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateEpsilon("epsilon", mesh_) + ), + mut_ + ( + IOobject + ( + "mut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) + ) +{ + bound(k_, k0_); + bound(epsilon_, epsilon0_); + + mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp realizableKE::R() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "R", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))), + k_.boundaryField().types() + ) + ); +} + + +tmp realizableKE::devRhoReff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + -muEff()*dev(twoSymm(fvc::grad(U_))) + ) + ); +} + + +tmp realizableKE::divDevRhoReff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T())) + ); +} + + +bool realizableKE::read() +{ + if (RASModel::read()) + { + Cmu_.readIfPresent(coeffDict_); + A0_.readIfPresent(coeffDict_); + C2_.readIfPresent(coeffDict_); + alphak_.readIfPresent(coeffDict_); + alphaEps_.readIfPresent(coeffDict_); + alphah_.readIfPresent(coeffDict_); + + return true; + } + else + { + return false; + } +} + + +void realizableKE::correct() +{ + if (!turbulence_) + { + // Re-calculate viscosity + mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + + return; + } + + RASModel::correct(); + + volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_)); + + if (mesh_.moving()) + { + divU += fvc::div(mesh_.phi()); + } + + volTensorField gradU = fvc::grad(U_); + volScalarField S2 = 2*magSqr(dev(symm(gradU))); + volScalarField magS = sqrt(S2); + + volScalarField eta = magS*k_/epsilon_; + volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43)); + + volScalarField G("G", mut_*(gradU && dev(twoSymm(gradU)))); + + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); + + // Dissipation equation + tmp epsEqn + ( + fvm::ddt(rho_, epsilon_) + + fvm::div(phi_, epsilon_) + - fvm::laplacian(DepsilonEff(), epsilon_) + == + C1*rho_*magS*epsilon_ + - fvm::Sp + ( + C2_*rho_*epsilon_/(k_ + sqrt((mu()/rho_)*epsilon_)), + epsilon_ + ) + ); + + epsEqn().relax(); + + epsEqn().boundaryManipulate(epsilon_.boundaryField()); + + solve(epsEqn); + bound(epsilon_, epsilon0_); + + + // Turbulent kinetic energy equation + + tmp kEqn + ( + fvm::ddt(rho_, k_) + + fvm::div(phi_, k_) + - fvm::laplacian(DkEff(), k_) + == + G - fvm::SuSp(2.0/3.0*rho_*divU, k_) + - fvm::Sp(rho_*(epsilon_)/k_, k_) + ); + + kEqn().relax(); + solve(kEqn); + bound(k_, k0_); + + // Re-calculate viscosity + mut_ == rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.H b/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.H new file mode 100644 index 0000000000..f997efdd5f --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.H @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::realizableKE + +Description + Realizable k-epsilon turbulence model for compressible flows. + + Model described in the paper: + @verbatim + "A New k-epsilon Eddy Viscosity Model for High Reynolds Number + Turbulent Flows" + + Tsan-Hsing Shih, William W. Liou, Aamir Shabbir, Zhigang Tang and + Jiang Zhu + + Computers and Fluids Vol. 24, No. 3, pp. 227-238, 1995 + @endverbatim + + The default model coefficients correspond to the following: + @verbatim + realizableKE + { + Cmu 0.09; + A0 4.0; + C2 1.9; + alphak 1.0; + alphaEps 0.833333; + alphah 1.0; // only for compressible + } + @endverbatim + +SourceFiles + realizableKE.C + +\*---------------------------------------------------------------------------*/ + +#ifndef realizableKE_H +#define realizableKE_H + +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class realizableKE Declaration +\*---------------------------------------------------------------------------*/ + +class realizableKE +: + public RASModel +{ + // Private data + + dimensionedScalar Cmu_; + dimensionedScalar A0_; + dimensionedScalar C2_; + dimensionedScalar alphak_; + dimensionedScalar alphaEps_; + dimensionedScalar alphah_; + + volScalarField k_; + volScalarField epsilon_; + volScalarField mut_; + volScalarField alphat_; + + tmp rCmu + ( + const volTensorField& gradU, + const volScalarField& S2, + const volScalarField& magS + ); + + tmp rCmu + ( + const volTensorField& gradU + ); + +public: + + //- Runtime type information + TypeName("realizableKE"); + + // Constructors + + //- from components + realizableKE + ( + const volScalarField& rho, + const volVectorField& U, + const surfaceScalarField& phi, + basicThermo& thermophysicalModel + ); + + + // Destructor + + ~realizableKE(){} + + + // Member Functions + + //- Return the turbulence viscosity + tmp mut() const + { + return mut_; + } + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", alphak_*mut_ + mu()) + ); + } + + //- Return the effective diffusivity for epsilon + tmp DepsilonEff() const + { + return tmp + ( + new volScalarField("DepsilonEff", alphaEps_*mut_ + mu()) + ); + } + + //- Return the effective turbulent thermal diffusivity + tmp alphaEff() const + { + return tmp + ( + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) + ); + } + + //- Return the turbulence kinetic energy + tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + tmp epsilon() const + { + return epsilon_; + } + + //- Return the Reynolds stress tensor + tmp R() const; + + //- Return the effective stress tensor including the laminar stress + tmp devRhoReff() const; + + //- Return the source term for the momentum equation + tmp divDevRhoReff(volVectorField& U) const; + + //- Solve the turbulence equations and correct the turbulence viscosity + void correct(); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/Allwmake b/src/turbulenceModels/incompressible/Allwmake new file mode 100755 index 0000000000..ddff417018 --- /dev/null +++ b/src/turbulenceModels/incompressible/Allwmake @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wmake libso turbulenceModel +wmake libso RAS +wmake libso LES + +# ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/incompressible/LES/DeardorffDiffStress/DeardorffDiffStress.C b/src/turbulenceModels/incompressible/LES/DeardorffDiffStress/DeardorffDiffStress.C new file mode 100644 index 0000000000..aa7e5b7cc6 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/DeardorffDiffStress/DeardorffDiffStress.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "DeardorffDiffStress.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(DeardorffDiffStress, 0); +addToRunTimeSelectionTable(LESModel, DeardorffDiffStress, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +DeardorffDiffStress::DeardorffDiffStress +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESModel(typeName, U, phi, transport), + GenSGSStress(U, phi, transport), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.094 + ) + ), + cm_ + ( + dimensioned::lookupOrAddToDict + ( + "cm", + coeffDict(), + 4.13 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void DeardorffDiffStress::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + + GenSGSStress::correct(gradU); + + volSymmTensorField D = symm(gradU); + + volSymmTensorField P = -twoSymm(B_ & gradU); + + volScalarField K = 0.5*tr(B_); + volScalarField Epsilon = 2*nuEff()*magSqr(D); + + fvSymmTensorMatrix BEqn + ( + fvm::ddt(B_) + + fvm::div(phi(), B_) + - fvm::laplacian(DBEff(), B_) + + fvm::Sp(cm_*sqrt(K)/delta(), B_) + == + P + + 0.8*K*D + - (2*ce_ - 0.667*cm_)*I*Epsilon + ); + + BEqn.relax(); + BEqn.solve(); + + // Bounding the component kinetic energies + + forAll(B_, celli) + { + B_[celli].component(symmTensor::XX) = + max(B_[celli].component(symmTensor::XX), k0().value()); + B_[celli].component(symmTensor::YY) = + max(B_[celli].component(symmTensor::YY), k0().value()); + B_[celli].component(symmTensor::ZZ) = + max(B_[celli].component(symmTensor::ZZ), k0().value()); + } + + K = 0.5*tr(B_); + bound(K, k0()); + + nuSgs_ = ck_*sqrt(K)*delta(); + nuSgs_.correctBoundaryConditions(); +} + + +bool DeardorffDiffStress::read() +{ + if (GenSGSStress::read()) + { + ck_.readIfPresent(coeffDict()); + cm_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/DeardorffDiffStress/DeardorffDiffStress.H b/src/turbulenceModels/incompressible/LES/DeardorffDiffStress/DeardorffDiffStress.H new file mode 100644 index 0000000000..713189bbdd --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/DeardorffDiffStress/DeardorffDiffStress.H @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::LESModels::DeardorffDiffStress + +Description + Differential SGS Stress Equation Model for incompressible flows + + The DSEM uses a model version of the full balance equation for the SGS + stress tensor to simulate the behaviour of B. + Thus, + @verbatim + d/dt(B) + div(U*B) - div(nuSgs*grad(B)) + = + P - c1*epsilon/k*B - 0.667*(1 - c1)*epsilon*I - c2*(P - 0.333*trP*I) + + where + + k = 0.5*tr(B), + epsilon = ce*k^3/2/delta, + epsilon/k = ce*k^1/2/delta + P = -(B'L + L'B) + nuSgs = ck*sqrt(k)*delta + nuEff = nuSgs + nu + @endverbatim + +SourceFiles + DeardorffDiffStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef DeardorffDiffStress_H +#define DeardorffDiffStress_H + +#include "GenSGSStress.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class DeardorffDiffStress Declaration +\*---------------------------------------------------------------------------*/ + +class DeardorffDiffStress +: + public GenSGSStress +{ + // Private data + + dimensionedScalar ck_; + dimensionedScalar cm_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + DeardorffDiffStress(const DeardorffDiffStress&); + DeardorffDiffStress& operator=(const DeardorffDiffStress&); + + +public: + + //- Runtime type information + TypeName("DeardorffDiffStress"); + + // Constructors + + //- Construct from components + DeardorffDiffStress + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~DeardorffDiffStress() + {} + + + // Member Functions + + //- Return the effective diffusivity for B + tmp DBEff() const + { + return tmp + ( + new volScalarField("DBEff", nuSgs_ + nu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.C b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.C new file mode 100644 index 0000000000..7cf9d6a2f3 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.C @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +GenEddyVisc::GenEddyVisc +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESModel(word("GenEddyVisc"), U, phi, transport), + + ce_ + ( + dimensioned::lookupOrAddToDict + ( + "ce", + coeffDict(), + 1.048 + ) + ), + + nuSgs_ + ( + IOobject + ( + "nuSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) +{ +// printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp GenEddyVisc::B() const +{ + return ((2.0/3.0)*I)*k() - nuSgs_*twoSymm(fvc::grad(U())); +} + + +tmp GenEddyVisc::devBeff() const +{ + return -nuEff()*dev(twoSymm(fvc::grad(U()))); +} + + +tmp GenEddyVisc::divDevBeff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(nuEff(), U) - fvc::div(nuEff()*dev(fvc::grad(U)().T())) + ); +} + + +void GenEddyVisc::correct(const tmp& gradU) +{ + LESModel::correct(gradU); +} + + +bool GenEddyVisc::read() +{ + if (LESModel::read()) + { + ce_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H new file mode 100644 index 0000000000..5c16c96147 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::LESModels::GenEddyVisc + +Description + General base class for all incompressible models that can be implemented + as an eddy viscosity, i.e. algebraic and one-equation models. + + Contains fields for k (SGS turbulent kinetic energy), gamma + (modelled viscosity) and epsilon (SGS dissipation). + +SourceFiles + GenEddyVisc.C + +\*---------------------------------------------------------------------------*/ + +#ifndef GenEddyVisc_H +#define GenEddyVisc_H + +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class GenEddyVisc Declaration +\*---------------------------------------------------------------------------*/ + +class GenEddyVisc +: + virtual public LESModel +{ + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + GenEddyVisc(const GenEddyVisc&); + GenEddyVisc& operator=(const GenEddyVisc&); + + +protected: + + dimensionedScalar ce_; + + volScalarField nuSgs_; + + +public: + + // Constructors + + //- Construct from components + GenEddyVisc + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~GenEddyVisc() + {} + + + // Member Functions + + //- Return SGS kinetic energy + virtual tmp k() const = 0; + + //- Return sub-grid disipation rate + virtual tmp epsilon() const + { + return ce_*k()*sqrt(k())/delta(); + } + + //- Return the SGS viscosity. + virtual tmp nuSgs() const + { + return nuSgs_; + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const; + + //- Return the effective sub-grid turbulence stress tensor + // including the laminar stress + virtual tmp devBeff() const; + + //- Return the deviatoric part of the effective sub-grid + // turbulence stress tensor including the laminar stress + virtual tmp divDevBeff(volVectorField& U) const; + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.C b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.C new file mode 100644 index 0000000000..469bb17b43 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.C @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "GenSGSStress.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +GenSGSStress::GenSGSStress +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESModel(word("GenSGSStress"), U, phi, transport), + + ce_ + ( + dimensioned::lookupOrAddToDict + ( + "ce", + coeffDict(), + 1.048 + ) + ), + + couplingFactor_ + ( + dimensioned::lookupOrAddToDict + ( + "couplingFactor", + coeffDict(), + 0.0 + ) + ), + + B_ + ( + IOobject + ( + "B", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + nuSgs_ + ( + IOobject + ( + "nuSgs", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + nu(), + B_.boundaryField().types() + ) +{ + if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) + { + FatalErrorIn + ( + "GenSGSStress::GenSGSStress" + "(const volVectorField& U, const surfaceScalarField& phi," + "transportModel& lamTransportModel)" + ) << "couplingFactor = " << couplingFactor_ + << " is not in range 0 - 1" << nl + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp GenSGSStress::devBeff() const +{ + return tmp + ( + new volSymmTensorField + ( + IOobject + ( + "devRhoReff", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + B_ - nu()*dev(twoSymm(fvc::grad(U()))) + ) + ); +} + + +tmp GenSGSStress::divDevBeff +( + volVectorField& U +) const +{ + if (couplingFactor_.value() > 0.0) + { + return + ( + fvc::div(B_ + couplingFactor_*nuSgs_*fvc::grad(U)) + + fvc::laplacian + ( + (1.0 - couplingFactor_)*nuSgs_, U, "laplacian(nuEff,U)" + ) + - fvm::laplacian(nuEff(), U) + ); + } + else + { + return + ( + fvc::div(B_) + + fvc::laplacian(nuSgs_, U, "laplacian(nuEff,U)") + - fvm::laplacian(nuEff(), U) + ); + } +} + + +bool GenSGSStress::read() +{ + if (LESModel::read()) + { + ce_.readIfPresent(coeffDict()); + + couplingFactor_.readIfPresent(coeffDict()); + + if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) + { + FatalErrorIn("GenSGSStress::read()") + << "couplingFactor = " << couplingFactor_ + << " is not in range 0 - 1" + << exit(FatalError); + } + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H new file mode 100644 index 0000000000..38073d08b6 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::LESModels::GenSGSStress + +Description + General base class for all incompressible models that directly + solve for the SGS stress tensor B. + + Contains tensor fields B (the SGS stress tensor) as well as scalar + fields for k (SGS turbulent energy) gamma (SGS viscosity) and epsilon + (SGS dissipation). + +SourceFiles + GenSGSStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef GenSGSStress_H +#define GenSGSStress_H + +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class GenSGSStress Declaration +\*---------------------------------------------------------------------------*/ + +class GenSGSStress +: + virtual public LESModel +{ + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + GenSGSStress(const GenSGSStress&); + GenSGSStress& operator=(const GenSGSStress&); + + +protected: + + dimensionedScalar ce_; + + dimensionedScalar couplingFactor_; + + volSymmTensorField B_; + volScalarField nuSgs_; + + +public: + + // Constructors + + //- Construct from components + GenSGSStress + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~GenSGSStress() + {} + + + // Member Functions + + //- Return the SGS turbulent kinetic energy. + virtual tmp k() const + { + return 0.5*tr(B_); + } + + //- Return the SGS turbulent dissipation. + virtual tmp epsilon() const + { + volScalarField K = k(); + return ce_*K*sqrt(K)/delta(); + } + + //- Return the SGS viscosity. + virtual tmp nuSgs() const + { + return nuSgs_; + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const + { + return B_; + } + + //- Return the effective sub-grid turbulence stress tensor + // including the laminar stress + virtual tmp devBeff() const; + + //- Returns div(B). + // This is the additional term due to the filtering of the NSE. + virtual tmp divDevBeff(volVectorField& U) const; + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/LESModel/LESModel.C b/src/turbulenceModels/incompressible/LES/LESModel/LESModel.C new file mode 100644 index 0000000000..e55a55b47e --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/LESModel/LESModel.C @@ -0,0 +1,186 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LESModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(LESModel, 0); +defineRunTimeSelectionTable(LESModel, dictionary); +addToRunTimeSelectionTable(turbulenceModel, LESModel, turbulenceModel); + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void LESModel::printCoeffs() +{ + if (printCoeffs_) + { + Info<< type() << "Coeffs" << coeffDict_ << endl; + } +} + + +// * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * // + +LESModel::LESModel +( + const word& type, + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& lamTransportModel +) +: + turbulenceModel(U, phi, lamTransportModel), + + IOdictionary + ( + IOobject + ( + "LESProperties", + U.time().constant(), + U.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + + turbulence_(lookup("turbulence")), + printCoeffs_(lookupOrDefault("printCoeffs", false)), + coeffDict_(subDict(type + "Coeffs")), + + k0_("k0", dimVelocity*dimVelocity, SMALL), + delta_(LESdelta::New("delta", U.mesh(), *this)) +{ + readIfPresent("k0", k0_); +} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +autoPtr LESModel::New +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +{ + word LESModelTypeName; + + // Enclose the creation of the turbulencePropertiesDict to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary turbulencePropertiesDict + ( + IOobject + ( + "LESProperties", + U.time().constant(), + U.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + turbulencePropertiesDict.lookup("LESModel") >> LESModelTypeName; + } + + Info<< "Selecting LES turbulence model " << LESModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(LESModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "LESModel::select(const volVectorField&, const " + "surfaceScalarField&, transportModel&)" + ) << "Unknown LESModel type " << LESModelTypeName + << endl << endl + << "Valid LESModel types are :" << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(U, phi, transport)); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +LESModel::~LESModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void LESModel::correct(const tmp&) +{ + turbulenceModel::correct(); + delta_().correct(); +} + + +void LESModel::correct() +{ + correct(fvc::grad(U_)); +} + + +bool LESModel::read() +{ + if (regIOobject::read()) + { + coeffDict_ = subDict(type() + "Coeffs"); + + delta_().read(*this); + + readIfPresent("k0", k0_); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H b/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H new file mode 100644 index 0000000000..776328d3a2 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H @@ -0,0 +1,277 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::incompressible::LESModels + +Description + Namespace for incompressible LES models. + +Class + Foam::incompressible::LESModel + +Description + Base class for all incompressible flow LES SGS models. + + This class defines the basic interface for an incompressible flow SGS + model, and encapsulates data of value to all possible models. In + particular this includes references to all the dependent fields (U, + phi), the physical viscosity nu, and the turbulenceProperties + dictionary which contains the model selection and model coefficients. + +SourceFiles + LESModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef LESModel_H +#define LESModel_H + +#include "turbulenceModel.H" +#include "LESdelta.H" +#include "fvm.H" +#include "fvc.H" +#include "fvMatrices.H" +#include "incompressible/transportModel/transportModel.H" +#include "wallFvPatch.H" +#include "bound.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +/*---------------------------------------------------------------------------*\ + Class LESModel Declaration +\*---------------------------------------------------------------------------*/ + +class LESModel +: + public turbulenceModel, + public IOdictionary +{ + +protected: + + // Protected data + + Switch turbulence_; + Switch printCoeffs_; + dictionary coeffDict_; + + dimensionedScalar k0_; + + autoPtr delta_; + + + // Protected member functions + + //- Print model coefficients + virtual void printCoeffs(); + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + LESModel(const LESModel&); + + //- Disallow default bitwise assignment + LESModel& operator=(const LESModel&); + + +public: + + //- Runtime type information + TypeName("LESModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + LESModel, + dictionary, + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& lamTransportModel + ), + (U, phi, lamTransportModel) + ); + + + // Constructors + + //- Construct from components + LESModel + ( + const word& type, + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& lamTransportModel + ); + + + // Selectors + + //- Return a reference to the selected LES model + static autoPtr New + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& lamTransportModel + ); + + + //- Destructor + virtual ~LESModel(); + + + // Member Functions + + //- Access function to velocity field + inline const volVectorField& U() const + { + return U_; + } + + //- Access function to flux field + inline const surfaceScalarField& phi() const + { + return phi_; + } + + //- Access the dictionary which provides info. about choice of + // models, and all related data (particularly model coefficients). + inline dictionary& coeffDict() + { + return coeffDict_; + } + + //- Access function to filter width + inline const volScalarField& delta() const + { + return delta_(); + } + + //- Return the value of k0 which k is not allowed to be less than + const dimensionedScalar& k0() const + { + return k0_; + } + + //- Allow k0 to be changed + dimensionedScalar& k0() + { + return k0_; + } + + + //- Return the SGS turbulent kinetic energy. + virtual tmp k() const = 0; + + //- Return the SGS turbulent dissipation. + virtual tmp epsilon() const = 0; + + //- Return the SGS viscosity. + virtual tmp nuSgs() const = 0; + + //- Return the effective viscosity + virtual tmp nuEff() const + { + return tmp + ( + new volScalarField("nuEff", nuSgs() + nu()) + ); + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const = 0; + + //- Return the deviatoric part of the effective sub-grid + // turbulence stress tensor including the laminar stress + virtual tmp devBeff() const = 0; + + //- Returns div(dev(Beff)). + // This is the additional term due to the filtering of the NSE. + virtual tmp divDevBeff(volVectorField& U) const = 0; + + + // RAS compatibility functions for the turbulenceModel base class + + //- Return the turbulence viscosity + virtual tmp nut() const + { + return nuSgs(); + } + + //- Return the Reynolds stress tensor + virtual tmp R() const + { + return B(); + } + + //- Return the effective stress tensor including the laminar stress + virtual tmp devReff() const + { + return devBeff(); + } + + //- Return the source term for the momentum equation + virtual tmp divDevReff(volVectorField& U) const + { + return divDevBeff(U); + } + + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Correct Eddy-Viscosity and related properties. + // This calls correct(const tmp& gradU) by supplying + // gradU calculated locally. + void correct(); + + //- Read turbulenceProperties dictionary + virtual bool read() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/LRRDiffStress/LRRDiffStress.C b/src/turbulenceModels/incompressible/LES/LRRDiffStress/LRRDiffStress.C new file mode 100644 index 0000000000..f6aa1f536e --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/LRRDiffStress/LRRDiffStress.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LRRDiffStress.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(LRRDiffStress, 0); +addToRunTimeSelectionTable(LESModel, LRRDiffStress, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +LRRDiffStress::LRRDiffStress +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESModel(typeName, U, phi, transport), + GenSGSStress(U, phi, transport), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.09 + ) + ), + c1_ + ( + dimensioned::lookupOrAddToDict + ( + "c1", + coeffDict(), + 1.8 + ) + ), + c2_ + ( + dimensioned::lookupOrAddToDict + ( + "c2", + coeffDict(), + 0.6 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void LRRDiffStress::correct(const tmp& tgradU) +{ + const volTensorField& gradU = tgradU(); + + GenSGSStress::correct(gradU); + + volSymmTensorField D = symm(gradU); + + volSymmTensorField P = -twoSymm(B_ & gradU); + + volScalarField K = 0.5*tr(B_); + volScalarField Epsilon = 2*nuEff()*magSqr(D); + + fvSymmTensorMatrix BEqn + ( + fvm::ddt(B_) + + fvm::div(phi(), B_) + - fvm::laplacian(DBEff(), B_) + + fvm::Sp(c1_*Epsilon/K, B_) + == + P + - (0.667*(1.0 - c1_)*I)*Epsilon + - c2_*(P - 0.333*I*tr(P)) + - (0.667 - 2*c1_)*I*pow(K, 1.5)/delta() + ); + + BEqn.relax(); + BEqn.solve(); + + // Bounding the component kinetic energies + + forAll(B_, celli) + { + B_[celli].component(symmTensor::XX) = + max(B_[celli].component(symmTensor::XX), k0().value()); + B_[celli].component(symmTensor::YY) = + max(B_[celli].component(symmTensor::YY), k0().value()); + B_[celli].component(symmTensor::ZZ) = + max(B_[celli].component(symmTensor::ZZ), k0().value()); + } + + K = 0.5*tr(B_); + bound(K, k0()); + + nuSgs_ = ck_*sqrt(K)*delta(); + nuSgs_.correctBoundaryConditions(); +} + + +bool LRRDiffStress::read() +{ + if (GenSGSStress::read()) + { + ck_.readIfPresent(coeffDict()); + c1_.readIfPresent(coeffDict()); + c2_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/LRRDiffStress/LRRDiffStress.H b/src/turbulenceModels/incompressible/LES/LRRDiffStress/LRRDiffStress.H new file mode 100644 index 0000000000..a61ea1a49a --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/LRRDiffStress/LRRDiffStress.H @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::LESModels::LRRDiffStress + +Description + Differential SGS Stress Equation Model for incompressible flows. + + The DSEM uses a model version of the full balance equation for the SGS + stress tensor to simulate the behaviour of B, hence, + @verbatim + d/dt(B) + div(U*B) - div(nuSgs*grad(B)) + = + P - c1*e/k*B - 0.667*(1 - c1)*e*I - c2*(P - 0.333*trP*I) + where + k = 0.5*trB, + epsilon = ce*k^3/2/delta + epsilon/k = ce*k^1/2/delta + P = -(B'L + L'B) + nuEff = ck*sqrt(k)*delta + nu + @endverbatim + + This version from Launder, Rece & Rodi 1975 + +SourceFiles + LRRDiffStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef LRRDiffStress_H +#define LRRDiffStress_H + +#include "GenSGSStress.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class LRRDiffStress Declaration +\*---------------------------------------------------------------------------*/ + +class LRRDiffStress +: + public GenSGSStress +{ + // Private data + + dimensionedScalar ck_; + dimensionedScalar c1_; + dimensionedScalar c2_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + LRRDiffStress(const LRRDiffStress&); + LRRDiffStress& operator=(const LRRDiffStress&); + + +public: + + //- Runtime type information + TypeName("LRRDiffStress"); + + // Constructors + + //- Construct from components + LRRDiffStress + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~LRRDiffStress() + {} + + + // Member Functions + + //- Return the effective diffusivity for B + tmp DBEff() const + { + return tmp + ( + new volScalarField("DBEff", nuSgs_ + nu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/Make/files b/src/turbulenceModels/incompressible/LES/Make/files new file mode 100644 index 0000000000..bd97e2c1ec --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/Make/files @@ -0,0 +1,38 @@ +vanDriestDelta/vanDriestDelta.C + +LESModel/LESModel.C + +GenEddyVisc/GenEddyVisc.C +GenSGSStress/GenSGSStress.C + +laminar/laminar.C +SpalartAllmaras/SpalartAllmaras.C +SpalartAllmarasDDES/SpalartAllmarasDDES.C +SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C + +oneEqEddy/oneEqEddy.C +dynOneEqEddy/dynOneEqEddy.C +locDynOneEqEddy/locDynOneEqEddy.C +Smagorinsky/Smagorinsky.C +dynSmagorinsky/dynSmagorinsky.C +LRRDiffStress/LRRDiffStress.C +DeardorffDiffStress/DeardorffDiffStress.C +spectEddyVisc/spectEddyVisc.C + +scaleSimilarity/scaleSimilarity.C +mixedSmagorinsky/mixedSmagorinsky.C +dynMixedSmagorinsky/dynMixedSmagorinsky.C + +/*Smagorinsky2/Smagorinsky2.C*/ + +kOmegaSSTSAS/kOmegaSSTSAS.C + +/* Wall functions */ +wallFunctions=derivedFvPatchFields/wallFunctions + +nuSgsWallFunctions=$(wallFunctions)/nuSgsWallFunctions +$(nuSgsWallFunctions)/nuSgsSpalartAllmarasWallFunction/nuSgsSpalartAllmarasWallFunctionFvPatchScalarField.C + + +LIB = $(FOAM_LIBBIN)/libincompressibleLESModels diff --git a/src/turbulenceModels/incompressible/LES/Make/options b/src/turbulenceModels/incompressible/LES/Make/options new file mode 100644 index 0000000000..8772261e70 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I../turbulenceModel/lnInclude \ + -I../../LES/LESdeltas/lnInclude \ + -I../../LES/LESfilters/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +LIB_LIBS = \ + -lincompressibleTurbulenceModel \ + -lLESdeltas \ + -lLESfilters\ + -lfiniteVolume \ + -lmeshTools diff --git a/src/turbulenceModels/incompressible/LES/Smagorinsky/Smagorinsky.C b/src/turbulenceModels/incompressible/LES/Smagorinsky/Smagorinsky.C new file mode 100644 index 0000000000..3011677064 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/Smagorinsky/Smagorinsky.C @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "Smagorinsky.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Smagorinsky, 0); +addToRunTimeSelectionTable(LESModel, Smagorinsky, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Smagorinsky::Smagorinsky +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESModel(typeName, U, phi, transport), + GenEddyVisc(U, phi, transport), + + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.094 + ) + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Smagorinsky::correct(const tmp& gradU) +{ + GenEddyVisc::correct(gradU); + + nuSgs_ = ck_*delta()*sqrt(k(gradU)); + nuSgs_.correctBoundaryConditions(); +} + + +bool Smagorinsky::read() +{ + if (GenEddyVisc::read()) + { + ck_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/Smagorinsky/Smagorinsky.H b/src/turbulenceModels/incompressible/LES/Smagorinsky/Smagorinsky.H new file mode 100644 index 0000000000..3dcb5b28a4 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/Smagorinsky/Smagorinsky.H @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::LESModels::Smagorinsky + +Description + The Isochoric Smagorinsky Model for incompressible flows. + + Algebraic eddy viscosity SGS model founded on the assumption that + local equilibrium prevails. + Thus, + @verbatim + B = 2/3*k*I - 2*nuSgs*dev(D) + Beff = 2/3*k*I - 2*nuEff*dev(D) + + where + + D = symm(grad(U)); + k = (2*ck/ce)*delta^2*||D||^2 + nuSgs = ck*sqrt(k)*delta + nuEff = nuSgs + nu + @endverbatim + +SourceFiles + Smagorinsky.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Smagorinsky_H +#define Smagorinsky_H + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class Smagorinsky Declaration +\*---------------------------------------------------------------------------*/ + +class Smagorinsky +: + public GenEddyVisc +{ + // Private data + + dimensionedScalar ck_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + Smagorinsky(const Smagorinsky&); + Smagorinsky& operator=(const Smagorinsky&); + + +public: + + //- Runtime type information + TypeName("Smagorinsky"); + + // Constructors + + //- Construct from components + Smagorinsky + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~Smagorinsky() + {} + + + // Member Functions + + //- Return SGS kinetic energy + // calculated from the given velocity gradient + tmp k(const tmp& gradU) const + { + return (2.0*ck_/ce_)*sqr(delta())*magSqr(dev(symm(gradU))); + } + + //- Return SGS kinetic energy + virtual tmp k() const + { + return k(fvc::grad(U())); + } + + + //- Correct Eddy-Viscosity and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/Smagorinsky2/Smagorinsky2.C b/src/turbulenceModels/incompressible/LES/Smagorinsky2/Smagorinsky2.C new file mode 100644 index 0000000000..351db3526e --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/Smagorinsky2/Smagorinsky2.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "Smagorinsky2.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Smagorinsky2, 0); +addToRunTimeSelectionTable(LESModel, Smagorinsky2, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Smagorinsky2::Smagorinsky2 +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESModel(typeName, U, phi, transport), + Smagorinsky(U, phi, transport), + + cD2_ + ( + dimensioned::lookupOrAddToDict + ( + "cD2", + coeffDict(), + 0.02 + ) + ) +{ + printCoeffs(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Evaluate B (from the definition of an eddy viscosity model) and +// return it. + +tmp Smagorinsky2::B() const +{ + volSymmTensorField D = dev(symm(fvc::grad(U()))); + + return (((2.0/3.0)*I)*k() - 2.0*nuSgs_*D - (2.0*cD2_)*delta()*(D&D)); +} + + +tmp Smagorinsky2::divDevBeff +( + volVectorField& U +) const +{ + volTensorField gradU = fvc::grad(U); + + volSymmTensorField aniNuEff + ( + "aniNuEff", + I*nuEff() + cD2_*delta()*symm(gradU) + ); + + return + ( + - fvm::laplacian(aniNuEff, U) - fvc::div(nuEff()*dev(fvc::grad(U)().T())) + ); +} + + +bool Smagorinsky2::read() +{ + if (Smagorinsky::read()) + { + cD2.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/Smagorinsky2/Smagorinsky2.H b/src/turbulenceModels/incompressible/LES/Smagorinsky2/Smagorinsky2.H new file mode 100644 index 0000000000..330bfd8b28 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/Smagorinsky2/Smagorinsky2.H @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::LESModels::Smagorinsky2 + +Description + The Isochoric Smagorinsky Model for incompressible flows + + Algebraic eddy viscosity SGS model founded on the assumption that + local equilibrium prevails, hence + @verbatim + B = 2/3*k*I - 2*nuSgs*dev(D) - 2*cD2*delta*(D.dev(D)); + Beff = 2/3*k*I - 2*nuEff*dev(D) - 2*cD2*delta*(D.dev(D)); + + where + + D = symm(grad(U)); + k = cI*delta^2*||D||^2 + nuSgs = ck*sqrt(k)*delta + nuEff = nuSgs + nu + @endverbatim + +SourceFiles + Smagorinsky2.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Smagorinsky2_H +#define Smagorinsky2_H + +#include "Smagorinsky.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class Smagorinsky2 Declaration +\*---------------------------------------------------------------------------*/ + +class Smagorinsky2 +: + public Smagorinsky +{ + // Private data + + dimensionedScalar cD2_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + Smagorinsky2(const Smagorinsky2&); + Smagorinsky2& operator=(const Smagorinsky2&); + + +public: + + //- Runtime type information + TypeName("Smagorinsky2"); + + + // Constructors + + //- Construct from components + Smagorinsky2 + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~Smagorinsky2() + {} + + + // Member Functions + + //- Return B. + virtual tmp B() const; + + //- Returns div(B). + // This is the additional term due to the filtering of the NSE. + virtual tmp divDevBeff(volVectorField& U) const; + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C new file mode 100644 index 0000000000..11843958d5 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C @@ -0,0 +1,371 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpalartAllmaras.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(SpalartAllmaras, 0); +addToRunTimeSelectionTable(LESModel, SpalartAllmaras, dictionary); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp SpalartAllmaras::fv1() const +{ + volScalarField chi3 = pow3(nuTilda_/nu()); + return chi3/(chi3 + pow3(Cv1_)); +} + + +tmp SpalartAllmaras::fv2() const +{ + volScalarField chi = nuTilda_/nu(); + return 1.0/pow3(scalar(1) + chi/Cv2_); +} + + +tmp SpalartAllmaras::fv3() const +{ + volScalarField chi = nuTilda_/nu(); + volScalarField chiByCv2 = (1/Cv2_)*chi; + + return + (scalar(1) + chi*fv1()) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); +} + + +tmp SpalartAllmaras::calcS(const volTensorField& gradU) +{ + return ::sqrt(2.0)*mag(skew(gradU)); +} + + +tmp SpalartAllmaras::calcSTilda(const volTensorField& gradU) +{ + return fv3()*calcS(gradU) + fv2()*nuTilda_/sqr(kappa_*dTilda_); +} + + +tmp SpalartAllmaras::r +( + const volScalarField& visc, + const volScalarField& S +) const +{ + tmp tr + ( + new volScalarField + ( + min + ( + visc + /( + max + ( + S, + dimensionedScalar("SMALL", S.dimensions(), SMALL) + ) + *sqr(kappa_*dTilda_) + + dimensionedScalar + ( + "ROOTVSMALL", + dimensionSet(0, 2 , -1, 0, 0), + ROOTVSMALL + ) + ), + scalar(10.0) + ) + ) + ); + + return tr; +} + + +tmp SpalartAllmaras::fw(const volScalarField& S) const +{ + volScalarField r = this->r(nuTilda_, S); + + volScalarField g = r + Cw2_*(pow6(r) - r); + + return g*pow((1.0 + pow6(Cw3_))/(pow6(g) + pow6(Cw3_)), 1.0/6.0); +} + + +void SpalartAllmaras::dTildaUpdate(const volScalarField&) +{ + if (mesh_.changing()) + { + dTilda_ = min(CDES_*delta(), wallDist(mesh_).y()); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +SpalartAllmaras::SpalartAllmaras +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport, + const word& modelName +) +: + LESModel(modelName, U, phi, transport), + + alphaNut_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaNut", + coeffDict(), + 1.5 + ) + ), + kappa_ + ( + dimensioned::lookupOrAddToDict + ( + "kappa", + *this, + 0.4187 + ) + ), + Cb1_ + ( + dimensioned::lookupOrAddToDict + ( + "Cb1", + coeffDict(), + 0.1355 + ) + ), + Cb2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cb2", + coeffDict(), + 0.622 + ) + ), + Cv1_ + ( + dimensioned::lookupOrAddToDict + ( + "Cv1", + coeffDict(), + 7.1 + ) + ), + Cv2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cv2", + coeffDict(), + 5.0 + ) + ), + CDES_ + ( + dimensioned::lookupOrAddToDict + ( + "CDES", + coeffDict(), + 0.65 + ) + ), + ck_ + ( + dimensioned::lookupOrAddToDict + ( + "ck", + coeffDict(), + 0.07 + ) + ), + Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)), + Cw2_ + ( + dimensioned::lookupOrAddToDict + ( + "Cw2", + coeffDict(), + 0.3 + ) + ), + Cw3_ + ( + dimensioned::lookupOrAddToDict + ( + "Cw3", + coeffDict(), + 2.0 + ) + ), + + nuTilda_ + ( + IOobject + ( + "nuTilda", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + dTilda_(min(CDES_*delta(), wallDist(mesh_).y())), + + nuSgs_ + ( + IOobject + ( + "nuSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) +{} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void SpalartAllmaras::correct(const tmp& gradU) +{ + LESModel::correct(gradU); + + const volScalarField STilda = calcSTilda(gradU); + + const volScalarField S = calcS(gradU); + + dTildaUpdate(S); + + fvScalarMatrix nuTildaEqn + ( + fvm::ddt(nuTilda_) + + fvm::div(phi(), nuTilda_) + - fvm::laplacian + ( + alphaNut_*(nuTilda_ + nu()), + nuTilda_, + "laplacian(DnuTildaEff,nuTilda)" + ) + - alphaNut_*Cb2_*magSqr(fvc::grad(nuTilda_)) + == + Cb1_*STilda*nuTilda_ + - fvm::Sp(Cw1_*fw(STilda)*nuTilda_/sqr(dTilda_), nuTilda_) + ); + + nuTildaEqn.relax(); + nuTildaEqn.solve(); + + bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0)); + nuTilda_.correctBoundaryConditions(); + + nuSgs_.internalField() = fv1()*nuTilda_.internalField(); + nuSgs_.correctBoundaryConditions(); +} + + +tmp SpalartAllmaras::epsilon() const +{ + return 2.0*nuEff()*magSqr(symm(fvc::grad(U()))); +} + + +tmp SpalartAllmaras::B() const +{ + return ((2.0/3.0)*I)*k() - nuSgs()*twoSymm(fvc::grad(U())); +} + + +tmp SpalartAllmaras::devBeff() const +{ + return -nuEff()*dev(twoSymm(fvc::grad(U()))); +} + + +tmp SpalartAllmaras::divDevBeff(volVectorField& U) const +{ + return + ( + - fvm::laplacian(nuEff(), U) - fvc::div(nuEff()*dev(fvc::grad(U)().T())) + ); +} + + +bool SpalartAllmaras::read() +{ + if (LESModel::read()) + { + alphaNut_.readIfPresent(coeffDict()); + kappa_.readIfPresent(*this); + Cb1_.readIfPresent(coeffDict()); + Cb2_.readIfPresent(coeffDict()); + Cv1_.readIfPresent(coeffDict()); + Cv2_.readIfPresent(coeffDict()); + CDES_.readIfPresent(coeffDict()); + ck_.readIfPresent(coeffDict()); + Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_); + Cw2_.readIfPresent(coeffDict()); + Cw3_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H new file mode 100644 index 0000000000..aa721b1b5c --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::LESmodels::SpalartAllmaras + +Description + SpalartAllmaras DES (SA + LES) turbulence model for incompressible flows + +SourceFiles + SpalartAllmaras.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SpalartAllmaras_H +#define SpalartAllmaras_H + +#include "LESModel.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class SpalartAllmaras Declaration +\*---------------------------------------------------------------------------*/ + +class SpalartAllmaras +: + public LESModel +{ + // Private member functions + + // Disallow default bitwise copy construct and assignment + SpalartAllmaras(const SpalartAllmaras&); + SpalartAllmaras& operator=(const SpalartAllmaras&); + + +protected: + + // Protected data + + dimensionedScalar alphaNut_; + dimensionedScalar kappa_; + + + // Model constants + + dimensionedScalar Cb1_; + dimensionedScalar Cb2_; + dimensionedScalar Cv1_; + dimensionedScalar Cv2_; + dimensionedScalar CDES_; + dimensionedScalar ck_; + dimensionedScalar Cw1_; + dimensionedScalar Cw2_; + dimensionedScalar Cw3_; + + + // Fields + + volScalarField nuTilda_; + volScalarField dTilda_; + volScalarField nuSgs_; + + + // Protected member functions + + // Helper functions + + virtual tmp fv1() const; + virtual tmp fv2() const; + virtual tmp fv3() const; + //- + virtual tmp calcS(const volTensorField& gradU); + virtual tmp calcSTilda(const volTensorField& gradU); + virtual tmp r + ( + const volScalarField& visc, + const volScalarField& S + ) const; + virtual tmp fw(const volScalarField& S) const; + + //- Length scale calculation + virtual void dTildaUpdate(const volScalarField& S); + + +public: + + //- Runtime type information + TypeName("SpalartAllmaras"); + + + // Constructors + + //- Construct from components + SpalartAllmaras + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport, + const word& modelName = typeName + ); + + + //- Destructor + virtual ~SpalartAllmaras() + {} + + + // Member Functions + + //- Return SGS kinetic energy + virtual tmp k() const + { + return sqr(nuSgs()/ck_/dTilda_); + } + + //- Return sub-grid disipation rate + virtual tmp epsilon() const; + + tmp nuTilda() const + { + return nuTilda_; + } + + //- Return SGS viscosity + virtual tmp nuSgs() const + { + return nuSgs_; + } + + //- Return the sub-grid stress tensor. + virtual tmp B() const; + + //- Return the effective sub-grid turbulence stress tensor + // including the laminar stress + virtual tmp devBeff() const; + + //- Return the deviatoric part of the divergence of Beff + // i.e. the additional term in the filtered NSE. + virtual tmp divDevBeff(volVectorField& U) const; + + //- Correct nuTilda and related properties + virtual void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasDDES/SpalartAllmarasDDES.C b/src/turbulenceModels/incompressible/LES/SpalartAllmarasDDES/SpalartAllmarasDDES.C new file mode 100644 index 0000000000..6f5435a268 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasDDES/SpalartAllmarasDDES.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpalartAllmarasDDES.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(SpalartAllmarasDDES, 0); +addToRunTimeSelectionTable(LESModel, SpalartAllmarasDDES, dictionary); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp SpalartAllmarasDDES::rd +( + const volScalarField& visc, + const volScalarField& S +) const +{ + volScalarField d = wallDist(mesh_).y(); + + tmp trd + ( + new volScalarField + ( + min + ( + visc + /( + max + ( + S, + dimensionedScalar("SMALL", S.dimensions(), SMALL) + )*sqr(kappa_*d) + + dimensionedScalar + ( + "ROOTVSMALL", + dimensionSet(0, 2 , -1, 0, 0), + ROOTVSMALL + ) + ), scalar(10.0) + ) + ) + ); + + return trd; +} + + +tmp SpalartAllmarasDDES::fd(const volScalarField& S) +{ + return 1.0 - tanh(pow3(8.0*rd(nuSgs_ + transport().nu(), S))); +} + + +void SpalartAllmarasDDES::dTildaUpdate(const volScalarField& S) +{ + dTilda_ = + wallDist(mesh_).y() + - fd(S)*max + ( + dimensionedScalar("zero", dimLength, 0.0), + wallDist(mesh_).y() - CDES_*delta() + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +SpalartAllmarasDDES::SpalartAllmarasDDES +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + SpalartAllmaras(U, phi, transport, typeName) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasDDES/SpalartAllmarasDDES.H b/src/turbulenceModels/incompressible/LES/SpalartAllmarasDDES/SpalartAllmarasDDES.H new file mode 100644 index 0000000000..ec7eeda68c --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasDDES/SpalartAllmarasDDES.H @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::LESmodels::SpalartAllmarasDDES + +Description + SpalartAllmaras DDES LES turbulence model for incompressible flows + + Reference: + P.R. Spalart, S. Deck, S., M.L.Shur, K.D. Squires, M.Kh Strelets, and + A. Travin. `A new version of detached-eddy simulation, resistant to + ambiguous grid densities'. Theor. Comp. Fluid Dyn., 20:181-195, 2006. + +SourceFiles + SpalartAllmarasDDES.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SpalartAllmarasDDES_H +#define SpalartAllmarasDDES_H + +#include "SpalartAllmaras.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class SpalartAllmarasDDES Declaration +\*---------------------------------------------------------------------------*/ + +class SpalartAllmarasDDES +: + public SpalartAllmaras +{ + // Private member functions + + // Disallow default bitwise copy construct and assignment + SpalartAllmarasDDES(const SpalartAllmarasDDES&); + SpalartAllmarasDDES& operator=(const SpalartAllmarasDDES&); + + +protected: + + // Protected member functions + + tmp fd(const volScalarField& S); + tmp rd + ( + const volScalarField& visc, + const volScalarField& S + ) const; + + //- Length scale calculation + virtual void dTildaUpdate(const volScalarField& S); + + +public: + + //- Runtime type information + TypeName("SpalartAllmarasDDES"); + + + // Constructors + + //- Construct from components + SpalartAllmarasDDES + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~SpalartAllmarasDDES() + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C new file mode 100644 index 0000000000..36e6a46a4e --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "IDDESDelta.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(IDDESDelta, 0); + addToRunTimeSelectionTable(LESdelta, IDDESDelta, dictionary); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::IDDESDelta::calcDelta() +{ + const Vector