Added generic turbulenceModel base class to incompressible turbulence models.

This commit is contained in:
henry
2008-11-20 20:33:06 +00:00
parent 326b86ec2d
commit 0479165024
307 changed files with 64527 additions and 0 deletions

View File

@ -0,0 +1,3 @@
channelFoam.C
EXE = $(FOAM_APPBIN)/channelFoam

View File

@ -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

View File

@ -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<nCorr; corr++)
{
U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);
adjustPhi(phi, U, p);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
{
pEqn.solve(mesh.solver(p.name() + "Final"));
}
else
{
pEqn.solve(mesh.solver(p.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
#include "continuityErrs.H"
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
}
// Correct driving force for a constant mass flow rate
// Extract the velocity in the flow direction
dimensionedScalar magUbarStar =
(flowDirection & U)().weightedAverage(mesh.V());
// Calculate the pressure gradient increment needed to
// adjust the average flow-rate to the correct value
dimensionedScalar gragPplus =
(magUbar - magUbarStar)/rUA.weightedAverage(mesh.V());
U += flowDirection*rUA*gragPplus;
gradP += gragPplus;
Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab
<< "pressure gradient = " << gradP.value() << endl;
runTime.write();
#include "writeGradP.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
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<incompressible::LESModel> sgsModel
(
incompressible::LESModel::New(U, phi, laminarTransport)
);

View File

@ -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" <<endl
<< endl;
}
else
{
Info<< "Initializing with 0 pressure gradient" <<endl
<< endl;
};

View File

@ -0,0 +1,28 @@
Info<< "\nReading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar nu
(
transportProperties.lookup("nu")
);
// Read centerline velocity for channel simulations
dimensionedVector Ubar
(
transportProperties.lookup("Ubar")
);
dimensionedScalar magUbar = mag(Ubar);
vector flowDirection = (Ubar/magUbar).value();

View File

@ -0,0 +1,19 @@
if (runTime.outputTime())
{
OFstream gradPFile
(
runTime.path()/runTime.timeName()/"uniform"/"gradP.raw"
);
if(gradPFile.good())
{
gradPFile << gradP << endl;
}
else
{
FatalErrorIn(args.executable())
<< "Cannot open file "
<< runTime.path()/runTime.timeName()/"uniform"/"gradP.raw"
<< exit(FatalError);
};
};

View File

@ -0,0 +1,3 @@
pimpleDyMFoam.C
EXE = $(FOAM_APPBIN)/pimpleDyMFoam

View File

@ -0,0 +1,17 @@
EXE_INC = \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-ldynamicFvMesh \
-ldynamicMesh \
-lmeshTools \
-lincompressibleTransportModels \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lfiniteVolume

View File

@ -0,0 +1,16 @@
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
+ turbulence->divDevReff(U)
);
if (ocorr != nOuterCorr-1)
{
UEqn.relax();
}
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}

View File

@ -0,0 +1,44 @@
{
wordList pcorrTypes(p.boundaryField().types());
for (label i=0; i<p.boundaryField().size(); i++)
{
if(p.boundaryField()[i].fixesValue())
{
pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
}
}
volScalarField pcorr
(
IOobject
(
"pcorr",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("pcorr", p.dimensions(), 0.0),
pcorrTypes
);
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pcorrEqn
(
fvm::laplacian(rAU, pcorr) == fvc::div(phi)
);
pcorrEqn.setReference(pRefCell, pRefValue);
pcorrEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pcorrEqn.flux();
}
}
}
#include "continuityErrs.H"

View File

@ -0,0 +1,59 @@
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<incompressible::turbulenceModel> 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
);

View File

@ -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; ocorr<nOuterCorr; ocorr++)
{
if (nOuterCorr != 1)
{
p.storePrevIter();
}
# include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
rAU = 1.0/UEqn.A();
U = rAU*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf());
if (p.needReference())
{
fvc::makeRelative(phi, U);
adjustPhi(phi, U, p);
fvc::makeAbsolute(phi, U);
}
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
if
(
ocorr == nOuterCorr-1
&& corr == nCorr-1
&& nonOrth == nNonOrthCorr)
{
pEqn.solve(mesh.solver(p.name() + "Final"));
}
else
{
pEqn.solve(mesh.solver(p.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
# include "continuityErrs.H"
// Explicitly relax pressure for momentum corrector
if (ocorr != nOuterCorr-1)
{
p.relax();
}
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
U -= rAU*fvc::grad(p);
U.correctBoundaryConditions();
}
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -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"));
}

View File

@ -0,0 +1,3 @@
pisoFoam.C
EXE = $(FOAM_APPBIN)/pisoFoam

View File

@ -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

View File

@ -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<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);

