2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
|
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
|
|
\\ / O peration |
|
|
|
|
\\ / A nd | Copyright held by original author
|
|
|
|
\\/ 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
|
2010-08-26 14:22:03 +00:00
|
|
|
pimpleDyMFoam.C
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
Description
|
2010-08-26 14:22:03 +00:00
|
|
|
Transient solver for incompressible, flow of Newtonian fluids
|
|
|
|
on a moving mesh using the PIMPLE (merged PISO-SIMPLE) algorithm.
|
|
|
|
|
|
|
|
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "fvCFD.H"
|
2010-08-26 14:22:03 +00:00
|
|
|
#include "singlePhaseTransportModel.H"
|
|
|
|
#include "turbulenceModel.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
#include "dynamicFvMesh.H"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
# include "setRootCase.H"
|
|
|
|
|
|
|
|
# include "createTime.H"
|
|
|
|
# include "createDynamicFvMesh.H"
|
2010-08-26 14:22:03 +00:00
|
|
|
# include "readPIMPLEControls.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
# include "initContinuityErrs.H"
|
|
|
|
# include "createFields.H"
|
|
|
|
# include "readTimeControls.H"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
Info<< "\nStarting time loop\n" << endl;
|
|
|
|
|
|
|
|
while (runTime.run())
|
|
|
|
{
|
|
|
|
# include "readControls.H"
|
|
|
|
# include "CourantNo.H"
|
|
|
|
|
|
|
|
// Make the fluxes absolute
|
|
|
|
fvc::makeAbsolute(phi, U);
|
|
|
|
|
|
|
|
# include "setDeltaT.H"
|
|
|
|
|
|
|
|
runTime++;
|
|
|
|
|
|
|
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
|
|
|
|
|
|
|
bool meshChanged = mesh.update();
|
2011-02-27 02:17:43 +00:00
|
|
|
reduce(meshChanged, orOp<bool>());
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2011-02-27 02:17:43 +00:00
|
|
|
if (correctPhi && meshChanged)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
# include "correctPhi.H"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make the fluxes relative to the mesh motion
|
|
|
|
fvc::makeRelative(phi, U);
|
|
|
|
|
2011-02-27 02:17:43 +00:00
|
|
|
if (checkMeshCourantNo)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
# include "meshCourantNo.H"
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- PIMPLE loop
|
|
|
|
for (int ocorr=0; ocorr<nOuterCorr; ocorr++)
|
|
|
|
{
|
2010-08-26 14:22:03 +00:00
|
|
|
if (nOuterCorr != 1)
|
|
|
|
{
|
|
|
|
p.storePrevIter();
|
|
|
|
}
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
# include "UEqn.H"
|
|
|
|
|
|
|
|
// --- PISO loop
|
|
|
|
for (int corr=0; corr<nCorr; corr++)
|
|
|
|
{
|
|
|
|
rAU = 1.0/UEqn.A();
|
|
|
|
|
|
|
|
U = rAU*UEqn.H();
|
|
|
|
phi = (fvc::interpolate(U) & mesh.Sf());
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
if (p.needReference())
|
|
|
|
{
|
|
|
|
fvc::makeRelative(phi, U);
|
|
|
|
adjustPhi(phi, U, p);
|
|
|
|
fvc::makeAbsolute(phi, U);
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
|
|
|
{
|
|
|
|
fvScalarMatrix pEqn
|
|
|
|
(
|
|
|
|
fvm::laplacian(rAU, p) == fvc::div(phi)
|
|
|
|
);
|
|
|
|
|
|
|
|
pEqn.setReference(pRefCell, pRefValue);
|
|
|
|
|
|
|
|
if
|
|
|
|
(
|
|
|
|
ocorr == nOuterCorr-1
|
|
|
|
&& corr == nCorr-1
|
|
|
|
&& nonOrth == nNonOrthCorr
|
|
|
|
)
|
|
|
|
{
|
|
|
|
pEqn.solve(mesh.solver(p.name() + "Final"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pEqn.solve(mesh.solver(p.name()));
|
|
|
|
}
|
2010-08-26 14:22:03 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
if (nonOrth == nNonOrthCorr)
|
|
|
|
{
|
|
|
|
phi -= pEqn.flux();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# include "continuityErrs.H"
|
|
|
|
|
|
|
|
// Explicitly relax pressure for momentum corrector
|
|
|
|
if (ocorr != nOuterCorr-1)
|
|
|
|
{
|
|
|
|
p.relax();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make the fluxes relative to the mesh motion
|
|
|
|
fvc::makeRelative(phi, U);
|
|
|
|
|
|
|
|
U -= rAU*fvc::grad(p);
|
|
|
|
U.correctBoundaryConditions();
|
|
|
|
}
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
turbulence->correct();
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
runTime.write();
|
|
|
|
|
|
|
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
|
|
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
|
|
|
<< nl << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
Info<< "End\n" << endl;
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
return 0;
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|