上海交通大学船舶海洋与建筑工程学院谢彬Numerical TESTs for PDEs解答5.2.2
/*---------------------------------------------------------------------------*\
License
Changed from OpenFoam 7 icoFoam to nse521Foam
Application
nse522Foam
Description
Designed for solving Numerical TESTs for PDEs 5.2.2.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "pisoControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
pisoControl piso(mesh);
#include "createFields.H"
#include "initContinuityErrs.H"
scalar my_Re = 0;
scalar my_U = 1;
scalar my_a = 1;
scalar my_nu = mag(nu).value();
my_Re = my_U*my_a/my_nu;
scalar my_tmp = 0;
scalar minLength = 100;
forAll(U,celli)
{
my_tmp = mesh.V()[celli];
if (minLength>=my_tmp)
{
minLength = my_tmp;
}
else {}
}
// using std::pow;
// minLength = pow(minLength,1/3);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "CourantNo.H"
// Momentum predictor
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
volScalarField p_ex(p); // measure previous p
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();
if (piso.finalNonOrthogonalIter())
{
phi = phiHbyA - pEqn.flux();
}
}
#include "continuityErrs.H"
U = HbyA - rAU*fvc::grad(p);
U.correctBoundaryConditions();
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
Info<< "Re = " << my_Re << endl;
In

本文介绍了谢彬教授在船舶海洋与建筑工程学院针对NumericalTESTs for PDEs 5.2.2章节的详细解答,涉及PDE求解的PISO算法、边界条件处理及压力修正过程。
最低0.47元/天 解锁文章
1605

被折叠的 条评论
为什么被折叠?