View File

@ -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; corr<nCorr; corr++)
{
volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);
adjustPhi(phi, U, p);
// Non-orthogonal pressure corrector loop
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
// Pressure corrector
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
# include "continuityErrs.H"
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
}
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -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;
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
cavitatingFoam.C
EXE = $(FOAM_APPBIN)/cavitatingFoam

View File

@ -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

View File

@ -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));
}

View File

@ -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; outerCorr<nOuterCorr; outerCorr++)
{
# include "rhoEqn.H"
# include "gammaPsi.H"
# include "UEqn.H"
for (int corr=0; corr<nCorr; corr++)
{
# include "pEqn.H"
}
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "\n end \n";
return(0);
}
// ************************************************************************* //

View File

@ -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;
}

View File

@ -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<barotropicCompressibilityModel> 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<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phiv, twoPhaseProperties)
);

View File

@ -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;
}

View File

@ -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"
}

View File

@ -0,0 +1,9 @@
#include "readTimeControls.H"
scalar maxAcousticCo
(
readScalar(runTime.controlDict().lookup("maxAcousticCo"))
);
#include "readPISOControls.H"

View File

@ -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"));

View File

@ -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<calculatedFvsPatchScalarField>(phiPatches[patchI]);
phiPatch == ((rhoPatches[patchI]*Upatches[patchI]) & SfPatches[patchI]);
}
}

View File

@ -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<calculatedFvsPatchScalarField>(phivPatches[patchI]);
phivPatch == (Upatches[patchI] & SfPatches[patchI]);
}
}

View File

@ -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);
}

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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
)
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
compressibleInterDyMFoam.C
EXE = $(FOAM_APPBIN)/compressibleInterDyMFoam

View File

@ -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

View File

@ -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()
)
);
}

View File

@ -0,0 +1,76 @@
{
word alphaScheme("div(phi,alpha)");
word alpharScheme("div(phirb,alpha)");
surfaceScalarField phir = phic*interface.nHatf();
for (int gCorr=0; gCorr<nAlphaCorr; gCorr++)
{
volScalarField::DimensionedInternalField Sp
(
IOobject
(
"Sp",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("Sp", dgdt.dimensions(), 0.0)
);
volScalarField::DimensionedInternalField Su
(
IOobject
(
"Su",
runTime.timeName(),
mesh
),
// Divergence term is handled explicitly to be
// consistent with the explicit transport solution
divU*min(alpha1, scalar(1))
);
forAll(dgdt, celli)
{
if (dgdt[celli] > 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;
}

View File

@ -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<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);
!(++alphaSubCycle).end();
)
{
# include "alphaEqns.H"
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi;
}
rhoPhi = rhoPhiSum;
}
else
{
# include "alphaEqns.H"
}
if (oCorr == 0)
{
interface.correct();
}
}

View File

@ -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<nOuterCorr; oCorr++)
{
#include "alphaEqnsSubCycle.H"
solve(fvm::ddt(rho) + fvc::div(rhoPhi));
#include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
}
rho = alpha1*rho1 + alpha2*rho2;
runTime.write();
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n\n" << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -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<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
);

View File

@ -0,0 +1,77 @@
{
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rUAf = fvc::interpolate(rUA);
tmp<fvScalarMatrix> 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);
}

View File

@ -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"));
}

View File

@ -0,0 +1,3 @@
compressibleInterFoam.C
EXE = $(FOAM_APPBIN)/compressibleInterFoam

View File

@ -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

View File

@ -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()
)
);
}

View File

@ -0,0 +1,76 @@
{
word alphaScheme("div(phi,alpha)");
word alpharScheme("div(phirb,alpha)");
surfaceScalarField phir = phic*interface.nHatf();
for (int gCorr=0; gCorr<nAlphaCorr; gCorr++)
{
volScalarField::DimensionedInternalField Sp
(
IOobject
(
"Sp",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("Sp", dgdt.dimensions(), 0.0)
);
volScalarField::DimensionedInternalField Su
(
IOobject
(
"Su",
runTime.timeName(),
mesh
),
// Divergence term is handled explicitly to be
// consistent with the explicit transport solution
divU*min(alpha1, scalar(1))
);
forAll(dgdt, celli)
{
if (dgdt[celli] > 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;
}

View File

@ -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<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);
!(++alphaSubCycle).end();
)
{
#include "alphaEqns.H"
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi;
}
rhoPhi = rhoPhiSum;
}
else
{
#include "alphaEqns.H"
}
if (oCorr == 0)
{
interface.correct();
}
}

View File

