From 25908eb4fc2245a707e6eab18810b94d4401ab6d Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Tue, 10 Feb 2015 13:47:18 +0000 Subject: [PATCH] pimpleControl and pisoControl: Rationalize PISO and PIMPLE control --- applications/solvers/DNS/dnsFoam/dnsFoam.C | 13 +-- .../electromagnetics/mhdFoam/createFields.H | 2 +- .../electromagnetics/mhdFoam/mhdFoam.C | 47 ++++++---- .../incompressible/icoFoam/createFields.H | 2 +- .../nonNewtonianIcoFoam/createFields.H | 2 +- .../incompressible/pisoFoam/createFields.H | 2 +- .../incompressible/pisoFoam/pisoFoam.C | 27 ++---- src/finiteVolume/Make/files | 1 + .../pimpleControl/pimpleControl.C | 6 +- .../pimpleControl/pimpleControl.H | 25 +++--- .../solutionControl/pisoControl/pisoControl.C | 50 +++++++++++ .../solutionControl/pisoControl/pisoControl.H | 86 +++++++++++++++++++ 12 files changed, 203 insertions(+), 60 deletions(-) create mode 100644 src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C create mode 100644 src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.H diff --git a/applications/solvers/DNS/dnsFoam/dnsFoam.C b/applications/solvers/DNS/dnsFoam/dnsFoam.C index 865af56184b..38c5b7be8f0 100644 --- a/applications/solvers/DNS/dnsFoam/dnsFoam.C +++ b/applications/solvers/DNS/dnsFoam/dnsFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,6 +35,7 @@ Description #include "fft.H" #include "calcEk.H" #include "graph.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,6 +45,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMeshNoClear.H" + + pisoControl piso(mesh); + #include "readTransportProperties.H" #include "createFields.H" #include "readTurbulenceProperties.H" @@ -57,8 +61,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - #include "readPISOControls.H" - force.internalField() = ReImSum ( fft::reverseTransform @@ -82,8 +84,7 @@ int main(int argc, char *argv[]) // --- PISO loop - - for (int corr=1; corr<=1; corr++) + while (piso.correct()) { volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); @@ -102,7 +103,7 @@ int main(int argc, char *argv[]) fvm::laplacian(rAUf, p) == fvc::div(phiHbyA) ); - pEqn.solve(); + pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); phi = phiHbyA - pEqn.flux(); diff --git a/applications/solvers/electromagnetics/mhdFoam/createFields.H b/applications/solvers/electromagnetics/mhdFoam/createFields.H index fb5a0049322..a514f114160 100644 --- a/applications/solvers/electromagnetics/mhdFoam/createFields.H +++ b/applications/solvers/electromagnetics/mhdFoam/createFields.H @@ -104,4 +104,4 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); diff --git a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C index e9dedef5a93..c9cb0242bd1 100644 --- a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C +++ b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,7 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "OSspecific.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,6 +59,10 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" + + pisoControl piso(mesh); + pisoControl bpiso(mesh, "BPISO"); + #include "createFields.H" #include "initContinuityErrs.H" @@ -68,9 +72,6 @@ int main(int argc, char *argv[]) while (runTime.loop()) { - #include "readPISOControls.H" - #include "readBPISOControls.H" - Info<< "Time = " << runTime.timeName() << nl << endl; #include "CourantNo.H" @@ -85,12 +86,14 @@ int main(int argc, char *argv[]) + fvc::grad(DBU*magSqr(B)) ); - solve(UEqn == -fvc::grad(p)); + if (piso.momentumPredictor()) + { + solve(UEqn == -fvc::grad(p)); + } // --- PISO loop - - for (int corr=0; corr<nCorr; corr++) + while (piso.correct()) { volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); @@ -105,7 +108,7 @@ int main(int argc, char *argv[]) + rAUf*fvc::ddtCorr(U, phi) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -113,9 +116,9 @@ int main(int argc, char *argv[]) ); pEqn.setReference(pRefCell, pRefValue); - pEqn.solve(); + pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi = phiHbyA - pEqn.flux(); } @@ -129,8 +132,7 @@ int main(int argc, char *argv[]) } // --- B-PISO loop - - for (int Bcorr=0; Bcorr<nBcorr; Bcorr++) + while (bpiso.correct()) { fvVectorMatrix BEqn ( @@ -148,13 +150,20 @@ int main(int argc, char *argv[]) phiB = (fvc::interpolate(B) & mesh.Sf()) + rABf*fvc::ddtCorr(B, phiB); - fvScalarMatrix pBEqn - ( - fvm::laplacian(rABf, pB) == fvc::div(phiB) - ); - pBEqn.solve(); + while (bpiso.correctNonOrthogonal()) + { + fvScalarMatrix pBEqn + ( + fvm::laplacian(rABf, pB) == fvc::div(phiB) + ); - phiB -= pBEqn.flux(); + pBEqn.solve(mesh.solver(pB.select(bpiso.finalInnerIter()))); + + if (bpiso.finalNonOrthogonalIter()) + { + phiB -= pBEqn.flux(); + } + } #include "magneticFieldErr.H" } diff --git a/applications/solvers/incompressible/icoFoam/createFields.H b/applications/solvers/incompressible/icoFoam/createFields.H index 02093c39386..438c67ea29f 100644 --- a/applications/solvers/incompressible/icoFoam/createFields.H +++ b/applications/solvers/incompressible/icoFoam/createFields.H @@ -52,4 +52,4 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); diff --git a/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H b/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H index ef08e58c7d1..ea10104b916 100644 --- a/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H +++ b/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H @@ -36,4 +36,4 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); diff --git a/applications/solvers/incompressible/pisoFoam/createFields.H b/applications/solvers/incompressible/pisoFoam/createFields.H index 85f9ce4793c..c89520fdafe 100644 --- a/applications/solvers/incompressible/pisoFoam/createFields.H +++ b/applications/solvers/incompressible/pisoFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/incompressible/pisoFoam/pisoFoam.C b/applications/solvers/incompressible/pisoFoam/pisoFoam.C index b812418fd6a..e068306470f 100644 --- a/applications/solvers/incompressible/pisoFoam/pisoFoam.C +++ b/applications/solvers/incompressible/pisoFoam/pisoFoam.C @@ -34,6 +34,7 @@ Description #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "turbulentTransportModel.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,6 +44,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" + + pisoControl piso(mesh); + #include "createFields.H" #include "initContinuityErrs.H" @@ -54,7 +58,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - #include "readPISOControls.H" #include "CourantNo.H" // Pressure-velocity PISO corrector @@ -70,14 +73,13 @@ int main(int argc, char *argv[]) UEqn.relax(); - if (momentumPredictor) + if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop - - for (int corr=0; corr<nCorr; corr++) + while (piso.correct()) { volScalarField rAU(1.0/UEqn.A()); @@ -93,7 +95,7 @@ int main(int argc, char *argv[]) adjustPhi(phiHbyA, U, p); // Non-orthogonal pressure corrector loop - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { // Pressure corrector @@ -104,20 +106,9 @@ int main(int argc, char *argv[]) pEqn.setReference(pRefCell, pRefValue); - if - ( - corr == nCorr-1 - && nonOrth == nNonOrthCorr - ) - { - pEqn.solve(mesh.solver("pFinal")); - } - else - { - pEqn.solve(); - } + pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi = phiHbyA - pEqn.flux(); } diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 5543c83aee1..8fc75e0656b 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -397,6 +397,7 @@ solutionControl = $(general)/solutionControl $(solutionControl)/solutionControl/solutionControl.C $(solutionControl)/simpleControl/simpleControl.C $(solutionControl)/pimpleControl/pimpleControl.C +$(solutionControl)/pisoControl/pisoControl.C porosity = $(general)/porosityModel $(porosity)/porosityModel/porosityModel.C diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C index 8329580bffb..d49421fa40e 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -120,9 +120,9 @@ bool Foam::pimpleControl::criteriaSatisfied() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::pimpleControl::pimpleControl(fvMesh& mesh) +Foam::pimpleControl::pimpleControl(fvMesh& mesh, const word& dictName) : - solutionControl(mesh, "PIMPLE"), + solutionControl(mesh, dictName), nCorrPIMPLE_(0), nCorrPISO_(0), corrPISO_(0), diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H index 510e3081881..1d78752b33f 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,6 +28,9 @@ Description PIMPLE control class to supply convergence information/checks for the PIMPLE loop. + May also be used to for PISO-based algorithms as PISO controls are a + sub-set of PIMPLE controls. + \*---------------------------------------------------------------------------*/ #ifndef pimpleControl_H @@ -48,6 +51,15 @@ class pimpleControl : public solutionControl { + // Private member functions + + //- Disallow default bitwise copy construct + pimpleControl(const pimpleControl&); + + //- Disallow default bitwise assignment + void operator=(const pimpleControl&); + + protected: // Protected data @@ -78,16 +90,9 @@ protected: //- Return true if all convergence checks are satisfied virtual bool criteriaSatisfied(); - //- Disallow default bitwise copy construct - pimpleControl(const pimpleControl&); - - //- Disallow default bitwise assignment - void operator=(const pimpleControl&); - public: - // Static Data Members //- Run-time type information @@ -96,8 +101,8 @@ public: // Constructors - //- Construct from mesh - pimpleControl(fvMesh& mesh); + //- Construct from mesh and the name of control sub-dictionary + pimpleControl(fvMesh& mesh, const word& dictName="PIMPLE"); //- Destructor diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C new file mode 100644 index 00000000000..49c670b010c --- /dev/null +++ b/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ 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 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/>. + +\*---------------------------------------------------------------------------*/ + +#include "pisoControl.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(pisoControl, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pisoControl::pisoControl(fvMesh& mesh, const word& dictName) +: + pimpleControl(mesh, dictName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::pisoControl::~pisoControl() +{} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.H b/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.H new file mode 100644 index 00000000000..3d412e7406e --- /dev/null +++ b/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ 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 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/>. + +Class + Foam::pisoControl + +Description + Specialization of the pimpleControl class for PISO control. + +\*---------------------------------------------------------------------------*/ + +#ifndef pisoControl_H +#define pisoControl_H + +#include "pimpleControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class pisoControl Declaration +\*---------------------------------------------------------------------------*/ + +class pisoControl +: + public pimpleControl +{ + // Private member functions + + //- Disallow default bitwise copy construct + pisoControl(const pisoControl&); + + //- Disallow default bitwise assignment + void operator=(const pisoControl&); + + +public: + + // Static Data Members + + //- Run-time type information + TypeName("pisoControl"); + + + // Constructors + + //- Construct from mesh and the name of control sub-dictionary + pisoControl(fvMesh& mesh, const word& dictName="PISO"); + + + //- Destructor + virtual ~pisoControl(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab