Merge branch 'master' into Lagrangian

This commit is contained in:
andy
2008-05-16 11:42:01 +01:00
283 changed files with 15542 additions and 50638 deletions

View File

@ -41,17 +41,13 @@ Description
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readTransportProperties.H"
# include "createFields.H"
# include "createAverages.H"
# include "initContinuityErrs.H"
# include "createGradP.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#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;
@ -59,9 +55,9 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readPISOControls.H"
#include "readPISOControls.H"
# include "CourantNo.H"
#include "CourantNo.H"
sgsModel->correct();
@ -116,7 +112,7 @@ int main(int argc, char *argv[])
}
}
# include "continuityErrs.H"
#include "continuityErrs.H"
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
@ -126,12 +122,12 @@ int main(int argc, char *argv[])
// Correct driving force for a constant mass flow rate
// Extract the velocity in the flow direction
dimensionedScalar magUbarStar =
dimensionedScalar magUbarStar =
(flowDirection & U)().weightedAverage(mesh.V());
// Calculate the pressure gradient increment needed to
// Calculate the pressure gradient increment needed to
// adjust the average flow-rate to the correct value
dimensionedScalar gragPplus =
dimensionedScalar gragPplus =
(magUbar - magUbarStar)/rUA.weightedAverage(mesh.V());
U += flowDirection*rUA*gragPplus;
@ -141,14 +137,9 @@ int main(int argc, char *argv[])
Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab
<< "pressure gradient = " << gradP.value() << endl;
# include "calculateAverages.H"
runTime.write();
# include "writeNaveragingSteps.H"
# include "writeGradP.H"
#include "writeGradP.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"

View File