@ -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; oCorr<nOuterCorr; oCorr++)
{
#include "alphaEqnsSubCycle.H"
solve(fvm::ddt(rho) + fvc::div(rhoPhi));
#include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
}
rho = alpha1*rho1 + alpha2*rho2;
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n\n" << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -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<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
);

View File

@ -0,0 +1,74 @@
{
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rUAf = fvc::interpolate(rUA);
tmp<fvScalarMatrix> 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;
}

View File

@ -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);
}

View File

@ -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<nAlphaCorr; gCorr++)
{
surfaceScalarField phiAlpha =
fvc::flux
(
phi,
alpha1,
alphaScheme
)
+ fvc::flux
(
-fvc::flux(-phir, scalar(1) - alpha1, alpharScheme),
alpha1,
alpharScheme
);
MULES::explicitSolve(alpha1, phi, phiAlpha, 1, 0);
rhoPhi = 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;
}

View File

@ -0,0 +1,35 @@
label nAlphaCorr
(
readLabel(piso.lookup("nAlphaCorr"))
);
label nAlphaSubCycles
(
readLabel(piso.lookup("nAlphaSubCycles"))
);
if (nAlphaSubCycles > 1)
{
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum = 0.0*rhoPhi;
for
(
subCycle<volScalarField> 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;

View File

@ -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<nAlphaCorr; gCorr++)
{
surfaceScalarField phiAlpha =
fvc::flux
(
phi,
alpha1,
alphaScheme
)
+ fvc::flux
(
-fvc::flux(-phir, scalar(1) - alpha1, alpharScheme),
alpha1,
alpharScheme
);
Pair<tmp<volScalarField> > 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;
}

View File

@ -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<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);
!(++alphaSubCycle).end();
)
{
# include "alphaEqn.H"
}
}
else
{
# include "alphaEqn.H"
}
if (nOuterCorr == 1)
{
interface.correct();
}
rho == alpha1*rho1 + (scalar(1) - alpha1)*rho2;
}

View File

@ -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;
}

View File

@ -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<scalar, volMesh>& iF
)
:
zeroGradientFvPatchScalarField(p, iF)
{}
Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField& gcpsf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
zeroGradientFvPatchScalarField(gcpsf, p, iF, mapper)
{}
Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
zeroGradientFvPatchScalarField(p, iF)
{
evaluate();
}
Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField& gcpsf
)
:
zeroGradientFvPatchScalarField(gcpsf)
{}
Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField& gcpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
zeroGradientFvPatchScalarField(gcpsf, iF)
{}
// ************************************************************************* //

View File

