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"
|
2013-11-20 15:05:20 +00:00
|
|
|
# include "CourantNo.H"
|
|
|
|
# include "setDeltaT.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// Make the fluxes absolute
|
|
|
|
fvc::makeAbsolute(phi, U);
|
|
|
|
|
|
|
|
runTime++;
|
|
|
|
|
|
|
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
|
|
|
|
|
|
|
bool meshChanged = mesh.update();
|
|
|
|
|
2013-11-20 15:05:20 +00:00
|
|
|
# include "volContinuity.H"
|
|
|
|
|
|
|
|
if (checkMeshCourantNo)
|
|
|
|
{
|
|
|
|
# include "meshCourantNo.H"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mesh motion update
|
2011-02-27 02:17:43 +00:00
|
|
|
if (correctPhi && meshChanged)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
# include "correctPhi.H"
|
|
|
|
}
|
|
|
|
|
2013-11-20 15:05:20 +00:00
|
|
|
if (meshChanged)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2013-11-20 15:05:20 +00:00
|
|
|
# include "CourantNo.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2013-11-20 15:05:20 +00:00
|
|
|
// Make the fluxes relative to the mesh motion
|
|
|
|
fvc::makeRelative(phi, U);
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
// --- PIMPLE loop
|
2013-11-20 15:05:20 +00:00
|
|
|
label oCorr = 0;
|
|
|
|
do
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
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
|
2011-10-12 10:41:39 +00:00
|
|
|
for (int corr = 0; corr < nCorr; corr++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
rAU = 1.0/UEqn.A();
|
|
|
|
|
|
|
|
U = rAU*UEqn.H();
|
|
|
|
phi = (fvc::interpolate(U) & mesh.Sf());
|
2013-11-20 15:05:20 +00:00
|
|
|
// ddtPhiCorr does not work. HJ, 20/Nov/2013
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-11-20 15:05:20 +00:00
|
|
|
adjustPhi(phi, U, p);
|
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
|
|
|
|
(
|
2013-11-20 15:05:20 +00:00
|
|
|
// oCorr == nOuterCorr - 1
|
|
|
|
corr == nCorr - 1
|
2010-05-12 13:27:55 +00:00
|
|
|
&& nonOrth == nNonOrthCorr
|
|
|
|
)
|
|
|
|
{
|
2011-08-14 16:39:59 +00:00
|
|
|
pEqn.solve
|
|
|
|
(
|
|
|
|
mesh.solutionDict().solver(p.name() + "Final")
|
|
|
|
);
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-14 16:39:59 +00:00
|
|
|
pEqn.solve(mesh.solutionDict().solver(p.name()));
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
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
|
2013-11-20 15:05:20 +00:00
|
|
|
if (oCorr != nOuterCorr - 1)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
p.relax();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make the fluxes relative to the mesh motion
|
|
|
|
fvc::makeRelative(phi, U);
|
|
|
|
|
2013-11-20 15:05:20 +00:00
|
|
|
# include "movingMeshContinuityErrs.H"
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
U -= rAU*fvc::grad(p);
|
|
|
|
U.correctBoundaryConditions();
|
|
|
|
}
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
turbulence->correct();
|
2013-11-20 15:05:20 +00:00
|
|
|
} while (++oCorr < nOuterCorr);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|