@ -26,6 +26,7 @@ Application
coodles
Description
Compressible LES solver.
\*---------------------------------------------------------------------------*/
@ -39,15 +40,12 @@ Description
int main(int argc, char *argv[])
{
#include "setRootCase.H"
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
Info<< "\nStarting time loop\n" << endl;
@ -55,17 +53,17 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readPISOControls.H"
# include "compressibleCourantNo.H"
#include "readPISOControls.H"
#include "compressibleCourantNo.H"
# include "rhoEqn.H"
# include "UEqn.H"
#include "rhoEqn.H"
#include "UEqn.H"
// --- PISO loop
for (int corr=1; corr<=nCorr; corr++)
{
# include "hEqn.H"
# include "pEqn.H"
#include "hEqn.H"
#include "pEqn.H"
}
turbulence->correct();

View File

@ -1,14 +0,0 @@
nAveragingSteps++;
scalar nm1Coeff = scalar(nAveragingSteps - 1)/nAveragingSteps;
scalar nCoeff = 1.0/nAveragingSteps;
R += sqr(Umean);
Umean = nm1Coeff*Umean + nCoeff*U;
R = nm1Coeff*R + nCoeff*sqr(U) - sqr(Umean);
Bmean = nm1Coeff*Bmean + nCoeff*sgsModel->B();
epsilonMean = nm1Coeff*epsilonMean + nCoeff*sgsModel->epsilon();
pPrime2Mean += sqr(pMean);
pMean = nm1Coeff*pMean + nCoeff*p;
pPrime2Mean = nm1Coeff*pPrime2Mean + nCoeff*sqr(p) - sqr(pMean);

View File

@ -1,234 +0,0 @@
label nAveragingSteps = 1;
IFstream nAveragingStepsFile
(
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
);
autoPtr<volVectorField> UmeanPtr;
autoPtr<volSymmTensorField> RPtr;
autoPtr<volSymmTensorField> BmeanPtr;
autoPtr<volScalarField> epsilonMeanPtr;
autoPtr<volScalarField> pMeanPtr;
autoPtr<volScalarField> pPrime2MeanPtr;
if (nAveragingStepsFile.good())
{
nAveragingStepsFile >> nAveragingSteps;
Info<< "Reading field Umean\n" << endl;
UmeanPtr.reset
(
new volVectorField
(
IOobject
(
"Umean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
Info<< "\nReading field R\n" << endl;
RPtr.reset
(
new volSymmTensorField
(
IOobject
(
"R",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
Info<< "\nReading field Bmean\n" << endl;
BmeanPtr.reset
(
new volSymmTensorField
(
IOobject
(
"Bmean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
Info<< "\nReading field epsilonMean\n" << endl;
epsilonMeanPtr.reset
(
new volScalarField
(
IOobject
(
"epsilonMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
Info<< "Reading field pMean\n" << endl;
pMeanPtr.reset
(
new volScalarField
(
IOobject
(
"pMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
Info<< "Reading field pPrime2Mean\n" << endl;
pPrime2MeanPtr.reset
(
new volScalarField
(
IOobject
(
"pPrime2Mean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
}
else
{
Info<< "Creating field Umean\n" << endl;
UmeanPtr.reset
(
new volVectorField
(
IOobject
(
"Umean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U
)
);
Info<< "Creating field R\n" << endl;
RPtr.reset
(
new volSymmTensorField
(
IOobject
(
"R",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqr(U) - sqr(UmeanPtr())
)
);
Info<< "Creating field Bmean\n" << endl;
BmeanPtr.reset
(
new volSymmTensorField
(
IOobject
(
"Bmean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sgsModel->B()
)
);
Info<< "Creating field epsilonMean\n" << endl;
epsilonMeanPtr.reset
(
new volScalarField
(
IOobject
(
"epsilonMean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sgsModel->epsilon()
)
);
Info<< "Creating field pMean\n" << endl;
pMeanPtr.reset
(
new volScalarField
(
IOobject
(
"pMean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p
)
);
Info<< "Creating field pPrime2Mean\n" << endl;
pPrime2MeanPtr.reset
(
new volScalarField
(
IOobject
(
"pPrime2Mean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqr(p) - sqr(pMeanPtr())
)
);
}
volVectorField& Umean = UmeanPtr();
volSymmTensorField& R = RPtr();
volSymmTensorField& Bmean = BmeanPtr();
volScalarField& epsilonMean = epsilonMeanPtr();
volScalarField& pMean = pMeanPtr();
volScalarField& pPrime2Mean = pPrime2MeanPtr();

View File

@ -42,16 +42,11 @@ Description
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMeshNoClear.H"
# include "createFields.H"
# include "createAverages.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "setRootCase.H"
#include "createTime.H"
#include "createMeshNoClear.H"
#include "createFields.H"
#include "initContinuityErrs.H"
Info<< "\nStarting time loop\n" << endl;
@ -59,8 +54,8 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readPISOControls.H"
# include "CourantNo.H"
#include "readPISOControls.H"
#include "CourantNo.H"
sgsModel->correct();
@ -76,9 +71,7 @@ int main(int argc, char *argv[])
solve(UEqn == -fvc::grad(p));
}
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
volScalarField rUA = 1.0/UEqn.A();
@ -113,19 +106,14 @@ int main(int argc, char *argv[])
}
}
# include "continuityErrs.H"
#include "continuityErrs.H"
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
}
# include "calculateAverages.H"
runTime.write();
# include "writeNaveragingSteps.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;

View File

@ -1,18 +0,0 @@
if (runTime.outputTime())
{
OFstream nAveragingStepsFile
(
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
);
if (nAveragingStepsFile.good())
{
nAveragingStepsFile << nAveragingSteps << endl;
}
else
{
FatalErrorIn(args.executable())
<< "Cannot open file " << nAveragingStepsFile.name()
<< abort(FatalError);
}
}

View File

@ -60,24 +60,19 @@ Description
#define divDevRhoReff divDevRhoBeff
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
# include "setRootCase.H"
# include "createTime.H"
# include "createMeshNoClear.H"
# include "readEnvironmentalProperties.H"
# include "createFields.H"
# include "readPISOControls.H"
# include "readCombustionProperties.H"
# include "createAverages.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "createTime.H"
#include "createMeshNoClear.H"
#include "readEnvironmentalProperties.H"
#include "createFields.H"
#include "readPISOControls.H"
#include "readCombustionProperties.H"
#include "initContinuityErrs.H"
Info<< "\nStarting time loop\n" << endl;
@ -85,36 +80,32 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "compressibleCourantNo.H"
#include "compressibleCourantNo.H"
# include "rhoEqn.H"
#include "rhoEqn.H"
turbulence->correct();
# include "UEqn.H"
#include "UEqn.H"
// --- PISO loop
for (int corr=1; corr<=nCorr; corr++)
{
# include "ftEqn.H"
# include "bEqn.H"
# include "huEqn.H"
# include "hEqn.H"
#include "ftEqn.H"
#include "bEqn.H"
#include "huEqn.H"
#include "hEqn.H"
if (!ign.ignited())
{
hu == h;
}
# include "pEqn.H"
#include "pEqn.H"
}
# include "calculateAverages.H"
runTime.write();
# include "writeNaveragingSteps.H"
rho = thermo->rho();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"

View File

@ -1,16 +0,0 @@
nAveragingSteps++;
scalar nm1Coeff = scalar(nAveragingSteps - 1)/nAveragingSteps;
scalar nCoeff = 1.0/nAveragingSteps;
R += sqr(Umean);
Umean = nm1Coeff*Umean + nCoeff*U;
R = nm1Coeff*R + nCoeff*sqr(U) - sqr(Umean);
pPrime2Mean += sqr(pMean);
pMean = nm1Coeff*pMean + nCoeff*p;
pPrime2Mean = nm1Coeff*pPrime2Mean + nCoeff*sqr(p) - sqr(pMean);
Tmean = nm1Coeff*Tmean + nCoeff*T;
bmean = nm1Coeff*bmean + nCoeff*b;
Ximean = nm1Coeff*Ximean + nCoeff*Xi;

View File

@ -1,229 +0,0 @@
label nAveragingSteps = 1;
IFstream nAveragingStepsFile
(
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
);
volVectorField* UmeanPtr;
volSymmTensorField* RPtr;
volScalarField* pMeanPtr;
volScalarField* pPrime2MeanPtr;
volScalarField* TmeanPtr;
volScalarField* bmeanPtr;
volScalarField* XimeanPtr;
if (nAveragingStepsFile.good())
{
nAveragingStepsFile >> nAveragingSteps;
Info << "Reading field Umean\n" << endl;
UmeanPtr = new volVectorField
(
IOobject
(
"Umean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "\nReading field R\n" << endl;
RPtr = new volSymmTensorField
(
IOobject
(
"R",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field pMean\n" << endl;
pMeanPtr = new volScalarField
(
IOobject
(
"pMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field pPrime2Mean\n" << endl;
pPrime2MeanPtr = new volScalarField
(
IOobject
(
"pPrime2Mean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info << "Reading field Tmean\n" << endl;
TmeanPtr = new volScalarField
(
IOobject
(
"Tmean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info << "Reading field bmean\n" << endl;
bmeanPtr = new volScalarField
(
IOobject
(
"bmean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info << "Reading field Ximean\n" << endl;
XimeanPtr = new volScalarField
(
IOobject
(
"Ximean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
}
else
{
Info << "Creating field Umean\n" << endl;
UmeanPtr = new volVectorField
(
IOobject
(
"Umean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U
);
Info<< "Creating field R\n" << endl;
RPtr = new volSymmTensorField
(
IOobject
(
"R",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqr(U) - sqr(*UmeanPtr)
);
Info<< "Creating field pMean\n" << endl;
pMeanPtr = new volScalarField
(
IOobject
(
"pMean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p
);
Info<< "Creating field pPrime2Mean\n" << endl;
pPrime2MeanPtr = new volScalarField
(
IOobject
(
"pPrime2Mean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqr(p) - sqr(*pMeanPtr)
);
Info << "Creating field Tmean\n" << endl;
TmeanPtr = new volScalarField
(
IOobject
(
"Tmean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
T
);
Info << "Creating field bmean\n" << endl;
bmeanPtr = new volScalarField
(
IOobject
(
"bmean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
b
);
Info << "Creating field Ximean\n" << endl;
XimeanPtr = new volScalarField
(
IOobject
(
"Ximean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
Xi
);
}
volVectorField& Umean = *UmeanPtr;
volSymmTensorField& R = *RPtr;
volScalarField& pMean = *pMeanPtr;
volScalarField& pPrime2Mean = *pPrime2MeanPtr;
volScalarField& Tmean = *TmeanPtr;
volScalarField& bmean = *bmeanPtr;
volScalarField& Ximean = *XimeanPtr;

View File

@ -1,18 +0,0 @@
if (runTime.outputTime())
{
OFstream nAveragingStepsFile
(
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
);
if (nAveragingStepsFile.good())
{
nAveragingStepsFile << nAveragingSteps << endl;
}
else
{
FatalErrorIn(args.executable())
<< "Cannot open file " << nAveragingStepsFile.name()
<< abort(FatalError);
}
}

View File

@ -26,9 +26,12 @@ Application
rhoSimpleFoam
Description
Steady-state solver for turbulent flow of compressible fluids for
Transient solver for turbulent flow of compressible fluids for
ventilation and heat-transfer.
Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
pseudo-transient simulations.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
@ -40,23 +43,20 @@ Description
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
# include "readTimeControls.H"
# include "readPIMPLEControls.H"
# include "compressibleCourantNo.H"
# include "setDeltaT.H"
#include "readTimeControls.H"
#include "readPIMPLEControls.H"
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
@ -72,13 +72,13 @@ int main(int argc, char *argv[])
int oCorr=0;
do
{
# include "UEqn.H"
# include "hEqn.H"
#include "UEqn.H"
#include "hEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
# include "pEqn.H"
#include "pEqn.H"
}
turbulence->correct();

View File

@ -27,7 +27,8 @@ Application
Description
Transient Solver for buoyant, turbulent flow of compressible fluids for
ventilation and heat-transfer.
ventilation and heat-transfer. Turbulence is modelled using a run-time
selectable compressible RAS model.
\*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,4 @@
buoyantSimpleRadiationFoam.C
EXE = $(FOAM_USER_APPBIN)/buoyantSimpleRadiationFoam

View File

@ -0,0 +1,14 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/turbulenceModels
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lbasicThermophysicalModels \
-lspecie \
-lradiation \
-lcompressibleTurbulenceModels

View File

@ -0,0 +1,12 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
- fvm::Sp(fvc::div(phi), U)
+ turbulence->divDevRhoReff(U)
);
UEqn().relax();
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);

View File

@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
buoyantSimpleRadiationFoam
Description
Steady-state solver for buoyant, turbulent flow of compressible fluids,
including radiation, for ventilation and heat-transfer.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "basicThermo.H"
#include "compressible/turbulenceModel/turbulenceModel.H"
#include "fixedGradientFvPatchFields.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readEnvironmentalProperties.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 "readSIMPLEControls.H"
pd.storePrevIter();
rho.storePrevIter();
// Pressure-velocity SIMPLE corrector
{
# include "UEqn.H"
# include "hEqn.H"
# include "pEqn.H"
}
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,93 @@
Info<< "Reading thermophysical properties\n" << endl;
autoPtr<basicThermo> thermo
(
basicThermo::New(mesh)
);
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermo->rho()
);
volScalarField& p = thermo->p();
volScalarField& h = thermo->h();
const volScalarField& T = thermo->T();
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "compressibleCreatePhi.H"
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo()
)
);
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
dimensionedScalar pRef("pRef", p.dimensions(), 1.0e5);
Info<< "Creating field pd\n" << endl;
volScalarField pd
(
IOobject
(
"pd",
runTime.timeName(),
mesh
),
p - rho*gh - pRef,
p.boundaryField().types()
);
label pdRefCell = 0;
scalar pdRefValue = 0.0;
setRefCell
(
pd,
mesh.solutionDict().subDict("SIMPLE"),
pdRefCell,
pdRefValue
);
Info<< "Creating radiation model\n" << endl;
autoPtr<radiation::radiationModel> radiation
(
radiation::radiationModel::New(T)
);
dimensionedScalar initialMass = fvc::domainIntegrate(rho);

View File

@ -0,0 +1,20 @@
{
fvScalarMatrix hEqn
(
fvm::div(phi, h)
- fvm::Sp(fvc::div(phi), h)
- fvm::laplacian(turbulence->alphaEff(), h)
==
fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p))
- p*fvc::div(phi/fvc::interpolate(rho))
+ radiation->Sh(thermo())
);
hEqn.relax();
hEqn.solve();
thermo->correct();
radiation->correct();
}

View File

@ -0,0 +1,47 @@
pd.boundaryField() ==
p.boundaryField() - rho.boundaryField()*gh.boundaryField() - pRef.value();
volScalarField rUA = 1.0/UEqn().A();
U = rUA*UEqn().H();
UEqn.clear();
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
bool closedVolume = adjustPhi(phi, U, p);
phi -= fvc::interpolate(rho*gh*rUA)*fvc::snGrad(rho)*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pdEqn
(
fvm::laplacian(rho*rUA, pd) == fvc::div(phi)
);
pdEqn.setReference(pdRefCell, pdRefValue);
pdEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pdEqn.flux();
}
}
#include "continuityErrs.H"
// Explicitly relax pressure for momentum corrector
pd.relax();
p = pd + rho*gh + pRef;
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
U.correctBoundaryConditions();
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
/fvc::domainIntegrate(thermo->psi());
}
rho = thermo->rho();
rho.relax();
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;

View File

@ -0,0 +1,13 @@
regionProperties/regionProperties.C
coupleManager/coupleManager.C
derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C
derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C
chtMultiRegionFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionFoam

View File

@ -0,0 +1,16 @@
EXE_INC = \
-Ifluid \
-Isolid \
-IregionProperties \
-IcoupleManager \
-IderivedFvPatchFields/solidWallTemperatureCoupled \
-IderivedFvPatchFields/solidWallHeatFluxTemperatureCoupled \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/turbulenceModels
EXE_LIBS = \
-lfiniteVolume \
-lbasicThermophysicalModels \
-lspecie \
-lcompressibleTurbulenceModels

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
chtMultiRegionFoam
Description
Combination of heatConductionFoam and buoyantFoam for conjugate heat
transfer between a solid region and fluid region
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "basicThermo.H"
#include "compressible/turbulenceModel/turbulenceModel.H"
#include "fixedGradientFvPatchFields.H"
#include "regionProperties.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "solveContinuityEquation.C"
#include "solveMomentumEquation.C"
#include "compressibleContinuityErrors.C"
#include "solvePressureDifferenceEquation.C"
#include "solveEnthalpyEquation.C"
#include "compressibleCourantNo.C"
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
regionProperties rp(runTime);
# include "createFluidMeshes.H"
# include "createSolidMeshes.H"
# include "createFluidFields.H"
# include "createSolidFields.H"
# include "initContinuityErrs.H"
# include "readTimeControls.H"
if (fluidRegions.size())
{
# include "compressibleMultiRegionCourantNo.H"
# include "setInitialDeltaT.H"
}
while(runTime.run())
{
# include "readTimeControls.H"
if (fluidRegions.size())
{
# include "compressibleMultiRegionCourantNo.H"
# include "setDeltaT.H"
}
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
forAll(fluidRegions, i)
{
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
# include "readFluidMultiRegionPISOControls.H"
# include "solveFluid.H"
}
forAll(solidRegions, i)
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
# include "readSolidMultiRegionPISOControls.H"
# include "solveSolid.H"
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info << "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "coupleManager.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coupleManager::coupleManager(const fvPatch& patch)
:
patch_(patch),
neighbourRegionName_("undefined-neighbourRegionName"),
neighbourPatchName_("undefined-neighbourPatchName"),
neighbourFieldName_("undefined-neighbourFieldName"),
localRegion_(patch_.boundaryMesh().mesh())
{}
Foam::coupleManager::coupleManager
(
const fvPatch& patch,
const dictionary& dict
)
:
patch_(patch),
neighbourRegionName_(dict.lookup("neighbourRegionName")),
neighbourPatchName_(dict.lookup("neighbourPatchName")),
neighbourFieldName_(dict.lookup("neighbourFieldName")),
localRegion_(patch_.boundaryMesh().mesh())
{}
Foam::coupleManager::coupleManager
(
const coupleManager& cm
)
:
patch_(cm.patch()),
neighbourRegionName_(cm.neighbourRegionName()),
neighbourPatchName_(cm.neighbourPatchName()),
neighbourFieldName_(cm.neighbourFieldName()),
localRegion_(patch_.boundaryMesh().mesh())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::coupleManager::~coupleManager()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::coupleManager::checkCouple() const
{
Info<< "neighbourRegionName_ = " << neighbourRegionName_ << endl;
Info<< "neighbourPatchName_ = " << neighbourPatchName_ << endl;
Info<< "neighbourFieldName_ = " << neighbourFieldName_ << endl;
const fvPatch& nPatch = neighbourPatch();
if (patch_.size() != nPatch.size())
{
FatalErrorIn("Foam::coupleManager::checkCouple()")
<< "Unequal patch sizes:" << nl
<< " patch name (size) = " << patch_.name()
<< "(" << patch_.size() << ")" << nl
<< " neighbour patch name (size) = "
<< nPatch.name() << "(" << patch_.size() << ")" << nl
<< abort(FatalError);
}
}
void Foam::coupleManager::coupleToObj() const
{
const fvPatch& nPatch = neighbourPatch();
OFstream obj
(
patch_.name() + "_to_" + nPatch.name() + "_couple.obj"
);
const vectorField& c1 = patch_.Cf();
const vectorField& c2 = neighbourPatch().Cf();
if (c1.size() != c2.size())
{
FatalErrorIn("coupleManager::coupleToObj() const")
<< "Coupled patches are of unequal size:" << nl
<< " patch0 = " << patch_.name()
<< "(" << patch_.size() << ")" << nl
<< " patch1 = " << nPatch.name()
<< "(" << nPatch.size() << ")" << nl
<< abort(FatalError);
}
forAll(c1, i)
{
obj << "v " << c1[i].x() << " " << c1[i].y() << " " << c1[i].z() << nl
<< "v " << c2[i].x() << " " << c2[i].y() << " " << c2[i].z() << nl
<< "l " << (2*i + 1) << " " << (2*i + 2) << endl;
}
}
void Foam::coupleManager::writeEntries(Ostream& os) const
{
os.writeKeyword("neighbourRegionName");
os << neighbourRegionName_ << token::END_STATEMENT << nl;
os.writeKeyword("neighbourPatchName");
os << neighbourPatchName_ << token::END_STATEMENT << nl;
os.writeKeyword("neighbourFieldName");
os << neighbourFieldName_ << token::END_STATEMENT << nl;
}
// ************************************************************************* //

View File

@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
coupleManager
Description
Object to handle the coupling of region patches. It can be queried to
return the neighbour information.
SourceFiles
coupleManager.C
\*---------------------------------------------------------------------------*/
#ifndef coupleManager_H
#define coupleManager_H
#include "Ostream.H"
#include "dictionary.H"
#include "fvPatch.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class coupleManager Declaration
\*---------------------------------------------------------------------------*/
class coupleManager
{
// Private data
//- Reference to the local fvPatch
const fvPatch& patch_;
//- Name of neighbour region
word neighbourRegionName_;
//- Name of patch on the neighbour region
word neighbourPatchName_;
//- Name of field on the neighbour region
word neighbourFieldName_;
//- Reference to the local region
const fvMesh& localRegion_;
// Private Member Functions
//- Disallow default bitwise copy construct
// coupleManager(const coupleManager&);
//- Disallow default bitwise assignment
void operator=(const coupleManager&);
public:
// Constructors
//- Construct from fvPatch
coupleManager(const fvPatch& patch);
//- Construct from fvPatch and dictionary
coupleManager(const fvPatch& patch, const dictionary& dict);
//- Copy constructor
coupleManager(const coupleManager& cm);
// Destructor
~coupleManager();
// Member Functions
// Access
//- Return a reference to the local patch
inline const fvPatch& patch() const;
//- Return the name of the neighbour region
inline const word& neighbourRegionName() const;
//- Return the name of the patch on the neighbour region
inline const word& neighbourPatchName() const;
//- Return the name of the field on the neighbour region
inline const word& neighbourFieldName() const;
//- Return a reference to the neighbour mesh
inline const fvMesh& neighbourRegion() const;
//- Return the neighbour patch ID
inline const label neighbourPatchID() const;
//- Return a reference to the neighbour patch
inline const fvPatch& neighbourPatch() const;
//- Return a reference to the neighbour patch field
template<class Type>
inline const fvPatchField<Type>& neighbourPatchField() const;
//- Check that the couple is valid
void checkCouple() const;
// Edit
//- Return the name of the neighbour region
word& neighbourRegionName();
//- Return the name of the patch on the neighbour region
word& neighbourPatchName();
//- Return the name of the field on the neighbour region
word& neighbourFieldName();
// Write
//- Write couple to obj file
void coupleToObj() const;
//- Write entries for patches
void writeEntries(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "coupleManagerI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
inline const Foam::fvPatch& Foam::coupleManager::patch() const
{
return patch_;
};
inline const Foam::word& Foam::coupleManager::neighbourRegionName() const
{
return neighbourRegionName_;
};
inline const Foam::word& Foam::coupleManager::neighbourPatchName() const
{
return neighbourPatchName_;
};
inline const Foam::word& Foam::coupleManager::neighbourFieldName() const
{
return neighbourFieldName_;
};
inline const Foam::fvMesh& Foam::coupleManager::neighbourRegion() const
{
return localRegion_.objectRegistry::parent()
.lookupObject<fvMesh>(neighbourRegionName_);
}
inline const Foam::label Foam::coupleManager::neighbourPatchID() const
{
return neighbourRegion().boundaryMesh().findPatchID(neighbourPatchName_);
}
inline const Foam::fvPatch& Foam::coupleManager::neighbourPatch() const
{
return neighbourRegion().boundary()[neighbourPatchID()];
}
template<class Type>
inline const Foam::fvPatchField<Type>&
Foam::coupleManager::neighbourPatchField() const
{
return neighbourPatch().lookupPatchField
<GeometricField<Type, fvPatchField, volMesh>, Type>
(neighbourFieldName_);
}
inline Foam::word& Foam::coupleManager::neighbourRegionName()
{
return neighbourRegionName_;
};
inline Foam::word& Foam::coupleManager::neighbourPatchName()
{
return neighbourPatchName_;
};
inline Foam::word& Foam::coupleManager::neighbourFieldName()
{
return neighbourFieldName_;
};
// ************************************************************************* //

View File

@ -0,0 +1,168 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "solidWallHeatFluxTemperatureFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
q_(p.size(), 0.0),
KName_("undefined-K")
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
q_(ptf.q_, mapper),
KName_(ptf.KName_)
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
q_("q", dict, p.size()),
KName_(dict.lookup("K"))
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf
)
:
fixedValueFvPatchScalarField(tppsf),
q_(tppsf.q_),
KName_(tppsf.KName_)
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(tppsf, iF),
q_(tppsf.q_),
KName_(tppsf.KName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchScalarField::autoMap(m);
q_.autoMap(m);
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
fixedValueFvPatchScalarField::rmap(ptf, addr);
const solidWallHeatFluxTemperatureFvPatchScalarField& hfptf =
refCast<const solidWallHeatFluxTemperatureFvPatchScalarField>(ptf);
q_.rmap(hfptf.q_, addr);
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const scalarField& Kw =
patch().lookupPatchField<volScalarField, scalar>(KName_);
const fvPatchScalarField& Tw = *this;
operator==(q_/(patch().deltaCoeffs()*Kw) + Tw.patchInternalField());
fixedValueFvPatchScalarField::updateCoeffs();
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::write
(
Ostream& os
) const
{
fixedValueFvPatchScalarField::write(os);
q_.writeEntry("q", os);
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
solidWallHeatFluxTemperatureFvPatchScalarField
);
}
// ************************************************************************* //

View File

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
solidWallHeatFluxTemperatureFvPatchScalarField
Description
Heat flux boundary condition for temperature on solid region
Example usage:
myWallPatch
{
type solidWallHeatFluxTemperature;
K K; // Name of K field
q uniform 1000; // Heat flux / [W/m2]
value 300.0; // Initial temperature / [K]
}
SourceFiles
solidWallHeatFluxTemperatureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef solidWallHeatFluxTemperatureFvPatchScalarField_H
#define solidWallHeatFluxTemperatureFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class solidWallHeatFluxTemperatureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class solidWallHeatFluxTemperatureFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
// Private data
//- Heat flux / [W/m2]
scalarField q_;
//- Name of thermal conductivity field
word KName_;
public:
//- Runtime type information
TypeName("solidWallHeatFluxTemperature");
// Constructors
//- Construct from patch and internal field
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// solidWallHeatFluxTemperatureFvPatchScalarField
// onto a new patch
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new solidWallHeatFluxTemperatureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&,
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 solidWallHeatFluxTemperatureFvPatchScalarField(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// 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&
);
// I-O
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "solidWallTemperatureCoupledFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(p, iF),
coupleManager_(p),
KName_("undefined-K")
{}
Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const solidWallHeatFluxTemperatureCoupledFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
coupleManager_(ptf.coupleManager_),
KName_(ptf.KName_)
{}
Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchScalarField(p, iF),
coupleManager_(p, dict),
KName_(dict.lookup("K"))
{
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
evaluate();
}
}
Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const solidWallHeatFluxTemperatureCoupledFvPatchScalarField& whftcsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(whftcsf, iF),
coupleManager_(whftcsf.coupleManager_),
KName_(whftcsf.KName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const fvPatchField<scalar>& neighbourField =
coupleManager_.neighbourPatchField<scalar>();
const fvPatchField<scalar>& K =
patch().lookupPatchField<volScalarField, scalar>(KName_);
gradient() = refCast<const solidWallTemperatureCoupledFvPatchScalarField>
(neighbourField).flux()/K;
fixedGradientFvPatchScalarField::updateCoeffs();
}
void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchScalarField::write(os);
coupleManager_.writeEntries(os);
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
);
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,165 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
Description
Fixed heat-flux boundary condition for temperature, to be used by the
conjugate heat transfer solver.
Example usage:
myInterfacePatchName
{
type solidWallHeatFluxTemperatureCoupled;
neighbourRegionName fluid;
neighbourPatchName fluidSolidInterface;
neighbourFieldName T;
K K;
value uniform 300;
}
SourceFiles
solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef solidWallHeatFluxTemperatureCoupledFvPatchScalarField_H
#define solidWallHeatFluxTemperatureCoupledFvPatchScalarField_H
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
#include "coupleManager.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class solidWallHeatFluxTemperatureCoupledFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class solidWallHeatFluxTemperatureCoupledFvPatchScalarField
:
public fixedGradientFvPatchScalarField
{
// Private data
//- Couple manager object
coupleManager coupleManager_;
//- Name of thermal conductivity field
word KName_;
public:
//- Runtime type information
TypeName("solidWallHeatFluxTemperatureCoupled");
// Constructors
//- Construct from patch and internal field
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// solidWallHeatFluxTemperatureCoupledFvPatchScalarField
// onto a new patch
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const solidWallHeatFluxTemperatureCoupledFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
const solidWallHeatFluxTemperatureCoupledFvPatchScalarField&,
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 solidWallHeatFluxTemperatureCoupledFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,156 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "solidWallTemperatureCoupledFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidWallTemperatureCoupledFvPatchScalarField::
solidWallTemperatureCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
coupleManager_(p),
KName_("undefined-K")
{}
Foam::solidWallTemperatureCoupledFvPatchScalarField::
solidWallTemperatureCoupledFvPatchScalarField
(
const solidWallTemperatureCoupledFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
coupleManager_(ptf.coupleManager_),
KName_(ptf.KName_)
{}
Foam::solidWallTemperatureCoupledFvPatchScalarField::
solidWallTemperatureCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF),
coupleManager_(p, dict),
KName_(dict.lookup("K"))
{
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
evaluate();
}
}
Foam::solidWallTemperatureCoupledFvPatchScalarField::
solidWallTemperatureCoupledFvPatchScalarField
(
const solidWallTemperatureCoupledFvPatchScalarField& wtcsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wtcsf, iF),
coupleManager_(wtcsf.coupleManager_),
KName_(wtcsf.KName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidWallTemperatureCoupledFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const fvPatchField<scalar>& neighbourField =
coupleManager_.neighbourPatchField<scalar>();
operator==(neighbourField);
fixedValueFvPatchScalarField::updateCoeffs();
}
void Foam::solidWallTemperatureCoupledFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchScalarField::write(os);
coupleManager_.writeEntries(os);
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
Foam::tmp<Foam::scalarField>
Foam::solidWallTemperatureCoupledFvPatchScalarField::flux() const
{
const fvPatchScalarField& Kw =
patch().lookupPatchField<volScalarField, scalar>(KName_);
const fvPatchScalarField& Tw = *this;
return Tw.snGrad()*patch().magSf()*Kw;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
solidWallTemperatureCoupledFvPatchScalarField
);
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,160 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
solidWallHeatFluxCoupledFvPatchScalarField
Description
Fixed value boundary condition for temperature, to be used by the
conjugate heat transfer solver.
Example usage:
myInterfacePatchName
{
type solidWallTemperatureCoupled;
neighbourRegionName fluid;
neighbourPatchName fluidSolidInterface;
neighbourFieldName T;
K K;
value uniform 300;
}
SourceFiles
solidWallTemperatureCoupledFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef solidWallTemperatureCoupledFvPatchScalarField_H
#define solidWallTemperatureCoupledFvPatchScalarField_H
#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
#include "coupleManager.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class solidWallTemperatureCoupledFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class solidWallTemperatureCoupledFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
// Private data
//- Couple manager object
coupleManager coupleManager_;
//- Name of thermal conductivity field
word KName_;
public:
//- Runtime type information
TypeName("solidWallTemperatureCoupled");
// Constructors
//- Construct from patch and internal field
solidWallTemperatureCoupledFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
solidWallTemperatureCoupledFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given solidWallTemperatureCoupledFvPatchScalarField
// onto a new patch
solidWallTemperatureCoupledFvPatchScalarField
(
const solidWallTemperatureCoupledFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new solidWallTemperatureCoupledFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
solidWallTemperatureCoupledFvPatchScalarField
(
const solidWallTemperatureCoupledFvPatchScalarField&,
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 solidWallTemperatureCoupledFvPatchScalarField(*this, iF)
);
}
// Member functions
//- Flux
tmp<scalarField> flux() const;
//- 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,10 @@
tmp<fvVectorMatrix> UEqn = solveMomentumEquation
(
momentumPredictor,
Uf[i],
rhof[i],
phif[i],
pdf[i],
ghf[i],
turb[i]
);

View File

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Continuity errors for fluid meshes
\*---------------------------------------------------------------------------*/
void compressibleContinuityErrors
(
scalar& cumulativeContErr,
const volScalarField& rho,
const basicThermo& thermo
)
{
dimensionedScalar totalMass = fvc::domainIntegrate(rho);
scalar sumLocalContErr =
(
fvc::domainIntegrate(mag(rho - thermo.rho()))/totalMass
).value();
scalar globalContErr =
(
fvc::domainIntegrate(rho - thermo.rho())/totalMass
).value();
cumulativeContErr += globalContErr;
const word& regionName = rho.mesh().name();
Info<< "time step continuity errors (" << regionName << ")"
<< ": sum local = " << sumLocalContErr
<< ", global = " << globalContErr
<< ", cumulative = " << cumulativeContErr
<< endl;
}

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Calculates and outputs the mean and maximum Courant Numbers for the fluid
regions
\*---------------------------------------------------------------------------*/
scalar compressibleCourantNo
(
const fvMesh& mesh,
const Time& runTime,
const volScalarField& rho,
const surfaceScalarField& phi
)
{
scalar CoNum = 0.0;
scalar meanCoNum = 0.0;
if (mesh.nInternalFaces())
{
surfaceScalarField SfUfbyDelta =
mesh.surfaceInterpolation::deltaCoeffs()
* mag(phi)
/ fvc::interpolate(rho);
CoNum = max(SfUfbyDelta/mesh.magSf())
.value()*runTime.deltaT().value();
meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf()))
.value()*runTime.deltaT().value();
}
Info<< "Region: " << mesh.name() << " Courant Number mean: " << meanCoNum
<< " max: " << CoNum << endl;
return CoNum;
}
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
scalar CoNum = -GREAT;
forAll(fluidRegions, regionI)
{
CoNum = max
(
compressibleCourantNo
(
fluidRegions[regionI],
runTime,
rhof[regionI],
phif[regionI]
),
CoNum
);
}

View File

@ -0,0 +1,181 @@
// Initialise fluid field pointer lists
PtrList<basicThermo> thermof(fluidRegions.size());
PtrList<volScalarField> rhof(fluidRegions.size());
PtrList<volScalarField> Kf(fluidRegions.size());
PtrList<volVectorField> Uf(fluidRegions.size());
PtrList<surfaceScalarField> phif(fluidRegions.size());
PtrList<compressible::turbulenceModel> turb(fluidRegions.size());
PtrList<volScalarField> DpDtf(fluidRegions.size());
PtrList<volScalarField> ghf(fluidRegions.size());
PtrList<volScalarField> pdf(fluidRegions.size());
List<scalar> initialMassf(fluidRegions.size());
dimensionedScalar pRef("pRef", dimensionSet(1, -1, -2, 0, 0), 1.0E5);
// Populate fluid field pointer lists
forAll(fluidRegions, i)
{
Info<< "*** Reading fluid mesh thermophysical properties for region "
<< fluidRegions[i].name() << nl << endl;
Info<< " Adding to pdf\n" << endl;
pdf.set
(
i,
new volScalarField
(
IOobject
(
"pd",
runTime.timeName(),
fluidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
fluidRegions[i]
)
);
Info<< " Adding to thermof\n" << endl;
thermof.set
(
i,
autoPtr<basicThermo>
(
basicThermo::New(fluidRegions[i])
).ptr()
);
Info<< " Adding to rhof\n" << endl;
rhof.set
(
i,
new volScalarField
(
IOobject
(
"rho",
runTime.timeName(),
fluidRegions[i],
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
thermof[i].rho()
)
);
Info<< " Adding to Kf\n" << endl;
Kf.set
(
i,
new volScalarField
(
IOobject
(
"K",
runTime.timeName(),
fluidRegions[i],
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermof[i].rho()*thermof[i].Cp()*thermof[i].alpha()
)
);
Info<< " Adding to Uf\n" << endl;
Uf.set
(
i,
new volVectorField
(
IOobject
(
"U",
runTime.timeName(),
fluidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
fluidRegions[i]
)
);
Info<< " Adding to phif\n" << endl;
phif.set
(
i,
new surfaceScalarField
(
IOobject
(
"phi",
runTime.timeName(),
fluidRegions[i],
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(rhof[i]*Uf[i])
& fluidRegions[i].Sf()
)
);
Info<< " Adding to turb\n" << endl;
turb.set
(
i,
autoPtr<compressible::turbulenceModel>
(
compressible::turbulenceModel::New
(
rhof[i],
Uf[i],
phif[i],
thermof[i]
)
).ptr()
);
Info<< " Adding to DpDtf\n" << endl;
DpDtf.set
(
i,
new volScalarField
(
fvc::DDt
(
surfaceScalarField
(
"phiU",
phif[i]/fvc::interpolate(rhof[i])
),
thermof[i].p()
)
)
);
const dictionary& environmentalProperties =
fluidRegions[i].lookupObject<IOdictionary>
("environmentalProperties");
dimensionedVector g(environmentalProperties.lookup("g"));
Info<< " Adding to ghf\n" << endl;
ghf.set
(
i,
new volScalarField
(
"gh",
g & fluidRegions[i].C()
)
);
Info<< " Updating p from pd\n" << endl;
thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef;
initialMassf[i] = fvc::domainIntegrate(rhof[i]).value();
}

View File

@ -0,0 +1,45 @@
PtrList<fvMesh> fluidRegions(rp.fluidRegionNames().size());
forAll(rp.fluidRegionNames(), i)
{
Info<< "Create fluid mesh for region " << rp.fluidRegionNames()[i]
<< " for time = " << runTime.timeName() << nl << endl;
fluidRegions.set
(
i,
new fvMesh
(
IOobject
(
rp.fluidRegionNames()[i],
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
// Force calculation of geometric properties to prevent it being done
// later in e.g. some boundary evaluation
//(void)fluidRegions[i].weights();
//(void)fluidRegions[i].deltaCoeffs();
// Attach environmental properties to each region
autoPtr<IOdictionary> environmentalProperties
(
new IOdictionary
(
IOobject
(
"environmentalProperties",
runTime.constant(),
fluidRegions[i],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
environmentalProperties.ptr()->store();
}

View File

@ -0,0 +1,9 @@
solveEnthalpyEquation
(
rhof[i],
DpDtf[i],
phif[i],
turb[i],
thermof[i]
);

View File

@ -0,0 +1,66 @@
{
bool closedVolume = false;
//pdf[i].boundaryField() ==
// thermof[i].p().boundaryField()
// - rhof[i].boundaryField()*ghf[i].boundaryField()
// - pRef.value();
rhof[i] = thermof[i].rho();
volScalarField rUA = 1.0/UEqn().A();
Uf[i] = rUA*UEqn().H();
phif[i] =
fvc::interpolate(rhof[i])
*(
(fvc::interpolate(Uf[i]) & fluidRegions[i].Sf())
// + fvc::ddtPhiCorr(rUA, rhof[i], Uf[i], phif[i])
)
- fvc::interpolate(rhof[i]*rUA*ghf[i])
*fvc::snGrad(rhof[i])
*fluidRegions[i].magSf();
// Solve pressure difference
# include "pdEqn.H"
// Solve continuity
# include "rhoEqn.H"
// Update pressure field (including bc)
thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef;
DpDtf[i] = fvc::DDt
(
surfaceScalarField("phiU", phif[i]/fvc::interpolate(rhof[i])),
thermof[i].p()
);
// Update continuity errors
compressibleContinuityErrors(cumulativeContErr, rhof[i], thermof[i]);
// Correct velocity field
Uf[i] -= rUA*(fvc::grad(pdf[i]) + fvc::grad(rhof[i])*ghf[i]);
Uf[i].correctBoundaryConditions();
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{
thermof[i].p() +=
(
dimensionedScalar
(
"massIni",
dimMass,
initialMassf[i]
)
- fvc::domainIntegrate(thermof[i].psi()*thermof[i].p())
)
/fvc::domainIntegrate(thermof[i].psi());
rhof[i] = thermof[i].rho();
}
// Update thermal conductivity
Kf[i] = rhof[i]*thermof[i].Cp()*turb[i].alphaEff();
}

View File

@ -0,0 +1,14 @@
solvePressureDifferenceEquation
(
corr,
nCorr,
nNonOrthCorr,
closedVolume,
pdf[i],
pRef,
rhof[i],
thermof[i].psi(),
rUA,
ghf[i],
phif[i]
);

View File

@ -0,0 +1,27 @@
dictionary piso = fluidRegions[i].solutionDict().subDict("PISO");
int nCorr(readInt(piso.lookup("nCorrectors")));
int nNonOrthCorr = 0;
if (piso.found("nNonOrthogonalCorrectors"))
{
nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors"));
}
bool momentumPredictor = true;
if (piso.found("momentumPredictor"))
{
momentumPredictor = Switch(piso.lookup("momentumPredictor"));
}
bool transonic = false;
if (piso.found("transonic"))
{
transonic = Switch(piso.lookup("transonic"));
}
int nOuterCorr = 1;
if (piso.found("nOuterCorrectors"))
{
nOuterCorr = readInt(piso.lookup("nOuterCorrectors"));
}

View File

@ -0,0 +1 @@
solveContinuityEquation(rhof[i], phif[i]);

View File

@ -0,0 +1,15 @@
if (adjustTimeStep)
{
if (CoNum > SMALL)
{
runTime.setDeltaT
(
min
(
maxCo*runTime.deltaT().value()/CoNum,
maxDeltaT
)
);
}
}

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve continuity equation
\*---------------------------------------------------------------------------*/
void solveContinuityEquation
(
volScalarField& rho,
const surfaceScalarField& phi
)
{
solve(fvm::ddt(rho) + fvc::div(phi));
}

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve enthalpy equation
\*---------------------------------------------------------------------------*/
void solveEnthalpyEquation
(
const volScalarField& rho,
const volScalarField& DpDt,
const surfaceScalarField& phi,
const compressible::turbulenceModel& turb,
basicThermo& thermo
)
{
volScalarField& h = thermo.h();
tmp<fvScalarMatrix> hEqn
(
fvm::ddt(rho, h)
+ fvm::div(phi, h)
- fvm::laplacian(turb.alphaEff(), h)
==
DpDt
);
hEqn().relax();
hEqn().solve();
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
<< endl;
}

View File

@ -0,0 +1,15 @@
# include "rhoEqn.H"
for (int ocorr=0; ocorr<nOuterCorr; ocorr++)
{
# include "UEqn.H"
# include "hEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
# include "pEqn.H"
}
}
turb[i].correct();

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve momentum equation and return matrix for use in pressure equation
\*---------------------------------------------------------------------------*/
tmp<fvVectorMatrix> solveMomentumEquation
(
const bool momentumPredictor,
volVectorField& U,
const volScalarField& rho,
const surfaceScalarField& phi,
const volScalarField& pd,
const volScalarField& gh,
const compressible::turbulenceModel& turb
)
{
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
+ turb.divDevRhoReff(U)
);
UEqn().relax();
if (momentumPredictor)
{
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);
}
return UEqn;
}

View File

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve pressure difference equation
\*---------------------------------------------------------------------------*/
void solvePressureDifferenceEquation
(
const label corr,
const label nCorr,
const label nNonOrthCorr,
bool& closedVolume,
volScalarField& pd,
const dimensionedScalar& pRef,
const volScalarField& rho,
const volScalarField& psi,
const volScalarField& rUA,
const volScalarField& gh,
surfaceScalarField& phi
)
{
closedVolume = pd.needReference();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pdEqn
(
fvm::ddt(psi, pd)
+ fvc::ddt(psi)*pRef
+ fvc::ddt(psi, rho)*gh
+ fvc::div(phi)
- fvm::laplacian(rho*rUA, pd)
);
//pdEqn.solve();
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
{
pdEqn.solve(pd.mesh().solver(pd.name() + "Final"));
}
else
{
pdEqn.solve(pd.mesh().solver(pd.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi += pdEqn.flux();
}
}
}

View File

@ -0,0 +1,69 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "regionProperties.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regionProperties::regionProperties(const Time& runTime)
:
IOdictionary
(
IOobject
(
"regionProperties",
runTime.time().constant(),
runTime.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
fluidRegionNames_(lookup("fluidRegionNames")),
solidRegionNames_(lookup("solidRegionNames"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regionProperties::~regionProperties()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::List<Foam::word>& Foam::regionProperties::fluidRegionNames() const
{
return fluidRegionNames_;
}
const Foam::List<Foam::word>& Foam::regionProperties::solidRegionNames() const
{
return solidRegionNames_;
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
regionProperties
Description
Simple class to hold region information for coupled region simulations
SourceFiles
regionProperties.C
\*---------------------------------------------------------------------------*/
#ifndef regionProperties_H
#define regionProperties_H
#include "IOdictionary.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class regionProperties Declaration
\*---------------------------------------------------------------------------*/
class regionProperties
:
public IOdictionary
{
// Private data
//- List of the fluid region names
List<word> fluidRegionNames_;
//- List of the solid region names
List<word> solidRegionNames_;
// Private Member Functions
//- Disallow default bitwise copy construct
regionProperties(const regionProperties&);
//- Disallow default bitwise assignment
void operator=(const regionProperties&);
public:
// Constructors
//- Construct from components
regionProperties(const Time& runTime);
// Destructor
~regionProperties();
// Member Functions
// Access
//- Return const reference to the list of fluid region names
const List<word>& fluidRegionNames() const;
//- Return const reference to the list of solid region names
const List<word>& solidRegionNames() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,91 @@
// Initialise solid field pointer lists
PtrList<volScalarField> rhos(solidRegions.size());
PtrList<volScalarField> cps(solidRegions.size());
PtrList<volScalarField> rhosCps(solidRegions.size());
PtrList<volScalarField> Ks(solidRegions.size());
PtrList<volScalarField> Ts(solidRegions.size());
// Populate solid field pointer lists
forAll(solidRegions, i)
{
Info<< "*** Reading solid mesh thermophysical properties for region "
<< solidRegions[i].name() << nl << endl;
Info<< " Adding to rhos\n" << endl;
rhos.set
(
i,
new volScalarField
(
IOobject
(
"rho",
runTime.timeName(),
solidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
solidRegions[i]
)
);
Info<< " Adding to cps\n" << endl;
cps.set
(
i,
new volScalarField
(
IOobject
(
"cp",
runTime.timeName(),
solidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
solidRegions[i]
)
);
rhosCps.set
(
i,
new volScalarField("rhosCps", rhos[i]*cps[i])
);
Info<< " Adding to Ks\n" << endl;
Ks.set
(
i,
new volScalarField
(
IOobject
(
"K",
runTime.timeName(),
solidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
solidRegions[i]
)
);
Info<< " Adding to Ts\n" << endl;
Ts.set
(
i,
new volScalarField
(
IOobject
(
"T",
runTime.timeName(),
solidRegions[i],
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
solidRegions[i]
)
);
}

View File

@ -0,0 +1,27 @@
PtrList<fvMesh> solidRegions(rp.solidRegionNames().size());
forAll(rp.solidRegionNames(), i)
{
Info<< "Create solid mesh for region " << rp.solidRegionNames()[i]
<< " for time = " << runTime.timeName() << nl << endl;
solidRegions.set
(
i,
new fvMesh
(
IOobject
(
rp.solidRegionNames()[i],
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
// Force calculation of geometric properties to prevent it being done
// later in e.g. some boundary evaluation
//(void)solidRegions[i].weights();
//(void)solidRegions[i].deltaCoeffs();
}

View File

@ -0,0 +1,7 @@
dictionary piso = solidRegions[i].solutionDict().subDict("PISO");
int nNonOrthCorr = 0;
if (piso.found("nNonOrthogonalCorrectors"))
{
nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors"));
}

View File

@ -0,0 +1,9 @@
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
solve
(
fvm::ddt(rhosCps[i], Ts[i]) - fvm::laplacian(Ks[i], Ts[i])
);
}
}

View File

@ -27,7 +27,8 @@ Application
Description
Transient Solver for buoyant, turbulent flow of compressible fluids for
ventilation and heat-transfer.
ventilation and heat-transfer. Turbulence is modelled using a run-time
selectable compressible LES model.
\*---------------------------------------------------------------------------*/

View File

@ -75,6 +75,9 @@ int main(int argc, char *argv[])
# include "correctPhi.H"
}
// Keep the absolute fluxes for use in ddtPhiCorr
surfaceScalarField phiAbs("phiAbs", phi);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
@ -95,7 +98,11 @@ int main(int argc, char *argv[])
U = rAU*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf());
//+ fvc::ddtPhiCorr(rAU, U, phi);
if (ddtPhiCorr)
{
phi += fvc::ddtPhiCorr(rAU, U, phiAbs);
}
adjustPhi(phi, U, p);
@ -116,7 +123,7 @@ int main(int argc, char *argv[])
{
pEqn.solve(mesh.solver(p.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();

View File

@ -1,8 +0,0 @@
cavitatingFoam.C
compressibilityModels/compressibilityModel/compressibilityModel.C
compressibilityModels/compressibilityModel/newCompressibilityModel.C
compressibilityModels/linear/linear.C
compressibilityModels/Wallis/Wallis.C
compressibilityModels/Chung/Chung.C
EXE = $(FOAM_APPBIN)/cavitatingFoam

View File

@ -1,6 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-IcompressibilityModels/compressibilityModel
EXE_LIBS = \
-lfiniteVolume

View File

@ -1,16 +0,0 @@
surfaceScalarField gammaf = fvc::interpolate(gamma);
surfaceScalarField muf("muf", gammaf*muv + (1.0 - gammaf)*mul);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(muf, U)
//- (fvc::grad(U) & fvc::grad(muf))
- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}

View File

@ -1,23 +0,0 @@
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar mul
(
transportProperties.lookup("mul")
);
dimensionedScalar muv
(
transportProperties.lookup("muv")
);

View File

@ -0,0 +1,3 @@
compressibleLesInterFoam.C
EXE = $(FOAM_USER_APPBIN)/compressibleLesInterFoam

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)/LESmodels \
-I$(LIB_SRC)/LESmodels/LESdeltas/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-linterfaceProperties \
-lincompressibleTransportModels \
-lincompressibleLESmodels \
-lfiniteVolume

View File

@ -0,0 +1,29 @@
surfaceScalarField muf =
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs());
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())))
);
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, 1.0)
);
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.cGamma()*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,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 is modelled using a run-time
selectable incompressible LES model.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "MULES.H"
#include "subCycle.H"
#include "interfaceProperties.H"
#include "twoPhaseMixture.H"
#include "incompressible/LESmodel/LESmodel.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;
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, 0.0001);
// Construct interface from alpha1 distribution
interfaceProperties interface(alpha1, U, twoPhaseProperties);
// Construct LES model
autoPtr<LESmodel> turbulence
(
LESmodel::New(U, phi, twoPhaseProperties)
);

View File

@ -0,0 +1,71 @@
{
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, 0.0)*(psi1/rho1) + max(alpha2, 0.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

@ -46,18 +46,17 @@ Description
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createDynamicFvMesh.H"
# include "readEnvironmentalProperties.H"
# include "readPISOControls.H"
# include "initContinuityErrs.H"
# include "createFields.H"
# include "readTimeControls.H"
# include "correctPhi.H"
# include "CourantNo.H"
# include "setInitialDeltaT.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "readEnvironmentalProperties.H"
#include "readPISOControls.H"
#include "initContinuityErrs.H"
#include "createFields.H"
#include "readTimeControls.H"
#include "correctPhi.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -65,17 +64,17 @@ int main(int argc, char *argv[])
while (runTime.run())
{
# include "readControls.H"
# include "CourantNo.H"
#include "readControls.H"
#include "CourantNo.H"
# include "setDeltaT.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
// Make the fluxes absolute
if (mesh.changing() && correctPhi)
if (mesh.changing())
{
fvc::makeAbsolute(phi, U);
}
@ -97,33 +96,36 @@ int main(int argc, char *argv[])
if (mesh.changing() && correctPhi)
{
# include "correctPhi.H"
#include "correctPhi.H"
}
// Keep the absolute fluxes for use in ddtPhiCorr
surfaceScalarField phiAbs("phiAbs", phi);
// Make the fluxes relative to the mesh motion
if (mesh.changing() && correctPhi)
if (mesh.changing())
{
fvc::makeRelative(phi, U);
}
if (mesh.changing() && checkMeshCourantNo)
{
# include "meshCourantNo.H"
#include "meshCourantNo.H"
}
twoPhaseProperties.correct();
# include "gammaEqnSubCycle.H"
#include "gammaEqnSubCycle.H"
# include "UEqn.H"
#include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
# include "pEqn.H"
#include "pEqn.H"
}
# include "continuityErrs.H"
#include "continuityErrs.H"
p = pd + rho*gh;

View File

@ -5,12 +5,12 @@
volVectorField HU = UEqn.H();
U = rAU*HU;
surfaceScalarField phiU
(
"phiU",
(fvc::interpolate(U) & mesh.Sf())
//+ fvc::ddtPhiCorr(rAU, rho, U, phiAbs)
);
surfaceScalarField phiU("phiU", (fvc::interpolate(U) & mesh.Sf()));
if (ddtPhiCorr)
{
phiU += fvc::ddtPhiCorr(rAU, rho, U, phiAbs);
}
phi = phiU +
(

View File

@ -45,7 +45,7 @@
Info<< "Reading transportProperties\n" << endl;
twoPhaseMixture twoPhaseProperties(U, phi, "gamma");
const dimensionedScalar& rho1 = twoPhaseProperties.rho1();
const dimensionedScalar& rho2 = twoPhaseProperties.rho2();
@ -83,14 +83,29 @@
);
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pd + rho*gh
);
label pdRefCell = 0;
scalar pdRefValue = 0.0;
setRefCell(pd, mesh.solutionDict().subDict("PISO"), pdRefCell, pdRefValue);
Info<< "Calculating field g.h\n" << endl;
surfaceScalarField ghf("gh", g & mesh.Cf());
// Construct interface from gamma distribution
interfaceProperties interface(gamma, U, twoPhaseProperties);

View File

@ -45,18 +45,17 @@ Description
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readEnvironmentalProperties.H"
# include "readPISOControls.H"
# include "initContinuityErrs.H"
# include "createFields.H"
# include "readTimeControls.H"
# include "correctPhi.H"
# include "CourantNo.H"
# include "setInitialDeltaT.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "readEnvironmentalProperties.H"
#include "readPISOControls.H"
#include "initContinuityErrs.H"
#include "createFields.H"
#include "readTimeControls.H"
#include "correctPhi.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -64,10 +63,10 @@ int main(int argc, char *argv[])
while (runTime.run())
{
# include "readPISOControls.H"
# include "readTimeControls.H"
# include "CourantNo.H"
# include "setDeltaT.H"
#include "readPISOControls.H"
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
@ -75,17 +74,19 @@ int main(int argc, char *argv[])
twoPhaseProperties.correct();
# include "gammaEqnSubCycle.H"
#include "gammaEqnSubCycle.H"
# include "UEqn.H"
#include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
# include "pEqn.H"
#include "pEqn.H"
}
# include "continuityErrs.H"
#include "continuityErrs.H"
p = pd + rho*gh;
runTime.write();

View File

@ -0,0 +1,5 @@
lesCavitatingFoam.C
devOneEqEddy/devOneEqEddy.C
EXE = $(FOAM_APPBIN)/lesCavitatingFoam

View File

@ -0,0 +1,16 @@
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)/LESmodels \
-I$(LIB_SRC)/LESmodels/incompressible/lnInclude \
-I$(LIB_SRC)/LESmodels/LESdeltas/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude
EXE_LIBS = \
-lincompressibleTransportModels \
-lincompressibleLESmodels \
-lfiniteVolume \
-lbarotropicCompressibilityModel

View File

@ -0,0 +1,20 @@
surfaceScalarField muEff
(
"muEff",
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs())
);
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()))
);
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}

View File

@ -40,11 +40,12 @@
gamma.oldTime();
Info<< "Creating compressibilityModel\n" << endl;
autoPtr<compressibilityModel> psiModel = compressibilityModel::New
(
thermodynamicProperties,
gamma
);
autoPtr<barotropicCompressibilityModel> psiModel =
barotropicCompressibilityModel::New
(
thermodynamicProperties,
gamma
);
const volScalarField& psi = psiModel->psi();
@ -72,3 +73,13 @@
# include "createPhiv.H"
# include "compressibleCreatePhi.H"
Info<< "Reading transportProperties\n" << endl;
twoPhaseMixture twoPhaseProperties(U, phiv, "gamma");
// Create LES model
autoPtr<LESmodel> turbulence
(
LESmodel::New(U, phiv, twoPhaseProperties)
);

View File

@ -0,0 +1,118 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "devOneEqEddy.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace LESmodels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(devOneEqEddy, 0);
addToRunTimeSelectionTable(LESmodel, devOneEqEddy, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
devOneEqEddy::devOneEqEddy
(
const volVectorField& U,
const surfaceScalarField& phi,
transportModel& transport
)
:
LESmodel(typeName, U, phi, transport),
GenEddyVisc(U, phi, transport),
k_
(
IOobject
(
"k",
runTime_.timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
ck_(LESmodelProperties().lookup("ck"))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void devOneEqEddy::correct(const tmp<volTensorField>& gradU)
{
GenEddyVisc::correct(gradU);
//volScalarField G = 2*nuSgs_*magSqr(symm(gradU));
volScalarField G = 2*nuSgs_*(gradU() && dev(symm(gradU())));
solve
(
fvm::ddt(k_)
+ fvm::div(phi(), k_)
- fvm::Sp(fvc::div(phi()), k_)
- fvm::laplacian(DkEff(), k_)
==
G
- fvm::Sp(ce_*sqrt(k_)/delta(), k_)
);
bound(k_, k0());
nuSgs_ = ck_*sqrt(k_)*delta();
nuSgs_.correctBoundaryConditions();
}
bool devOneEqEddy::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().lookup("ck") >> ck_;
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESmodels
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
devOneEqEddy
Description
<pre>
One Equation Eddy Viscosity Model
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eddy viscosity SGS model using a modeled balance equation to simulate the
behaviour of k, hence,
d/dt(k) + div(U*k) - div(nuEff*grad(k))
=
-B*L - ce*k^3/2/delta
and
B = 2/3*k*I - 2*nuEff*dev(D)
where
D = symm(grad(U));
nuSgs = ck*sqrt(k)*delta
nuEff = nuSgs + nu
</pre>
SourceFiles
devOneEqEddy.C
\*---------------------------------------------------------------------------*/
#ifndef devOneEqEddy_H
#define devOneEqEddy_H
#include "GenEddyVisc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace LESmodels
{
/*---------------------------------------------------------------------------*\
Class devOneEqEddy Declaration
\*---------------------------------------------------------------------------*/
class devOneEqEddy
:
public GenEddyVisc
{
// Private data
volScalarField k_;
dimensionedScalar ck_;
// Private Member Functions
// Disallow default bitwise copy construct and assignment
devOneEqEddy(const devOneEqEddy&);
devOneEqEddy& operator=(const devOneEqEddy&);
public:
//- Runtime type information
TypeName("devOneEqEddy");
// Constructors
//- Constructor from components
devOneEqEddy
(
const volVectorField& U,
const surfaceScalarField& phi,
transportModel& transport
);
// Destructor
~devOneEqEddy()
{}
// Member Functions
//- Return SGS kinetic energy
tmp<volScalarField> k() const
{
return k_;
}
//- Return the effective diffusivity for k
tmp<volScalarField> DkEff() const
{
return tmp<volScalarField>
(
new volScalarField("DkEff", nuSgs_ + nu())
);
}
//- Correct Eddy-Viscosity and related properties
void correct(const tmp<volTensorField>& gradU);
//- Read turbulenceProperties dictionary
bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESmodels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,14 +23,17 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
cavitatingFoam
lesCavitatingFoam
Description
Transient cavitation code with LES turbulence.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "compressibilityModel.H"
#include "barotropicCompressibilityModel.H"
#include "twoPhaseMixture.H"
#include "incompressible/LESmodel/LESmodel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -42,7 +45,6 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createMesh.H"
# include "readThermodynamicProperties.H"
# include "readTransportProperties.H"
# include "readControls.H"
# include "createFields.H"
# include "initContinuityErrs.H"
@ -62,6 +64,8 @@ int main(int argc, char *argv[])
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
turbulence->correct();
for (int outerCorr=0; outerCorr<nOuterCorr; outerCorr++)
{
# include "rhoEqn.H"

View File

@ -1,14 +1,17 @@
surfaceScalarField muf =
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs());
surfaceScalarField muEff
(
"muEff",
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs())
);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(rhoPhi, U)
- fvm::laplacian(muf, U)
- (fvc::grad(U) & fvc::grad(muf))
//- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
- fvm::laplacian(muEff, U)
- (fvc::grad(U) & fvc::grad(muEff))
//- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)

View File

@ -44,7 +44,7 @@
Info<< "Reading transportProperties\n" << endl;
twoPhaseMixture twoPhaseProperties(U, phi, "gamma");
const dimensionedScalar& rho1 = twoPhaseProperties.rho1();
const dimensionedScalar& rho2 = twoPhaseProperties.rho2();
@ -87,9 +87,24 @@
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pd + rho*gh
);
// Construct interface from gamma distribution
interfaceProperties interface(gamma, U, twoPhaseProperties);

View File

@ -26,8 +26,11 @@ Application
lesInterFoam
Description
Solver for 2 incompressible fluids capturing the interface. Turbulence is
modelled using a runtime selectable incompressible LES model.
Solver for 2 incompressible, 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 is modelled using a run-time
selectable incompressible LES model.
\*---------------------------------------------------------------------------*/
@ -38,28 +41,21 @@ Description
#include "twoPhaseMixture.H"
#include "incompressible/LESmodel/LESmodel.H"
#include "IFstream.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readEnvironmentalProperties.H"
# include "readPISOControls.H"
# include "initContinuityErrs.H"
# include "createFields.H"
//# include "createAverages.H"
# include "readTimeControls.H"
# include "correctPhi.H"
# include "CourantNo.H"
# include "setInitialDeltaT.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "readEnvironmentalProperties.H"
#include "readPISOControls.H"
#include "initContinuityErrs.H"
#include "createFields.H"
#include "readTimeControls.H"
#include "correctPhi.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,31 +63,29 @@ int main(int argc, char *argv[])
while (runTime.run())
{
# include "readPISOControls.H"
# include "readTimeControls.H"
# include "CourantNo.H"
# include "setDeltaT.H"
#include "readPISOControls.H"
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "gammaEqnSubCycle.H"
#include "gammaEqnSubCycle.H"
turbulence->correct();
# include "UEqn.H"
#include "UEqn.H"
// --- PISO loop
for (int corr=0; corr < nCorr; corr++)
{
# include "pEqn.H"
#include "pEqn.H"
}
# include "continuityErrs.H"
//# include "calculateAverages.H"
#include "continuityErrs.H"
runTime.write();
//# include "writeNaveragingSteps.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 @@
rasCavitatingFoam.C
EXE = $(FOAM_APPBIN)/rasCavitatingFoam

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 \
-I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude
EXE_LIBS = \
-lincompressibleTransportModels \
-lincompressibleTurbulenceModels \
-lfiniteVolume \
-lbarotropicCompressibilityModel

View File

@ -0,0 +1,20 @@
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()))
);
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}

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 RAS turbulence model
autoPtr<turbulenceModel> turbulence
(
turbulenceModel::New(U, phiv, twoPhaseProperties)
);

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