@ -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<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
alphaContactAngleFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given alphaContactAngleFvPatchScalarField
// onto a new patch
alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField&
);
//- Construct as copy setting internal field reference
alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
// Member functions
//- Return the contact angle
virtual tmp<scalarField> theta
(
const fvPatchVectorField& Up,
const fvsPatchVectorField& nHat
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar, volMesh>& iF
)
:
alphaContactAngleFvPatchScalarField(p, iF),
theta0_(0.0)
{}
Foam::constantAlphaContactAngleFvPatchScalarField::
constantAlphaContactAngleFvPatchScalarField
(
const constantAlphaContactAngleFvPatchScalarField& gcpsf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
alphaContactAngleFvPatchScalarField(gcpsf, p, iF, mapper),
theta0_(gcpsf.theta0_)
{}
Foam::constantAlphaContactAngleFvPatchScalarField::
constantAlphaContactAngleFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& 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<scalar, volMesh>& iF
)
:
alphaContactAngleFvPatchScalarField(gcpsf, iF),
theta0_(gcpsf.theta0_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField>
Foam::constantAlphaContactAngleFvPatchScalarField::theta
(
const fvPatchVectorField&,
const fvsPatchVectorField&
) const
{
return tmp<scalarField>(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
);
}
// ************************************************************************* //

View File

@ -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<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
constantAlphaContactAngleFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// constantAlphaContactAngleFvPatchScalarField
// onto a new patch
constantAlphaContactAngleFvPatchScalarField
(
const constantAlphaContactAngleFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
constantAlphaContactAngleFvPatchScalarField
(
const constantAlphaContactAngleFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new constantAlphaContactAngleFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
constantAlphaContactAngleFvPatchScalarField
(
const constantAlphaContactAngleFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new constantAlphaContactAngleFvPatchScalarField(*this, iF)
);
}
// Member functions
//- Return the equilibrium contact-angle
virtual tmp<scalarField> theta
(
const fvPatchVectorField& Up,
const fvsPatchVectorField& nHat
) const;
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar, volMesh>& 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<scalar, volMesh>& 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<scalar, volMesh>& 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<scalar, volMesh>& iF
)
:
alphaContactAngleFvPatchScalarField(gcpsf, iF),
theta0_(gcpsf.theta0_),
uTheta_(gcpsf.uTheta_),
thetaA_(gcpsf.thetaA_),
thetaR_(gcpsf.thetaR_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField>
Foam::dynamicAlphaContactAngleFvPatchScalarField::theta
(
const fvPatchVectorField& Up,
const fvsPatchVectorField& nHat
) const
{
if (uTheta_ < SMALL)
{
return tmp<scalarField>(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
);
}
// ************************************************************************* //

View File

@ -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<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
dynamicAlphaContactAngleFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// dynamicAlphaContactAngleFvPatchScalarField
// onto a new patch
dynamicAlphaContactAngleFvPatchScalarField
(
const dynamicAlphaContactAngleFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
dynamicAlphaContactAngleFvPatchScalarField
(
const dynamicAlphaContactAngleFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new dynamicAlphaContactAngleFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
dynamicAlphaContactAngleFvPatchScalarField
(
const dynamicAlphaContactAngleFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new dynamicAlphaContactAngleFvPatchScalarField(*this, iF)
);
}
// Member functions
//- Evaluate and return dynamic contact-angle
virtual tmp<scalarField> theta
(
const fvPatchVectorField& Up,
const fvsPatchVectorField& nHat
) const;
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar, volMesh>& 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<scalar, volMesh>& 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<scalar, volMesh>& 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<scalar, volMesh>& iF
)
:
alphaContactAngleFvPatchScalarField(gcpsf, iF),
t0_(gcpsf.t0_),
thetaT0_(gcpsf.thetaT0_),
te_(gcpsf.te_),
thetaTe_(gcpsf.thetaTe_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField>
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<scalarField>(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
);
}
// ************************************************************************* //

View File

@ -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<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
timeVaryingAlphaContactAngleFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given timeVaryingAlphaContactAngleFvPatchScalarField
// onto a new patch
timeVaryingAlphaContactAngleFvPatchScalarField
(
const timeVaryingAlphaContactAngleFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new timeVaryingAlphaContactAngleFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
timeVaryingAlphaContactAngleFvPatchScalarField
(
const timeVaryingAlphaContactAngleFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new timeVaryingAlphaContactAngleFvPatchScalarField(*this, iF)
);
}
// Member functions
//- Evaluate and return the time-varying equilibrium contact-angle
virtual tmp<scalarField> theta
(
const fvPatchVectorField& Up,
const fvsPatchVectorField& nHat
) const;
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
p_(p.size(), 0.0)
{}
Foam::alphaFixedPressureFvPatchScalarField::
alphaFixedPressureFvPatchScalarField
(
const alphaFixedPressureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
p_(ptf.p_, mapper)
{}
Foam::alphaFixedPressureFvPatchScalarField::
alphaFixedPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF),
p_("p", dict, p.size())
{
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
fvPatchField<scalar>::operator=(p_);
}
}
Foam::alphaFixedPressureFvPatchScalarField::
alphaFixedPressureFvPatchScalarField
(
const alphaFixedPressureFvPatchScalarField& tppsf
)
:
fixedValueFvPatchScalarField(tppsf),
p_(tppsf.p_)
{}
Foam::alphaFixedPressureFvPatchScalarField::
alphaFixedPressureFvPatchScalarField
(
const alphaFixedPressureFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& 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<const alphaFixedPressureFvPatchScalarField>(ptf);
p_.rmap(tiptf.p_, addr);
}
void Foam::alphaFixedPressureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const dictionary& environmentalProperties
= db().lookupObject<IOdictionary>("environmentalProperties");
dimensionedVector g(environmentalProperties.lookup("g"));
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>("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
);
}
// ************************************************************************* //

View File

@ -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<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
alphaFixedPressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given alphaFixedPressureFvPatchScalarField
// onto a new patch
alphaFixedPressureFvPatchScalarField
(
const alphaFixedPressureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
alphaFixedPressureFvPatchScalarField
(
const alphaFixedPressureFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new alphaFixedPressureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
alphaFixedPressureFvPatchScalarField
(
const alphaFixedPressureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
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
// ************************************************************************* //

View File

@ -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

View File

@ -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<scalar>::lookupOrAddToDict
(
"ck",
coeffDict(),
0.094
)
),
cm_
(
dimensioned<scalar>::lookupOrAddToDict
(
"cm",
coeffDict(),
4.13
)
)
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void DeardorffDiffStress::correct(const tmp<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volScalarField> DBEff() const
{
return tmp<volScalarField>
(
new volScalarField("DBEff", muSgs_ + mu())
);
}
//- Correct Eddy-Viscosity and related properties
void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar>::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<volSymmTensorField> GenEddyVisc::B() const
{
return ((2.0/3.0)*I)*k_ - (muSgs_/rho())*dev(twoSymm(fvc::grad(U())));
}
tmp<volSymmTensorField> GenEddyVisc::devRhoBeff() const
{
return -muEff()*dev(twoSymm(fvc::grad(U())));
}
tmp<fvVectorMatrix> GenEddyVisc::divDevRhoBeff(volVectorField& U) const
{
return
(
- fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
);
}
void GenEddyVisc::correct(const tmp<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volScalarField> k() const
{
return k_;
}
//- Return sub-grid disipation rate
virtual tmp<volScalarField> epsilon() const
{
return ce_*k_*sqrt(k_)/delta();
}
//- Return viscosity
virtual tmp<volScalarField> muSgs() const
{
return muSgs_;
}
//- Return thermal conductivity
virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", muSgs_ + alpha())
);
}
//- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const;
//- Return the deviatoric part of the effective sub-grid
// turbulence stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devRhoBeff() const;
//- Returns div(rho*dev(B)).
// This is the additional term due to the filtering of the NSE.
virtual tmp<fvVectorMatrix> divDevRhoBeff(volVectorField& U) const;
//- Correct Eddy-Viscosity and related properties
virtual void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar>::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<volSymmTensorField> GenSGSStress::devRhoBeff() const
{
return tmp<volSymmTensorField>
(
new volSymmTensorField
(
IOobject
(
"devRhoReff",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho()*B_ - mu()*dev(twoSymm(fvc::grad(U())))
)
);
}
tmp<fvVectorMatrix> 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<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volScalarField> k() const
{
return 0.5*tr(B_);
}
//- Return the SGS turbulent dissipation.
virtual tmp<volScalarField> epsilon() const
{
volScalarField K = k();
return ce_*K*sqrt(K)/delta();
}
//- Return the SGS viscosity.
virtual tmp<volScalarField> muSgs() const
{
return muSgs_;
}
//- Return thermal conductivity
virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", muSgs_ + alpha())
);
}
//- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const
{
return B_;
}
//- Return the deviatoric part of the effective sub-grid
// turbulence stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devRhoBeff() const;
//- Returns divergence of B : i.e. the additional term in the
// filtered NSE.
virtual tmp<fvVectorMatrix> divDevRhoBeff(volVectorField& U) const;
//- Correct Eddy-Viscosity and related properties
virtual void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<Switch>("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<volTensorField>&)
{
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
// ************************************************************************* //

View File

@ -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<LESdelta> 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<LESModel> 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<volScalarField> mu() const
{
return thermoPhysicalModel_.mu();
}
//- Access function to laminar thermal conductivity
tmp<volScalarField> alpha() const
{
return thermoPhysicalModel_.alpha();
}
//- Return the SGS turbulent kinetic energy.
virtual tmp<volScalarField> k() const = 0;
//- Return the SGS turbulent dissipation.
virtual tmp<volScalarField> epsilon() const = 0;
//- Return the effective viscosity
virtual tmp<volScalarField> muSgs() const = 0;
//- Return the effective viscosity
virtual tmp<volScalarField> muEff() const
{
return tmp<volScalarField>
(
new volScalarField("muEff", muSgs() + mu())
);
}
//- Return the SGS thermal conductivity.
virtual tmp<volScalarField> alphaEff() const = 0;
//- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const = 0;
//- Return the deviatoric part of the effective sub-grid
// turbulence stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devRhoBeff() const = 0;
//- Returns div(rho*dev(B)).
// This is the additional term due to the filtering of the NSE.
virtual tmp<fvVectorMatrix> divDevRhoBeff(volVectorField& U) const = 0;
//- Correct Eddy-Viscosity and related properties.
// This calls correct(const tmp<volTensorField>& gradU) by supplying
// gradU calculated locally.
void correct();
//- Correct Eddy-Viscosity and related properties
virtual void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
virtual bool read() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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> 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<LESModel>(cstrIter()(rho, U, phi, thermoPhysicalModel));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace compressible
} // End namespace Foam
// ************************************************************************* //

View File

@ -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

View File

@ -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

View File

@ -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<scalar>::lookupOrAddToDict
(
"ck",
coeffDict(),
0.02
)
)
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Smagorinsky::correct(const tmp<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<volScalarField> SpalartAllmaras::fv1() const
{
volScalarField chi3 = pow3(nuTilda_/(mu()/rho()));
return chi3/(chi3 + pow3(Cv1_));
}
tmp<volScalarField> 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<volScalarField> 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<volScalarField> 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<scalar>::lookupOrAddToDict
(
"alphaNut",
coeffDict(),
1.5
)
),
Cb1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cb1",
coeffDict(),
0.1355
)
),
Cb2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cb2",
coeffDict(),
0.622
)
),
Cv1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cv1",
coeffDict(),
7.1
)
),
Cv2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cv2",
coeffDict(),
5.0
)
),
CDES_
(
dimensioned<scalar>::lookupOrAddToDict
(
"CDES",
coeffDict(),
0.65
)
),
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
coeffDict(),
0.07
)
),
kappa_
(
dimensioned<scalar>::lookupOrAddToDict
(
"kappa",
*this,
0.4187
)
),
Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)),
Cw2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cw2",
coeffDict(),
0.3
)
),
Cw3_
(
dimensioned<scalar>::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<volSymmTensorField> SpalartAllmaras::B() const
{
return ((2.0/3.0)*I)*k() - (muSgs_/rho())*dev(twoSymm(fvc::grad(U())));
}
tmp<volSymmTensorField> SpalartAllmaras::devRhoBeff() const
{
return -muEff()*dev(twoSymm(fvc::grad(U())));
}
tmp<volScalarField> SpalartAllmaras::epsilon() const
{
return 2*muEff()/rho()*magSqr(symm(fvc::grad(U())));
}
tmp<fvVectorMatrix> SpalartAllmaras::divDevRhoBeff(volVectorField& U) const
{
return
(
- fvm::laplacian(muEff(), U) - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
);
}
void SpalartAllmaras::correct(const tmp<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volScalarField> fv1() const;
tmp<volScalarField> fv2() const;
tmp<volScalarField> fv3() const;
tmp<volScalarField> 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<volScalarField> k() const
{
return sqr(muSgs()/rho()/ck_/dTilda_);
}
//- Return sub-grid disipation rate
tmp<volScalarField> epsilon() const;
tmp<volScalarField> nuTilda() const
{
return nuTilda_;
}
//- Return SGS viscosity
tmp<volScalarField> muSgs() const
{
return muSgs_;
}
//- Return thermal conductivity
tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", muSgs_ + alpha())
);
}
//- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const;
//- Return the deviatoric part of the effective sub-grid
// turbulence stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devRhoBeff() const;
//- Returns div(rho*dev(B)).
// This is the additional term due to the filtering of the NSE.
tmp<fvVectorMatrix> divDevRhoBeff(volVectorField& U) const;
//- Correct nuTilda and related properties
void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF)
{}
muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
{}
muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
Istream& is
)
:
fixedValueFvPatchScalarField(p, iF, is)
{}
muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict)
{}
muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf
)
:
fixedValueFvPatchScalarField(tppsf)
{}
muSgsSpalartAllmarasWallFunctionFvPatchScalarField::
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const muSgsSpalartAllmarasWallFunctionFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void muSgsSpalartAllmarasWallFunctionFvPatchScalarField::evaluate
(
const Pstream::commsTypes
)
{
const LESModel& sgsModel
= db().lookupObject<LESModel>("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<volVectorField, vector>("U");
scalarField magUp = mag(U.patchInternalField() - U);
const scalarField& muw =
patch().lookupPatchField<volScalarField, scalar>("mu");
const scalarField& rhow =
patch().lookupPatchField<volScalarField, scalar>("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
// ************************************************************************* //

View File

@ -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<scalar, volMesh>&
);
//- Construct from patch, internal field and Istream
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
Istream&
);
//- Construct from patch, internal field and dictionary
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// muSgsSpalartAllmarasWallFunctionFvPatchScalarField
// onto a new patch
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new muSgsSpalartAllmarasWallFunctionFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
muSgsSpalartAllmarasWallFunctionFvPatchScalarField
(
const muSgsSpalartAllmarasWallFunctionFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
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
// ************************************************************************* //

View File

@ -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<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<LESfilter> 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<volScalarField> DkEff() const
{
return tmp<volScalarField>
(
new volScalarField("DkEff", muSgs_ + mu())
);
}
//- Correct Eddy-Viscosity and related properties
void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar>::lookupOrAddToDict
(
"ck",
coeffDict(),
0.07
)
),
beta_
(
dimensioned<scalar>::lookupOrAddToDict
(
"beta",
coeffDict(),
0.01
)
)
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void lowReOneEqEddy::correct(const tmp<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volScalarField> DkEff() const
{
return tmp<volScalarField>
(
new volScalarField("DkEff", muSgs_ + mu())
);
}
//- Correct Eddy-Viscosity and related properties
void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar>::lookupOrAddToDict
(
"ck",
coeffDict(),
0.094
)
)
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void oneEqEddy::correct(const tmp<volTensorField>& 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
// ************************************************************************* //

View File

@ -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<volScalarField> DkEff() const
{
return tmp<volScalarField>
(
new volScalarField("DkEff", muSgs_ + mu())
);
}
//- Correct Eddy-Viscosity and related properties
void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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<scalar>::lookupOrAddToDict
(
"Cmu",
coeffDict_,
0.09
)
),
Clrr1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Clrr1",
coeffDict_,
1.8
)
),
Clrr2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Clrr2",
coeffDict_,
0.6
)
),
C1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C1",
coeffDict_,
1.44
)
),
C2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C2",
coeffDict_,
1.92
)
),
Cs_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cs",
coeffDict_,
0.25
)
),
Ceps_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Ceps",
coeffDict_,
0.15
)
),
couplingFactor_
(
dimensioned<scalar>::lookupOrAddToDict
(
"couplingFactor",
coeffDict_,
0.0
)
),
alphaR_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphaR",
coeffDict_,
1.22
)
),
alphaEps_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphaEps",
coeffDict_,
0.76923
)
),
alphah_
(
dimensioned<scalar>::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<volSymmTensorField> LRR::devRhoReff() const
{
return tmp<volSymmTensorField>
(
new volSymmTensorField
(
IOobject
(
"devRhoReff",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_)))
)
);
}
tmp<fvVectorMatrix> 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<fvScalarMatrix> 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<fvSymmTensorMatrix> 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
// ************************************************************************* //

