mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: solver and tutorial using baffles
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
buoyantBaffleSimpleFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/buoyantBaffleSimpleFoam
|
||||
@ -0,0 +1,19 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/cfdTools \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
|
||||
-I$(LIB_SRC)/regionModels/thermoBaffleModels/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lbasicThermophysicalModels \
|
||||
-lspecie \
|
||||
-lcompressibleTurbulenceModel \
|
||||
-lcompressibleRASModels \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-lthermoBaffleModels
|
||||
@ -0,0 +1,25 @@
|
||||
// Solve the Momentum equation
|
||||
|
||||
tmp<fvVectorMatrix> UEqn
|
||||
(
|
||||
fvm::div(phi, U)
|
||||
+ turbulence->divDevRhoReff(U)
|
||||
);
|
||||
|
||||
UEqn().relax();
|
||||
|
||||
if (simple.momentumPredictor())
|
||||
{
|
||||
solve
|
||||
(
|
||||
UEqn()
|
||||
==
|
||||
fvc::reconstruct
|
||||
(
|
||||
(
|
||||
- ghf*fvc::snGrad(rho)
|
||||
- fvc::snGrad(p_rgh)
|
||||
)*mesh.magSf()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
buoyantBaffleSimpleFoam
|
||||
|
||||
Description
|
||||
Steady-state solver for buoyant, turbulent flow of compressible fluids
|
||||
using thermal baffles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "basicPsiThermo.H"
|
||||
#include "RASModel.H"
|
||||
#include "fixedGradientFvPatchFields.H"
|
||||
#include "simpleControl.H"
|
||||
#include "thermoBaffleModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "readGravitationalAcceleration.H"
|
||||
#include "createFields.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
simpleControl simple(mesh);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (simple.loop())
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
p_rgh.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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,94 @@
|
||||
Info<< "Reading thermophysical properties\n" << endl;
|
||||
|
||||
autoPtr<basicPsiThermo> pThermo
|
||||
(
|
||||
basicPsiThermo::New(mesh)
|
||||
);
|
||||
basicPsiThermo& thermo = pThermo();
|
||||
|
||||
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& psi = thermo.psi();
|
||||
|
||||
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::RASModel> turbulence
|
||||
(
|
||||
compressible::RASModel::New
|
||||
(
|
||||
rho,
|
||||
U,
|
||||
phi,
|
||||
thermo
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Info<< "Calculating field g.h\n" << endl;
|
||||
volScalarField gh("gh", g & mesh.C());
|
||||
surfaceScalarField ghf("ghf", g & mesh.Cf());
|
||||
|
||||
Info<< "Reading field p_rgh\n" << endl;
|
||||
volScalarField p_rgh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"p_rgh",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
// Force p_rgh to be consistent with p
|
||||
p_rgh = p - rho*gh;
|
||||
|
||||
|
||||
label pRefCell = 0;
|
||||
scalar pRefValue = 0.0;
|
||||
setRefCell
|
||||
(
|
||||
p,
|
||||
p_rgh,
|
||||
mesh.solutionDict().subDict("SIMPLE"),
|
||||
pRefCell,
|
||||
pRefValue
|
||||
);
|
||||
|
||||
autoPtr<regionModels::thermoBaffleModels::thermoBaffleModel> baffles
|
||||
(
|
||||
regionModels::thermoBaffleModels::thermoBaffleModel::New(mesh)
|
||||
);
|
||||
|
||||
dimensionedScalar initialMass = fvc::domainIntegrate(rho);
|
||||
dimensionedScalar totalVolume = sum(mesh.V());
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
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))
|
||||
);
|
||||
|
||||
hEqn.relax();
|
||||
hEqn.solve();
|
||||
|
||||
baffles->evolve();
|
||||
thermo.correct();
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
{
|
||||
rho = thermo.rho();
|
||||
rho.relax();
|
||||
|
||||
volScalarField rAU(1.0/UEqn().A());
|
||||
surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU));
|
||||
|
||||
U = rAU*UEqn().H();
|
||||
UEqn.clear();
|
||||
|
||||
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
|
||||
bool closedVolume = adjustPhi(phi, U, p_rgh);
|
||||
|
||||
surfaceScalarField buoyancyPhi(rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf());
|
||||
phi -= buoyancyPhi;
|
||||
|
||||
for (int nonOrth=0; nonOrth<=simple.nNonOrthCorr(); nonOrth++)
|
||||
{
|
||||
fvScalarMatrix p_rghEqn
|
||||
(
|
||||
fvm::laplacian(rhorAUf, p_rgh) == fvc::div(phi)
|
||||
);
|
||||
|
||||
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
|
||||
p_rghEqn.solve();
|
||||
|
||||
if (nonOrth == simple.nNonOrthCorr())
|
||||
{
|
||||
// Calculate the conservative fluxes
|
||||
phi -= p_rghEqn.flux();
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
p_rgh.relax();
|
||||
|
||||
// Correct the momentum source with the pressure gradient flux
|
||||
// calculated from the relaxed pressure
|
||||
U -= rAU*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rhorAUf);
|
||||
U.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
|
||||
#include "continuityErrs.H"
|
||||
|
||||
p = p_rgh + rho*gh;
|
||||
|
||||
// For closed-volume cases adjust the pressure level
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
p += (initialMass - fvc::domainIntegrate(psi*p))
|
||||
/fvc::domainIntegrate(psi);
|
||||
p_rgh = p - rho*gh;
|
||||
}
|
||||
|
||||
rho = thermo.rho();
|
||||
rho.relax();
|
||||
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value()
|
||||
<< endl;
|
||||
}
|
||||
Reference in New Issue
Block a user