/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 . Application icoFoam Group grpIncompressibleSolvers Description Transient solver for incompressible, laminar flow of Newtonian fluids. \heading Solver details The solver uses the PISO algorithm to solve the continuity equation: \f[ \div \vec{U} = 0 \f] and momentum equation: \f[ \ddt{\vec{U}} + \div \left( \vec{U} \vec{U} \right) - \div \left(\nu \grad \vec{U} \right) = - \grad p \f] Where: \vartable \vec{U} | Velocity p | Pressure \endvartable \heading Required fields \plaintable U | Velocity [m/s] p | Kinematic pressure, p/rho [m2/s2] \endplaintable \*---------------------------------------------------------------------------*/ #include "gpufvCFD.H" #include "pisoControl.H" #include struct my_timer { struct timeval start_time, end_time; double time_use; void start() { gettimeofday(&start_time, NULL); } void stop() { gettimeofday(&end_time, NULL); time_use = (end_time.tv_sec - start_time.tv_sec) + (double)(end_time.tv_usec - start_time.tv_usec)/1000000.0; } }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { my_timer tm; tm.start(); argList::addNote ( "Transient solver for incompressible, laminar flow" " of Newtonian fluids." ); #include "gpupostProcess.H" #include "addCheckCaseOptions.H" #include "setRootCaseLists.H" #include "createTime.H" #include "gpucreateMesh.H" pisoControl piso(mesh); #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; my_timer tm1; tm1.start(); #include "gpuCourantNo.H" // Momentum predictor gpufvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) ); if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop while (piso.correct()) { volScalargpuField rAU(1.0/UEqn.A()); volVectorgpuField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); surfaceScalargpuField 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 gpufvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); if (piso.finalNonOrthogonalIter()) { phi = phiHbyA - pEqn.flux(); } } #include "gpucontinuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); runTime.printExecutionTime(Info); tm1.stop(); Info<<"------Time Step = "<