View File

@ -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<volScalarField> mut() const
{
return mut_;
}
//- Return the effective diffusivity for R
tmp<volScalarField> DREff() const
{
return tmp<volScalarField>
(
new volScalarField("DREff", alphaR_*mut_ + mu())
);
}
//- Return the effective diffusivity for epsilon
tmp<volScalarField> DepsilonEff() const
{
return tmp<volScalarField>
(
new volScalarField("DepsilonEff", alphaEps_*mut_ + mu())
);
}
//- Return the effective turbulent thermal diffusivity
tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
);
}
//- Return the turbulence kinetic energy
tmp<volScalarField> k() const
{
return k_;
}
//- Return the turbulence kinetic energy dissipation rate
tmp<volScalarField> epsilon() const
{
return epsilon_;
}
//- Return the Reynolds stress tensor
tmp<volSymmTensorField> R() const
{
return R_;
}
//- Return the effective stress tensor including the laminar stress
tmp<volSymmTensorField> devRhoReff() const;
//- Return the source term for the momentum equation
tmp<fvVectorMatrix> 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
// ************************************************************************* //

View File

@ -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<scalar>::lookupOrAddToDict
(
"Cmu",
coeffDict_,
0.09
)
),
Clg1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Clg1",
coeffDict_,
1.8
)
),
Clg2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Clg2",
coeffDict_,
0.6
)
),
C1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C1",
coeffDict_,
1.44
)
),
C2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C2",
coeffDict_,
1.92
)
),
Cs_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cs",
coeffDict_,
0.25
)
),
Ceps_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Ceps",
coeffDict_,
0.15
)
),
C1Ref_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C1Ref",
coeffDict_,
0.5
)
),
C2Ref_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C2Ref",
coeffDict_,
0.3
)
),
couplingFactor_
(
dimensioned<scalar>::lookupOrAddToDict
(
"couplingFactor",
coeffDict_,
0.0
)
),
alphaR_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphaR",
coeffDict_,
1.22
)
),
alphaEps_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphaEps",
coeffDict_,
0.76923
)
),
alphah_
(
dimensioned<scalar>::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<volSymmTensorField> LaunderGibsonRSTM::devRhoReff() const
{
return tmp<volSymmTensorField>
(
new volSymmTensorField
(
IOobject
(
"devRhoReff",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho_*R_ - mu()*dev(twoSymm(fvc::grad(U_)))
)
);
}
tmp<fvVectorMatrix> 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<fvScalarMatrix> 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<fvSymmTensorMatrix> 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
// ************************************************************************* //

View File

@ -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<volScalarField> mut() const
{
return mut_;
}
//- Return the effective diffusivity for R
tmp<volScalarField> DREff() const
{
return tmp<volScalarField>
(
new volScalarField("DREff", alphaR_*mut_ + mu())
);
}
//- Return the effective diffusivity for epsilon
tmp<volScalarField> DepsilonEff() const
{
return tmp<volScalarField>
(
new volScalarField("DepsilonEff", alphaEps_*mut_ + mu())
);
}
//- Return the effective turbulent thermal diffusivity
tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
);
}
//- Return the turbulence kinetic energy
tmp<volScalarField> k() const
{
return k_;
}
//- Return the turbulence kinetic energy dissipation rate
tmp<volScalarField> epsilon() const
{
return epsilon_;
}
//- Return the Reynolds stress tensor
tmp<volSymmTensorField> R() const
{
return R_;
}
//- Return the effective stress tensor including the laminar stress
tmp<volSymmTensorField> devRhoReff() const;
//- Return the source term for the momentum equation
tmp<fvVectorMatrix> 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
// ************************************************************************* //

View File

@ -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<volScalarField> LaunderSharmaKE::fMu() const
{
return exp(-3.4/sqr(scalar(1) + rho_*sqr(k_)/(mu()*epsilon_)/50.0));
}
tmp<volScalarField> 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<scalar>::lookupOrAddToDict
(
"Cmu",
coeffDict_,
0.09
)
),
C1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C1",
coeffDict_,
1.44
)
),
C2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C2",
coeffDict_,
1.92
)
),
C3_
(
dimensioned<scalar>::lookupOrAddToDict
(
"C3",
coeffDict_,
-0.33
)
),
alphak_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphak",
coeffDict_,
1.0
)
),
alphaEps_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphaEps",
coeffDict_,
0.76923
)
),
alphah_
(
dimensioned<scalar>::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<volSymmTensorField> LaunderSharmaKE::R() const
{
return tmp<volSymmTensorField>
(
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<volSymmTensorField> LaunderSharmaKE::devRhoReff() const
{
return tmp<volSymmTensorField>
(
new volSymmTensorField
(
IOobject
(
"devRhoReff",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
-muEff()*dev(twoSymm(fvc::grad(U_)))
)
);
}
tmp<fvVectorMatrix> 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<volTensorField> tgradU = fvc::grad(U_);
volScalarField G = mut_*(tgradU() && dev(twoSymm(tgradU())));
tgradU.clear();
// Dissipation equation
tmp<fvScalarMatrix> 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<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(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
// ************************************************************************* //

View File

@ -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<volScalarField> fMu() const;
tmp<volScalarField> 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<volScalarField> mut() const
{
return mut_;
}
//- Return the effective diffusivity for k
tmp<volScalarField> DkEff() const
{
return tmp<volScalarField>
(
new volScalarField("DkEff", alphak_*mut_ + mu())
);
}
//- Return the effective diffusivity for epsilon
tmp<volScalarField> DepsilonEff() const
{
return tmp<volScalarField>
(
new volScalarField("DepsilonEff", alphaEps_*mut_ + mu())
);
}
//- Return the effective turbulent thermal diffusivity
tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphah_*mut_ + alpha())
);
}
//- Return the turbulence kinetic energy
tmp<volScalarField> k() const
{
return k_;
}
//- Return the turbulence kinetic energy dissipation rate
tmp<volScalarField> epsilon() const
{
return epsilon_;
}
//- Return the Reynolds stress tensor
tmp<volSymmTensorField> R() const;
//- Return the effective stress tensor including the laminar stress
tmp<volSymmTensorField> devRhoReff() const;
//- Return the source term for the momentum equation
tmp<fvVectorMatrix> 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
// ************************************************************************* //

View File

@ -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

View File

@ -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

View File

@ -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<Switch>("printCoeffs", false)),
coeffDict_(subDict(type + "Coeffs")),
wallFunctionDict_(subDict("wallFunctionCoeffs")),
kappa_
(
dimensioned<scalar>::lookupOrAddToDict
(
"kappa",
subDict("wallFunctionCoeffs"),
0.4187
)
),
E_
(
dimensioned<scalar>::lookupOrAddToDict
(
"E",
subDict("wallFunctionCoeffs"),
9.0
)
),
Cmu_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cmu",
wallFunctionDict_,
0.09
)
),
Prt_
(
dimensioned<scalar>::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<scalarField> RASModel::yPlus(const label patchNo) const
{
const fvPatch& curPatch = mesh_.boundary()[patchNo];
tmp<scalarField> tYp(new scalarField(curPatch.size()));
scalarField& Yp = tYp();
if (isType<wallFvPatch>(curPatch))
{
Yp = pow(Cmu_.value(), 0.25)
*y_[patchNo]
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
/(
mu().boundaryField()[patchNo].patchInternalField()
/rho_.boundaryField()[patchNo]
);
}
else
{
WarningIn
(
"tmp<scalarField> 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
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More