OLD: pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); pEqn.solve(mesh.solver("Yi")); NEW: pEqn.solve(p.select(piso.finalInnerIter())); pEqn.solve("Yi");
143 lines
4.0 KiB
C
143 lines
4.0 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | www.openfoam.com
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
-------------------------------------------------------------------------------
|
|
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
|
|
nonNewtonianIcoFoam
|
|
|
|
Group
|
|
grpIncompressibleSolvers
|
|
|
|
Description
|
|
Transient solver for incompressible, laminar flow of non-Newtonian fluids.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "fvCFD.H"
|
|
#include "singlePhaseTransportModel.H"
|
|
#include "pisoControl.H"
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
argList::addNote
|
|
(
|
|
"Transient solver for incompressible laminar flow"
|
|
" of non-Newtonian fluids."
|
|
);
|
|
|
|
#include "postProcess.H"
|
|
|
|
#include "addCheckCaseOptions.H"
|
|
#include "setRootCaseLists.H"
|
|
#include "createTime.H"
|
|
#include "createMeshNoClear.H"
|
|
#include "createControl.H"
|
|
#include "createFields.H"
|
|
#include "initContinuityErrs.H"
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
Info<< "\nStarting time loop\n" << endl;
|
|
|
|
while (runTime.loop())
|
|
{
|
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
|
|
|
#include "CourantNo.H"
|
|
|
|
fluid.correct();
|
|
|
|
// Momentum predictor
|
|
|
|
fvVectorMatrix UEqn
|
|
(
|
|
fvm::ddt(U)
|
|
+ fvm::div(phi, U)
|
|
- fvm::laplacian(fluid.nu(), U)
|
|
- (fvc::grad(U) & fvc::grad(fluid.nu()))
|
|
);
|
|
|
|
if (piso.momentumPredictor())
|
|
{
|
|
solve(UEqn == -fvc::grad(p));
|
|
}
|
|
|
|
// --- PISO loop
|
|
while (piso.correct())
|
|
{
|
|
volScalarField rAU(1.0/UEqn.A());
|
|
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
|
|
surfaceScalarField phiHbyA
|
|
(
|
|
"phiHbyA",
|
|
fvc::flux(HbyA)
|
|
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
|
|
);
|
|
|
|
adjustPhi(phiHbyA, U, p);
|
|
|
|
// Update the pressure BCs to ensure flux consistency
|
|
constrainPressure(p, U, phiHbyA, rAU);
|
|
|
|
// Non-orthogonal pressure corrector loop
|
|
while (piso.correctNonOrthogonal())
|
|
{
|
|
// Pressure corrector
|
|
|
|
fvScalarMatrix pEqn
|
|
(
|
|
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
|
|
);
|
|
|
|
pEqn.setReference(pRefCell, pRefValue);
|
|
|
|
pEqn.solve(p.select(piso.finalInnerIter()));
|
|
|
|
if (piso.finalNonOrthogonalIter())
|
|
{
|
|
phi = phiHbyA - pEqn.flux();
|
|
}
|
|
}
|
|
|
|
#include "continuityErrs.H"
|
|
|
|
U = HbyA - rAU*fvc::grad(p);
|
|
U.correctBoundaryConditions();
|
|
}
|
|
|
|
runTime.write();
|
|
|
|
runTime.printExecutionTime(Info);
|
|
}
|
|
|
|
Info<< "End\n" << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|