From 7b1840c7d3619d5a7e9efaa4de561205476f8b42 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 14 Feb 2019 15:46:00 +0000 Subject: [PATCH 1/3] functionObjects: Added phaseScalarTransport function This is like the scalarTrasport function except that the transported scalar is confined to a single phase of a multiphase simulation. In addition to the usual specification for the scalarTransport function (i.e., a field, schemes and solution parameters), the user needs to specify the phase-flux or a pressure field which can be used to generate it. Example usage for interFoam: phaseScalarTransport1 { type phaseScalarTransport; libs ("libsolverFunctionObjects.so"); field s.water; p p_rgh; } Example usage for reactingTwoPhaseEulerFoam: phaseScalarTransport1 { type phaseScalarTransport; libs ("libsolverFunctionObjects.so"); field s.water; alphaPhi alphaRhoPhi.water; rho thermo:rho.water; } The function will write out both the per-unit-phase field that is solved for (s.water in the above examples) and also the mixture-total field (alphaS.water), which is often more convenient for post-processing. --- .../phaseScalarTransport/phaseScalarTransport | 26 + .../phaseScalarTransport.cfg | 12 + .../solvers/scalarTransport/scalarTransport | 3 +- src/functionObjects/solvers/Make/files | 1 + .../phaseScalarTransport.C | 500 ++++++++++++++++++ .../phaseScalarTransport.H | 233 ++++++++ 6 files changed, 773 insertions(+), 2 deletions(-) create mode 100644 etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport create mode 100644 etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport.cfg create mode 100644 src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C create mode 100644 src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H diff --git a/etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport b/etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport new file mode 100644 index 0000000000..dafa291177 --- /dev/null +++ b/etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport @@ -0,0 +1,26 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Solves a transport equation for a scalar field within one phase of a + multiphase simulation. + + The name of the scalar field is specified in this file. A field file of + this name will also be required, typically in the 0 directory. Scheme and + solver settings will also be needed. Alternatively, if there is another + field which already has appropriate fvSchemes and fvSolution entries, these + settings can be reused by naming the field as the schemesField. + +\*---------------------------------------------------------------------------*/ + +#includeEtc "caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport.cfg" + +field s.water; +schemesField s.water; +p p_rgh; + +// ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport.cfg b/etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport.cfg new file mode 100644 index 0000000000..b1e52d55ec --- /dev/null +++ b/etc/caseDicts/postProcessing/solvers/phaseScalarTransport/phaseScalarTransport.cfg @@ -0,0 +1,12 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ + +type phaseScalarTransport; +libs ("libsolverFunctionObjects.so"); + +// ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport index c563bcc10d..75f9581b0b 100644 --- a/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport +++ b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport @@ -14,8 +14,7 @@ Description \*---------------------------------------------------------------------------*/ -type scalarTransport; -libs ("libsolverFunctionObjects.so"); +#includeEtc "caseDicts/postProcessing/solvers/scalarTransport/scalarTransport.cfg" field s; schemesField s; diff --git a/src/functionObjects/solvers/Make/files b/src/functionObjects/solvers/Make/files index 2b8e8f8d8e..46a7a3c4a5 100644 --- a/src/functionObjects/solvers/Make/files +++ b/src/functionObjects/solvers/Make/files @@ -1,3 +1,4 @@ scalarTransport/scalarTransport.C +phaseScalarTransport/phaseScalarTransport.C LIB = $(FOAM_LIBBIN)/libsolverFunctionObjects diff --git a/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C new file mode 100644 index 0000000000..2dbdee0778 --- /dev/null +++ b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C @@ -0,0 +1,500 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2019 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 . + +\*---------------------------------------------------------------------------*/ + +#include "addToRunTimeSelectionTable.H" +#include "fixedValueFvPatchField.H" +#include "fvcDdt.H" +#include "fvcDiv.H" +#include "fvmDdt.H" +#include "fvmDiv.H" +#include "fvmLaplacian.H" +#include "nonOrthogonalSolutionControl.H" +#include "phaseScalarTransport.H" +#include "surfaceFields.H" +#include "turbulenceModel.H" +#include "wallFvPatch.H" +#include "zeroGradientFvPatchField.H" + +#define PhiDimensionErrorInFunction(phi) \ + FatalErrorInFunction \ + << "Incompatible dimensions for " << phi.name() << ": " \ + << phi.dimensions() << nl \ + << "Dimensions should be " << dimMass/dimTime << " or " \ + << dimVolume/dimTime << exit(FatalError) + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(phaseScalarTransport, 0); + + addToRunTimeSelectionTable + ( + functionObject, + phaseScalarTransport, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::volScalarField& Foam::functionObjects::phaseScalarTransport::Phi() +{ + if (!PhiPtr_.valid()) + { + const surfaceScalarField& phi = + mesh_.lookupObject(phiName_); + const volScalarField& p = + mesh_.lookupObject(pName_); + + wordList PhiPatchFieldTypes(mesh_.boundaryMesh().size()); + forAll(p.boundaryField(), patchi) + { + PhiPatchFieldTypes[patchi] = + p.boundaryField()[patchi].fixesValue() + ? fixedValueFvPatchField::typeName + : zeroGradientFvPatchField::typeName; + } + + PhiPtr_.set + ( + new volScalarField + ( + IOobject + ( + "Phi" + s_.name(), + mesh_.time().timeName(), + mesh_, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar(phi.dimensions()/dimLength, Zero), + PhiPatchFieldTypes + ) + ); + + mesh_.setFluxRequired(PhiPtr_->name()); + } + + return PhiPtr_(); +} + + +Foam::tmp +Foam::functionObjects::phaseScalarTransport::alphaPhi() +{ + // If alphaPhi exists then return it + if (mesh_.foundObject(alphaPhiName_)) + { + return mesh_.lookupObject(alphaPhiName_); + } + + // Otherwise generate it ... + Info<< type() << ": " << surfaceScalarField::typeName << " " + << alphaPhiName_ << " was not found, so generating it" << endl; + + const volScalarField& alpha = + mesh_.lookupObject(alphaName_); + const surfaceScalarField& phi = + mesh_.lookupObject(phiName_); + + // Make a crude guess of the phase flux using default interpolation + tmp tAlphaPhi + ( + new surfaceScalarField + ( + alphaPhiName_, + phi*fvc::interpolate(alpha) + ) + ); + surfaceScalarField& alphaPhi = tAlphaPhi.ref(); + + // Get the potential field + volScalarField& Phi(this->Phi()); + + // Construct the scheme names + const word laplacianScheme = "laplacian(" + pName_ + ")"; + + // Debug writing. Write the material derivative of alpha, before and after + // the solution of the potential and the correction of alphaPhi. Before + // correction the field should be non-zero, and after it should be + // comparable to the solution tolerance. + auto writeDDt = [&](const label i) + { + const volScalarField DDtAlpha + ( + "DDt(" + + IOobject::groupName + ( + IOobject::member(alpha.name()) + Foam::name(i), + IOobject::group(alpha.name()) + ) + + ")", + fvc::ddt(alpha) + fvc::div(alphaPhi) + ); + Info<< type() << ": Writing " << DDtAlpha.name() << endl; + DDtAlpha.write(); + }; + if (debug && mesh_.time().writeTime()) + { + writeDDt(0); + } + + // Construct a non-orthogonal solution control + nonOrthogonalSolutionControl control + ( + const_cast(mesh_), + mesh_.lookupObjectRef + ( + solutionControl::typeName + ) + .algorithmName() + ); + + // Solve for the potential and correct alphaPhi with the resulting flux + if (phi.dimensions() == dimVolume/dimTime) + { + while (control.correctNonOrthogonal()) + { + fvScalarMatrix PhiEqn + ( + fvm::laplacian(Phi, laplacianScheme) + + fvc::ddt(alpha) + + fvc::div(alphaPhi) + ); + + PhiEqn.solve(pName_); + + if (control.finalNonOrthogonalIter()) + { + alphaPhi += PhiEqn.flux(); + } + } + } + else if (phi.dimensions() == dimMass/dimTime) + { + const volScalarField& rho = + mesh_.lookupObject(rhoName_); + + while (control.correctNonOrthogonal()) + { + fvScalarMatrix PhiEqn + ( + fvm::laplacian(Phi, laplacianScheme) + + fvc::ddt(rho, alpha) + + fvc::div(alphaPhi) + ); + + PhiEqn.solve(pName_); + + if (control.finalNonOrthogonalIter()) + { + alphaPhi += PhiEqn.flux(); + } + } + } + else + { + PhiDimensionErrorInFunction(phi); + } + + // Debug writing + if (debug && mesh_.time().writeTime()) + { + writeDDt(1); + } + + return tAlphaPhi; +} + + +Foam::tmp +Foam::functionObjects::phaseScalarTransport::D +( + const surfaceScalarField& alphaPhi +) const +{ + if (constantD_) + { + return volScalarField::New + ( + "D" + s_.name(), + mesh_, + dimensionedScalar(alphaPhi.dimensions()/dimLength, D_) + ); + } + + const word& nameNoPhase = turbulenceModel::propertiesName; + const word namePhase = IOobject::groupName(nameNoPhase, phaseName_); + + const word& name = + mesh_.foundObject(namePhase) + ? namePhase + : mesh_.foundObject(nameNoPhase) + ? nameNoPhase + : word::null; + + if (name == word::null) + { + return volScalarField::New + ( + "D" + s_.name(), + mesh_, + dimensionedScalar(alphaPhi.dimensions()/dimLength, 0) + ); + } + + const turbulenceModel& turbulence = + mesh_.lookupObject(name); + + if (alphaPhi.dimensions() == dimVolume/dimTime) + { + return alphaD_*turbulence.nu() + alphaDt_*turbulence.nut(); + } + else if (alphaPhi.dimensions() == dimMass/dimTime) + { + return alphaD_*turbulence.mu() + alphaDt_*turbulence.mut(); + } + else + { + PhiDimensionErrorInFunction(alphaPhi); + return tmp(nullptr); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::phaseScalarTransport::phaseScalarTransport +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + fieldName_(dict.lookup("field")), + phaseName_(IOobject::group(fieldName_)), + nCorr_(0), + residualAlpha_(rootSmall), + fvOptions_(mesh_), + s_ + ( + IOobject + ( + fieldName_, + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + alphaS_ + ( + IOobject + ( + "alpha" + + word(toupper(fieldName_[0])) + + fieldName_(1, fieldName_.size() - 1), + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar(s_.dimensions(), Zero) + ), + PhiPtr_(nullptr) +{ + if (phaseName_ == word::null) + { + FatalErrorInFunction + << "Field \"" << fieldName_ << "\" does not have a phase extension " + << "in its name. If it is associated with \"phaseA\" then it " + << "should be named \"" << fieldName_ << ".phaseA\"." + << exit(FatalError); + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::phaseScalarTransport::~phaseScalarTransport() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::phaseScalarTransport::read(const dictionary& dict) +{ + fvMeshFunctionObject::read(dict); + + alphaName_ = + dict.lookupOrDefault + ( + "alpha", + IOobject::groupName("alpha", phaseName_) + ); + alphaPhiName_ = + dict.lookupOrDefault + ( + "alphaPhi", + IOobject::groupName("alphaPhi", phaseName_) + ); + phiName_ = dict.lookupOrDefault("phi", "phi"); + rhoName_ = + dict.lookupOrDefault + ( + "rho", + IOobject::groupName("rho", phaseName_) + ); + pName_ = dict.lookupOrDefault("p", "p"); + schemesField_ = dict.lookupOrDefault("schemesField", fieldName_); + + constantD_ = dict.readIfPresent("D", D_); + alphaD_ = dict.lookupOrDefault("alphaD", 1); + alphaDt_ = dict.lookupOrDefault("alphaDt", 1); + + dict.readIfPresent("nCorr", nCorr_); + dict.readIfPresent("residualAlpha", residualAlpha_); + + if (dict.found("fvOptions")) + { + fvOptions_.reset(dict.subDict("fvOptions")); + } + + return true; +} + + +bool Foam::functionObjects::phaseScalarTransport::execute() +{ + Info<< type() << ": Executing" << endl; + + const volScalarField& alpha = + mesh_.lookupObject(alphaName_); + + // Get the phase flux + tmp tAlphaPhi(this->alphaPhi()); + const surfaceScalarField& alphaPhi = tAlphaPhi(); + + // Get the diffusivity + const volScalarField D(this->D(alphaPhi)); + + // Construct the scheme names + const word divScheme = + "div(" + alphaPhi.name() + "," + schemesField_ + ")"; + const word laplacianScheme = + "laplacian(" + D.name() + "," + schemesField_ + ")"; + + // Get the relaxation coefficient + const scalar relaxCoeff = + mesh_.relaxEquation(schemesField_) + ? mesh_.equationRelaxationFactor(schemesField_) + : 0; + + // Solve + if (alphaPhi.dimensions() == dimVolume/dimTime) + { + for (label i = 0; i <= nCorr_; ++ i) + { + fvScalarMatrix fieldEqn + ( + fvm::ddt(alpha, s_) + + fvm::div(alphaPhi, s_, divScheme) + - fvm::laplacian + ( + fvc::interpolate(alpha)*fvc::interpolate(D), + s_, + laplacianScheme + ) + == + fvOptions_(alpha, s_) + - fvm::ddt(residualAlpha_, s_) + + fvc::ddt(residualAlpha_, s_) + ); + + fieldEqn.relax(relaxCoeff); + fvOptions_.constrain(fieldEqn); + fieldEqn.solve(schemesField_); + } + } + else if (alphaPhi.dimensions() == dimMass/dimTime) + { + const volScalarField& rho = + mesh_.lookupObject(rhoName_); + + for (label i = 0; i <= nCorr_; ++ i) + { + fvScalarMatrix fieldEqn + ( + fvm::ddt(alpha, rho, s_) + + fvm::div(alphaPhi, s_, divScheme) + - fvm::laplacian + ( + fvc::interpolate(alpha)*fvc::interpolate(D), + s_, + laplacianScheme + ) + == + fvOptions_(rho, s_) + - fvm::ddt(residualAlpha_*rho, s_) + + fvc::ddt(residualAlpha_*rho, s_) + ); + + fieldEqn.relax(relaxCoeff); + fvOptions_.constrain(fieldEqn); + fieldEqn.solve(schemesField_); + } + } + else + { + PhiDimensionErrorInFunction(alphaPhi); + } + + // Update + alphaS_ = alpha*s_; + + Info<< endl; + + return true; +} + + +bool Foam::functionObjects::phaseScalarTransport::write() +{ + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H new file mode 100644 index 0000000000..aff03121b3 --- /dev/null +++ b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H @@ -0,0 +1,233 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2019 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 . + +Class + Foam::functionObjects::phaseScalarTransport + +Description + Evolves a passive scalar transport equation within one phase of a + multiphase simulation. The scalar is considered to be a phase-intensive + property; i.e., its value represents an amount per-unit of the phase. In + addition to the scalar, the function also writes out the product of the + volume fraction and the scalar, as this provides a phase-extensive field + which is often more convenient to post-process. + + Most entries are the same as for the \c scalarTransport function. Refer to + its documentation for details. Entries specific to this function are + detailed below. Note that the phase-name will be determined by stripping + the extension from the supplied field name. + + If \c alphaPhi is specified and found in the database then it will be used + to transport the field. This is the likely mode of operation if this + function is used with Euler-Euler solvers, in which \c alphaPhi -like + fluxes are available. If \c alphaPhi is not found, then a pressure-like + equation will be solved in order to construct it so that it exactly matches + the time-derivative of the phase volume or mass. This is likely to be + necessary in volume-of-fluid solvers where \c alphaPhi is not part of the + solution procedure. The pressure field name will be required in this case. + +Usage + \table + Property | Description | Req'd? | Default + alpha | Name of the volume-fraction field | no \\ + | alpha. + alphaPhi | Name of the phase-flux field | no \\ + | alphaPhi. + p | Name of the pressure field | no | p + residualAlpha | Small volume fraction used to stabilise the solution \\ + | no | rootSmall + \endtable + + Example specification for interFoam: + \verbatim + phaseScalarTransport1 + { + type phaseScalarTransport; + libs ("libsolverFunctionObjects.so"); + + field s.water; + p p_rgh; + } + \endverbatim + + Example specification for reactingTwoPhaseEulerFoam: + \verbatim + phaseScalarTransport1 + { + type phaseScalarTransport; + libs ("libsolverFunctionObjects.so"); + + field s.water; + alphaPhi alphaRhoPhi.water; + rho thermo:rho.water; + } + \endverbatim + +See also + Foam::functionObjects::fvMeshFunctionObject + Foam::functionObjects::scalarTransport + +SourceFiles + phaseScalarTransport.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_phaseScalarTransport_H +#define functionObjects_phaseScalarTransport_H + +#include "fvMeshFunctionObject.H" +#include "volFields.H" +#include "fvOptionList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class phaseScalarTransport Declaration +\*---------------------------------------------------------------------------*/ + +class phaseScalarTransport +: + public fvMeshFunctionObject +{ + // Private data + + //- Name of field to process + const word fieldName_; + + //- Name of the phase in which to solve + const word phaseName_; + + //- Name of phase volume-fraction field (optional) + word alphaName_; + + //- Name of the phase flux field (optional) + word alphaPhiName_; + + //- Name of the mixture flux field (optional) + word phiName_; + + //- Name of density field (optional) + word rhoName_; + + //- Name of the pressure field (optional) + word pName_; + + //- Diffusion coefficient (optional) + scalar D_; + + //- Flag to indicate whether a constant, uniform D_ is specified + bool constantD_; + + //- Laminar diffusion coefficient (optional) + scalar alphaD_; + + //- Turbulent diffusion coefficient (optional) + scalar alphaDt_; + + //- Number of corrector iterations (optional) + label nCorr_; + + //- Residual volume-fraction + scalar residualAlpha_; + + //- Name of field whose schemes are used (optional) + word schemesField_; + + //- Run-time selectable finite volume options, e.g. sources, constraints + fv::optionList fvOptions_; + + //- The field + volScalarField s_; + + //- The field multiplied by the phase fraction + volScalarField alphaS_; + + //- Potential field used to generate the phase flux + autoPtr PhiPtr_; + + + // Private Member Functions + + //- Return the potential field used to generate the phase flux. + // Constructed on demand. + volScalarField& Phi(); + + //- Return the phase flux. Tries to look it up, and generates it if the + // lookup fails. The generation creates a crude guess for alphaPhi + // then solves a Laplacian to correct the flux to match the time + // derivative of alpha. + tmp alphaPhi(); + + //- Return the diffusivity field + tmp D(const surfaceScalarField& alphaPhi) const; + + +public: + + //- Runtime type information + TypeName("phaseScalarTransport"); + + + // Constructors + + //- Construct from Time and dictionary + phaseScalarTransport + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~phaseScalarTransport(); + + + // Member Functions + + //- Read the settings from the given dictionary + virtual bool read(const dictionary&); + + //- Solve for the evolution of the field + virtual bool execute(); + + //- Do nothing. The field is registered and written automatically. + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 111cdf3a65c2840b6b7ba7ef817b28ce30e545e3 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Mon, 11 Feb 2019 17:10:38 +0000 Subject: [PATCH 2/3] solutionControl: Renaming and improved final logic The sub-loops of the solution control are now named more consistently, with ambiguously named methods such as finalIter replaced with ones like finalPimpleIter, so that it is clear which loop they represent. In addition, the final logic has been improved so that it restores state after a sub-iteration, and so that sub-iterations can be used on their own without an outer iteration in effect. Previously, if the non-orthogonal loop were used outside of a pimple/piso iteration, the final iteration would not execute with final settings. --- .../basic/potentialFoam/potentialFoam.C | 6 +-- .../solvers/combustion/reactingFoam/pEqn.H | 2 +- .../solvers/combustion/reactingFoam/pcEqn.H | 2 +- .../rhoReactingFoam/rhoReactingFoam.C | 6 +-- .../compressible/rhoPimpleFoam/correctPhi.H | 4 +- .../solvers/compressible/rhoPimpleFoam/pEqn.H | 2 +- .../compressible/rhoPimpleFoam/pcEqn.H | 2 +- .../rhoPimpleFoam/rhoPimpleFoam.C | 6 +-- .../chtMultiRegionFoam/fluid/pEqn.H | 2 +- .../chtMultiRegionFoam/fluid/solveFluid.H | 2 +- .../pimpleFoam/SRFPimpleFoam/pEqn.H | 2 +- .../incompressible/pimpleFoam/correctPhi.H | 4 +- .../solvers/incompressible/pimpleFoam/pEqn.H | 2 +- .../incompressible/pimpleFoam/pimpleFoam.C | 4 +- .../solvers/lagrangian/DPMFoam/correctPhic.H | 4 +- .../solvers/lagrangian/sprayFoam/pEqn.H | 2 +- .../compressibleInterFoam.C | 4 +- .../compressibleInterFoam/correctPhi.H | 4 +- .../solvers/multiphase/interFoam/correctPhi.H | 4 +- .../multiphase/interFoam/initCorrectPhi.H | 4 +- .../solvers/multiphase/interFoam/interFoam.C | 4 +- .../interMixingFoam/interMixingFoam.C | 4 +- .../interPhaseChangeFoam/correctPhi.H | 4 +- .../interPhaseChangeFoam/initCorrectPhi.H | 4 +- .../interPhaseChangeFoam.C | 4 +- .../multiphaseEulerFoam/correctPhi.H | 4 +- .../multiphaseInterFoam/multiphaseInterFoam.C | 4 +- .../potentialFreeSurfaceFoam/correctPhi.H | 4 +- .../potentialFreeSurfaceFoam/pEqn.H | 2 +- .../potentialFreeSurfaceFoam.C | 4 +- .../populationBalanceModel.C | 2 +- .../moveDynamicMesh/moveDynamicMesh.C | 4 +- .../pimpleControl/pimpleControl.C | 11 ++--- .../pimpleControl/pimpleControl.H | 2 +- .../pimpleControl/pimpleControlI.H | 4 +- .../pimpleControl/pimpleLoop/pimpleLoop.C | 13 ++--- .../pimpleControl/pimpleLoop/pimpleLoop.H | 11 ++--- .../pimpleControl/pimpleLoop/pimpleLoopI.H | 22 ++++----- .../pimpleMultiRegionControl.C | 25 +++++----- .../pimpleMultiRegionControlI.H | 4 +- .../pimpleNoLoopControl/pimpleNoLoopControl.C | 14 +++++- .../pimpleNoLoopControl/pimpleNoLoopControl.H | 19 ++++++-- .../solutionControl/pisoControl/pisoControl.C | 48 ++++++------------- .../solutionControl/pisoControl/pisoControl.H | 35 +++++++------- .../pisoControl/pisoControlI.H | 22 +++++---- .../simpleControl/simpleControl.C | 8 +--- .../simpleControl/simpleControl.H | 8 +--- .../solidNoLoopControl/solidNoLoopControl.C | 14 ++++-- .../solidNoLoopControl/solidNoLoopControl.H | 26 ++++++++-- .../nonOrthogonalSolutionControl.C | 45 ++++------------- .../nonOrthogonalSolutionControl.H | 15 +++--- .../nonOrthogonalSolutionControlI.H | 16 +++++-- .../singleRegionSolutionControl.C | 19 +++++++- .../singleRegionSolutionControl.H | 9 +++- 54 files changed, 248 insertions(+), 254 deletions(-) diff --git a/applications/solvers/basic/potentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/potentialFoam.C index fe19cf0cc8..5904a31525 100644 --- a/applications/solvers/basic/potentialFoam/potentialFoam.C +++ b/applications/solvers/basic/potentialFoam/potentialFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "pisoControl.H" +#include "nonOrthogonalSolutionControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" - pisoControl potentialFlow(mesh, "potentialFlow"); + nonOrthogonalSolutionControl potentialFlow(mesh, "potentialFlow"); #include "createFields.H" diff --git a/applications/solvers/combustion/reactingFoam/pEqn.H b/applications/solvers/combustion/reactingFoam/pEqn.H index 9f8f837ee2..d16070952b 100644 --- a/applications/solvers/combustion/reactingFoam/pEqn.H +++ b/applications/solvers/combustion/reactingFoam/pEqn.H @@ -4,7 +4,7 @@ volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/combustion/reactingFoam/pcEqn.H b/applications/solvers/combustion/reactingFoam/pcEqn.H index 8d514f3a40..45f2573d39 100644 --- a/applications/solvers/combustion/reactingFoam/pcEqn.H +++ b/applications/solvers/combustion/reactingFoam/pcEqn.H @@ -4,7 +4,7 @@ volScalarField rAU(1.0/UEqn.A()); volScalarField rAtU(1.0/(1.0/rAU - UEqn.H1())); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/combustion/reactingFoam/rhoReactingFoam/rhoReactingFoam.C b/applications/solvers/combustion/reactingFoam/rhoReactingFoam/rhoReactingFoam.C index 3e67f88fe7..bb3d92dedf 100644 --- a/applications/solvers/combustion/reactingFoam/rhoReactingFoam/rhoReactingFoam.C +++ b/applications/solvers/combustion/reactingFoam/rhoReactingFoam/rhoReactingFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { // Store momentum to set rhoUf for introduced faces. autoPtr rhoU; @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) } } - if (pimple.firstIter() && !pimple.simpleRho()) + if (pimple.firstPimpleIter() && !pimple.simpleRho()) { #include "rhoEqn.H" } diff --git a/applications/solvers/compressible/rhoPimpleFoam/correctPhi.H b/applications/solvers/compressible/rhoPimpleFoam/correctPhi.H index d142a3ed66..d71739f8fb 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/correctPhi.H +++ b/applications/solvers/compressible/rhoPimpleFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -9,5 +7,5 @@ CorrectPhi psi, dimensionedScalar("rAUf", dimTime, 1), divrhoU(), - pcorrControl + pimple ); diff --git a/applications/solvers/compressible/rhoPimpleFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/pEqn.H index 9c6785109f..79c76f8c5a 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/pEqn.H @@ -11,7 +11,7 @@ volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H b/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H index 62033c1ae8..b2016bcf8b 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H @@ -11,7 +11,7 @@ volScalarField rAU(1.0/UEqn.A()); volScalarField rAtU(1.0/(1.0/rAU - UEqn.H1())); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C index fd0c922baa..9c5c2a8984 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { // Store momentum to set rhoUf for introduced faces. autoPtr rhoU; @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) } } - if (pimple.firstIter() && !pimple.simpleRho()) + if (pimple.firstPimpleIter() && !pimple.simpleRho()) { #include "rhoEqn.H" } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H index 3c5098a38e..3dd6922d4a 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H @@ -6,7 +6,7 @@ if (!mesh.steady() && !pimple.simpleRho()) volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H index f56be68e86..b543c07dde 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H @@ -24,7 +24,7 @@ else turbulence.correct(); } - if (!mesh.steady() && pimples.finalIter()) + if (!mesh.steady() && pimples.finalPimpleIter()) { rho = thermo.rho(); } diff --git a/applications/solvers/incompressible/pimpleFoam/SRFPimpleFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/SRFPimpleFoam/pEqn.H index f904075ed7..d56081ed55 100644 --- a/applications/solvers/incompressible/pimpleFoam/SRFPimpleFoam/pEqn.H +++ b/applications/solvers/incompressible/pimpleFoam/SRFPimpleFoam/pEqn.H @@ -21,7 +21,7 @@ if (pimple.consistent()) HbyA -= (rAUrel - rAtUrel())*fvc::grad(p); } -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUrelEqn.clear(); } diff --git a/applications/solvers/incompressible/pimpleFoam/correctPhi.H b/applications/solvers/incompressible/pimpleFoam/correctPhi.H index 29fe7f0180..da0ee46df6 100644 --- a/applications/solvers/incompressible/pimpleFoam/correctPhi.H +++ b/applications/solvers/incompressible/pimpleFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -7,7 +5,7 @@ CorrectPhi p, dimensionedScalar("rAUf", dimTime, 1), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/incompressible/pimpleFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/pEqn.H index fd7a4ee871..da7e5d26c8 100644 --- a/applications/solvers/incompressible/pimpleFoam/pEqn.H +++ b/applications/solvers/incompressible/pimpleFoam/pEqn.H @@ -26,7 +26,7 @@ if (pimple.consistent()) HbyA -= (rAU - rAtU())*fvc::grad(p); } -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C index af02b442b8..b970945062 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { mesh.update(); diff --git a/applications/solvers/lagrangian/DPMFoam/correctPhic.H b/applications/solvers/lagrangian/DPMFoam/correctPhic.H index 149f31122e..46ef721fa2 100644 --- a/applications/solvers/lagrangian/DPMFoam/correctPhic.H +++ b/applications/solvers/lagrangian/DPMFoam/correctPhic.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( Uc, @@ -7,7 +5,7 @@ CorrectPhi p, dimensionedScalar("rAUf", dimTime, 1), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/lagrangian/sprayFoam/pEqn.H b/applications/solvers/lagrangian/sprayFoam/pEqn.H index d006952d34..e1c09c9217 100644 --- a/applications/solvers/lagrangian/sprayFoam/pEqn.H +++ b/applications/solvers/lagrangian/sprayFoam/pEqn.H @@ -7,7 +7,7 @@ volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C index 747f0a0d5b..979c659716 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { mesh.update(); diff --git a/applications/solvers/multiphase/compressibleInterFoam/correctPhi.H b/applications/solvers/multiphase/compressibleInterFoam/correctPhi.H index aa789b72b6..79860853b8 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/correctPhi.H +++ b/applications/solvers/multiphase/compressibleInterFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -7,7 +5,7 @@ CorrectPhi p, dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1), divU, - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/correctPhi.H index c4c30431ed..fcb5020587 100644 --- a/applications/solvers/multiphase/interFoam/correctPhi.H +++ b/applications/solvers/multiphase/interFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -7,7 +5,7 @@ CorrectPhi p_rgh, surfaceScalarField("rAUf", fvc::interpolate(rAU())), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interFoam/initCorrectPhi.H b/applications/solvers/multiphase/interFoam/initCorrectPhi.H index 7dca181930..76e0646a63 100644 --- a/applications/solvers/multiphase/interFoam/initCorrectPhi.H +++ b/applications/solvers/multiphase/interFoam/initCorrectPhi.H @@ -20,8 +20,6 @@ if (correctPhi) } else { - nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -29,7 +27,7 @@ else p_rgh, dimensionedScalar(dimTime/rho.dimensions(), 1), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interFoam/interFoam.C b/applications/solvers/multiphase/interFoam/interFoam.C index 0b65af9ee1..5faf9fb85c 100644 --- a/applications/solvers/multiphase/interFoam/interFoam.C +++ b/applications/solvers/multiphase/interFoam/interFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { mesh.update(); diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C b/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C index 0ed4b33efb..93b2b7e861 100644 --- a/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C +++ b/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { mesh.update(); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H b/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H index df68d5fc0e..58b79bed40 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -7,7 +5,7 @@ CorrectPhi p_rgh, surfaceScalarField("rAUf", fvc::interpolate(rAU())), divU, - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/initCorrectPhi.H b/applications/solvers/multiphase/interPhaseChangeFoam/initCorrectPhi.H index 537dcf6e64..59b96c87a9 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/initCorrectPhi.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/initCorrectPhi.H @@ -22,8 +22,6 @@ if (correctPhi) } else { - nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -31,7 +29,7 @@ else p_rgh, dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C index e563565381..4150454a9e 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { mesh.update(); diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H b/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H index 425cc4cb75..9afcd58a66 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -7,7 +5,7 @@ CorrectPhi p_rgh, dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C index 35a61bbc2e..d62117b8a8 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); diff --git a/applications/solvers/multiphase/potentialFreeSurfaceFoam/correctPhi.H b/applications/solvers/multiphase/potentialFreeSurfaceFoam/correctPhi.H index 92e208bd1d..f060cce12c 100644 --- a/applications/solvers/multiphase/potentialFreeSurfaceFoam/correctPhi.H +++ b/applications/solvers/multiphase/potentialFreeSurfaceFoam/correctPhi.H @@ -1,5 +1,3 @@ -nonOrthogonalSolutionControl pcorrControl(mesh, pimple.algorithmName()); - CorrectPhi ( U, @@ -7,7 +5,7 @@ CorrectPhi p_gh, surfaceScalarField("rAUf", fvc::interpolate(rAU)), geometricZeroField(), - pcorrControl + pimple ); #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/potentialFreeSurfaceFoam/pEqn.H b/applications/solvers/multiphase/potentialFreeSurfaceFoam/pEqn.H index ec342f7d67..6d9409b7dd 100644 --- a/applications/solvers/multiphase/potentialFreeSurfaceFoam/pEqn.H +++ b/applications/solvers/multiphase/potentialFreeSurfaceFoam/pEqn.H @@ -2,7 +2,7 @@ rAU = 1.0/UEqn.A(); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_gh)); -if (pimple.nCorrPISO() <= 1) +if (pimple.nCorrPiso() <= 1) { tUEqn.clear(); } diff --git a/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceFoam.C b/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceFoam.C index c1aa5d87ac..ef88eb2d4e 100644 --- a/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceFoam.C +++ b/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C index 580f47ae81..c862f1921f 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/populationBalanceModel/populationBalanceModel.C @@ -1233,7 +1233,7 @@ void Foam::diameterModels::populationBalanceModel::solve() bool solveOnFinalIterOnly = solutionControls.lookupOrDefault("solveOnFinalIterOnly", false); - if (!solveOnFinalIterOnly || pimple_.finalIter()) + if (!solveOnFinalIterOnly || pimple_.finalPimpleIter()) { const label nCorr = this->nCorr(); const scalar tolerance = diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index b7079f30c3..4443614c24 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) while (pimple.loop()) { - if (pimple.firstIter() || moveMeshOuterCorrectors) + if (pimple.firstPimpleIter() || moveMeshOuterCorrectors) { mesh.update(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C index 2ecfa7e32b..5144ebe4ca 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,7 +37,7 @@ namespace Foam Foam::pimpleControl::pimpleControl(fvMesh& mesh, const word& algorithmName) : - pimpleNoLoopControl(mesh, algorithmName), + pimpleNoLoopControl(mesh, algorithmName, *this), pimpleLoop(static_cast(*this)) { read(); @@ -91,17 +91,14 @@ bool Foam::pimpleControl::loop() if (!pimpleLoop::loop(*this)) { - mesh().data::remove("finalIteration"); + updateFinal(); return false; } storePrevIterFields(); - if (finalIter()) - { - mesh().data::add("finalIteration", true); - } + updateFinal(); return true; } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.H index 2edfa12e55..9a0dc02889 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControl.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControlI.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControlI.H index 23042fc14d..995db033f0 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControlI.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl/pimpleControlI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,7 +27,7 @@ License inline bool Foam::pimpleControl::turbCorr() const { - return !turbOnFinalIterOnly() || finalIter(); + return !turbOnFinalIterOnly() || finalPimpleIter(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.C index 18a1183e4e..21bcb1b4e7 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,15 +67,13 @@ bool Foam::pimpleLoop::loop(correctorConvergenceControl& convergence) { read(); - ++ corrPimple_; - // Handle quit conditions first { // If converged on the last iteration then end the correction loop if (converged_) { - Info<< control_.algorithmName() << ": Converged in " - << corrPimple_ - 1 << " iterations" << endl; + Info<< control_.algorithmName() << ": Converged in " << corrPimple_ + << " iterations" << endl; corrPimple_ = 0; converged_ = false; @@ -84,7 +82,7 @@ bool Foam::pimpleLoop::loop(correctorConvergenceControl& convergence) } // If all corrections have been completed then end the correction loop - if (corrPimple_ > nCorrPimple_) + if (corrPimple_ >= nCorrPimple_) { if (convergence.hasCorrResidualControls() && nCorrPimple_ > 1) { @@ -100,6 +98,9 @@ bool Foam::pimpleLoop::loop(correctorConvergenceControl& convergence) } // If we reached here, we are doing another loop + ++ corrPimple_; + + // Set up the next loop { // If convergence has been reached then set the flag so that the loop // exits next time around diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.H index 81b0764c6b..b41a0eb439 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoop.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -99,18 +99,15 @@ public: //- Maximum number of pimple correctors inline label nCorrPimple() const; + //- Flat to indicate any pimple iteration + inline bool anyPimpleIter() const; + //- Flag to indicate the first pimple iteration inline bool firstPimpleIter() const; //- Flag to indicate the last pimple iteration inline bool finalPimpleIter() const; - //- Flag to indicate the first iteration - inline bool firstIter() const; - - //- Flag to indicate the last iteration - inline bool finalIter() const; - // Evolution diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoopI.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoopI.H index 9799e67f39..5e2592b201 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoopI.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleLoop/pimpleLoopI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,12 @@ inline Foam::label Foam::pimpleLoop::nCorrPimple() const } +inline bool Foam::pimpleLoop::anyPimpleIter() const +{ + return corrPimple_ != 0; +} + + inline bool Foam::pimpleLoop::firstPimpleIter() const { return corrPimple_ == 1; @@ -39,19 +45,7 @@ inline bool Foam::pimpleLoop::firstPimpleIter() const inline bool Foam::pimpleLoop::finalPimpleIter() const { - return corrPimple_ >= nCorrPimple_; -} - - -inline bool Foam::pimpleLoop::firstIter() const -{ - return firstPimpleIter(); -} - - -inline bool Foam::pimpleLoop::finalIter() const -{ - return converged_ || finalPimpleIter(); + return converged_ || corrPimple_ >= nCorrPimple_; } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C index 5ceb8d203b..4af741dc1b 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,7 +84,7 @@ Foam::pimpleMultiRegionControl::pimpleMultiRegionControl { pimpleControls_.append ( - new pimpleNoLoopControl(pimpleMeshes[i], algorithmName) + new pimpleNoLoopControl(pimpleMeshes[i], algorithmName, *this) ); allSteady = allSteady && pimpleMeshes[i].steady(); @@ -95,7 +95,7 @@ Foam::pimpleMultiRegionControl::pimpleMultiRegionControl { solidControls_.append ( - new solidNoLoopControl(solidMeshes[i], algorithmName) + new solidNoLoopControl(solidMeshes[i], algorithmName, *this) ); allSteady = allSteady && solidMeshes[i].steady(); @@ -278,11 +278,11 @@ bool Foam::pimpleMultiRegionControl::loop() { forAll(pimpleControls_, i) { - pimpleControls_[i].mesh().data::remove("finalIteration"); + pimpleControls_[i].updateFinal(); } forAll(solidControls_, i) { - solidControls_[i].mesh().data::remove("finalIteration"); + solidControls_[i].updateFinal(); } return false; @@ -297,16 +297,13 @@ bool Foam::pimpleMultiRegionControl::loop() solidControls_[i].storePrevIterFields(); } - if (finalIter()) + forAll(pimpleControls_, i) { - forAll(pimpleControls_, i) - { - pimpleControls_[i].mesh().data::add("finalIteration", true); - } - forAll(solidControls_, i) - { - solidControls_[i].mesh().data::add("finalIteration", true); - } + pimpleControls_[i].updateFinal(); + } + forAll(solidControls_, i) + { + solidControls_[i].updateFinal(); } return true; diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControlI.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControlI.H index cc6700a98b..d66206d0cc 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControlI.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleMultiRegionControl/pimpleMultiRegionControlI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,7 +41,7 @@ Foam::pimpleMultiRegionControl::solid(const label i) inline bool Foam::pimpleMultiRegionControl::pimpleTurbCorr(const label i) const { - return !pimpleControls_[i].turbOnFinalIterOnly() || finalIter(); + return !pimpleControls_[i].turbOnFinalIterOnly() || finalPimpleIter(); } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.C index 768a65810f..8e3e09eaaf 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,7 +38,8 @@ namespace Foam Foam::pimpleNoLoopControl::pimpleNoLoopControl ( fvMesh& mesh, - const word& algorithmName + const word& algorithmName, + const pimpleLoop& loop ) : pisoControl(mesh, algorithmName), @@ -51,6 +52,7 @@ Foam::pimpleNoLoopControl::pimpleNoLoopControl static_cast(*this), "outerCorrector" ), + loop_(loop), simpleRho_(false), turbOnFinalIterOnly_(true) { @@ -90,4 +92,12 @@ bool Foam::pimpleNoLoopControl::read() } +bool Foam::pimpleNoLoopControl::isFinal() const +{ + return + (!anyPisoIter() && loop_.finalPimpleIter()) + || pisoControl::isFinal(); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.H b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.H index ee2139f835..24c40513e0 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleNoLoopControl/pimpleNoLoopControl.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,6 +38,7 @@ SourceFiles #ifndef pimpleNoLoopControl_H #define pimpleNoLoopControl_H +#include "pimpleLoop.H" #include "pisoControl.H" #include "singleRegionConvergenceControl.H" #include "singleRegionCorrectorConvergenceControl.H" @@ -64,6 +65,9 @@ protected: // Protected data + //- The pimple loop + const pimpleLoop& loop_; + //- Flag to indicate whether to update the density in SIMPLE mode rather // than PISO mode bool simpleRho_; @@ -83,8 +87,14 @@ public: // Constructors - //- Construct from a mesh and the name of the algorithm - pimpleNoLoopControl(fvMesh& mesh, const word& algorithmName); + //- Construct from a mesh, the name of the algorithm, and a reference + // to the pimple loop + pimpleNoLoopControl + ( + fvMesh& mesh, + const word& algorithmName, + const pimpleLoop& loop + ); //- Destructor @@ -100,6 +110,9 @@ public: // Access + //- Flag to indicate whether in final state + virtual bool isFinal() const; + //- Flag to indicate whether to update the density in simple mode inline bool simpleRho() const; diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C index 06838841c2..dd833fe138 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pisoControl/pisoControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,8 +38,8 @@ namespace Foam Foam::pisoControl::pisoControl(fvMesh& mesh, const word& algorithmName) : fluidSolutionControl(mesh, algorithmName), - nCorrPISO_(-1), - corrPISO_(0) + nCorrPiso_(-1), + corrPiso_(0) { read(); } @@ -62,57 +62,37 @@ bool Foam::pisoControl::read() const dictionary& solutionDict = dict(); - nCorrPISO_ = solutionDict.lookupOrDefault