diff --git a/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H b/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H index abddcf1a21..43d24572dd 100644 --- a/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H +++ b/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H @@ -9,7 +9,7 @@ CorrectPhi Uc, p, dimensionedScalar("rAUf", dimTime, 1), - geometricZeroField(), + autoPtr(), pressureReference, pimple ); diff --git a/applications/solvers/modules/VoFSolver/moveMesh.C b/applications/solvers/modules/VoFSolver/moveMesh.C index 9be50fadbe..2076f55182 100644 --- a/applications/solvers/modules/VoFSolver/moveMesh.C +++ b/applications/solvers/modules/VoFSolver/moveMesh.C @@ -67,32 +67,16 @@ void Foam::solvers::VoFSolver::moveMesh() if (incompressible()) { - if (divU.valid()) - { - CorrectPhi - ( - phi, - U, - p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU())), - divU(), - pressureReference(), - pimple - ); - } - else - { - CorrectPhi - ( - phi, - U, - p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU())), - geometricZeroField(), - pressureReference(), - pimple - ); - } + CorrectPhi + ( + phi, + U, + p_rgh, + surfaceScalarField("rAUf", fvc::interpolate(rAU())), + divU, + pressureReference(), + pimple + ); } else { diff --git a/applications/solvers/modules/incompressibleFluid/moveMesh.C b/applications/solvers/modules/incompressibleFluid/moveMesh.C index 6d34cb773d..b80a9c2053 100644 --- a/applications/solvers/modules/incompressibleFluid/moveMesh.C +++ b/applications/solvers/modules/incompressibleFluid/moveMesh.C @@ -54,7 +54,7 @@ void Foam::solvers::incompressibleFluid::moveMesh() U, p, dimensionedScalar("rAUf", dimTime, 1), - geometricZeroField(), + autoPtr(), pressureReference, pimple ); diff --git a/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C b/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C index 30abcee20f..4540f8bc93 100644 --- a/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C +++ b/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C @@ -128,7 +128,7 @@ Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF U, p_rgh, surfaceScalarField("rAUf", fvc::interpolate(rAU())), - geometricZeroField(), + autoPtr(), pressureReference(), pimple ); @@ -143,7 +143,7 @@ Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF U, p_rgh, dimensionedScalar(dimTime/rho.dimensions(), 1), - geometricZeroField(), + autoPtr(), pressureReference(), pimple ); diff --git a/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C b/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C index 7053817e18..a953e5cad5 100644 --- a/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C +++ b/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C @@ -113,7 +113,7 @@ Foam::solvers::incompressibleVoF::incompressibleVoF(fvMesh& mesh) U, p_rgh, surfaceScalarField("rAUf", fvc::interpolate(rAU())), - geometricZeroField(), + autoPtr(), pressureReference(), pimple ); @@ -128,7 +128,7 @@ Foam::solvers::incompressibleVoF::incompressibleVoF(fvMesh& mesh) U, p_rgh, dimensionedScalar(dimTime/rho.dimensions(), 1), - geometricZeroField(), + autoPtr(), pressureReference(), pimple ); diff --git a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/multiphaseEuler.H b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/multiphaseEuler.H index a213c6f8b3..ea857b582e 100644 --- a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/multiphaseEuler.H +++ b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/multiphaseEuler.H @@ -153,7 +153,7 @@ protected: //- Stored divU from the previous mesh so that it can be // mapped and used in correctPhi to ensure the corrected phi // has the same divergence - tmp divU; + autoPtr divU; //- Read controls void readControls(); diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C index d866bdedde..cea28d9919 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.C @@ -519,10 +519,10 @@ Foam::MovingPhaseModel::K() const template -Foam::tmp +const Foam::autoPtr& Foam::MovingPhaseModel::divU() const { - return divU_.valid() ? tmp(divU_()) : tmp(); + return divU_; } @@ -531,13 +531,13 @@ void Foam::MovingPhaseModel::divU(tmp divU) { if (!divU_.valid()) { - divU_ = divU; - divU_.ref().rename(IOobject::groupName("divU", this->name())); - divU_.ref().checkIn(); + divU_ = divU.ptr(); + divU_().rename(IOobject::groupName("divU", this->name())); + divU_().checkIn(); } else { - divU_.ref() = divU; + divU_() = divU; } } diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.H b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.H index 25d363b812..1f32f0c2aa 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.H +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/MovingPhaseModel/MovingPhaseModel.H @@ -119,7 +119,7 @@ protected: mutable tmp DUDtf_; //- Dilatation rate - tmp divU_; + autoPtr divU_; //- Turbulence model autoPtr momentumTransport_; @@ -253,7 +253,7 @@ public: // Compressibility (variable density) //- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi)) - virtual tmp divU() const; + virtual const autoPtr& divU() const; //- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi)) virtual void divU(tmp divU); diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.C b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.C index 6c81294ca4..6e0b87d294 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.C +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.C @@ -259,10 +259,11 @@ Foam::StationaryPhaseModel::K() const template -Foam::tmp +const Foam::autoPtr& Foam::StationaryPhaseModel::divU() const { - return tmp(); + static autoPtr divU_; + return divU_; } diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.H b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.H index 46f1f750ae..447b793260 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.H +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/StationaryPhaseModel/StationaryPhaseModel.H @@ -136,7 +136,7 @@ public: // Compressibility (variable density) //- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi)) - virtual tmp divU() const; + virtual const autoPtr& divU() const; //- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi)) virtual void divU(tmp divU); diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/phaseModel/phaseModel.H b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/phaseModel/phaseModel.H index cf7c6a6b0c..489f404ee4 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/phaseModel/phaseModel.H +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseModel/phaseModel/phaseModel.H @@ -246,7 +246,7 @@ public: virtual bool isochoric() const = 0; //- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi)) - virtual tmp divU() const = 0; + virtual const autoPtr& divU() const = 0; //- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi)) virtual void divU(tmp divU) = 0; diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C index ff5e65c3a0..591f09336a 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C @@ -728,7 +728,7 @@ void Foam::phaseSystem::correctBoundaryFlux() void Foam::phaseSystem::correctPhi ( const volScalarField& p_rgh, - const tmp& divU, + const autoPtr& divU, const pressureReference& pressureReference, nonOrthogonalSolutionControl& pimple ) @@ -778,32 +778,16 @@ void Foam::phaseSystem::correctPhi if (incompressible()) { - if (divU.valid()) - { - CorrectPhi - ( - phi_, - movingPhases()[0].U(), - p_rgh, - dimensionedScalar(dimTime/dimDensity, 1), - divU(), - pressureReference, - pimple - ); - } - else - { - CorrectPhi - ( - phi_, - movingPhases()[0].U(), - p_rgh, - dimensionedScalar(dimTime/dimDensity, 1), - geometricZeroField(), - pressureReference, - pimple - ); - } + CorrectPhi + ( + phi_, + movingPhases()[0].U(), + p_rgh, + dimensionedScalar(dimTime/dimDensity, 1), + divU, + pressureReference, + pimple + ); } else { diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.H b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.H index 42b445aee3..14406766fd 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.H +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.H @@ -656,7 +656,7 @@ public: void correctPhi ( const volScalarField& p_rgh, - const tmp& divU, + const autoPtr& divU, const pressureReference& pressureReference, nonOrthogonalSolutionControl& pimple ); diff --git a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C b/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C index 21250c9fae..953c43f420 100644 --- a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C +++ b/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C @@ -39,14 +39,14 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template +template void Foam::CorrectPhi ( surfaceScalarField& phi, const volVectorField& U, const volScalarField& p, const RAUfType& rAUf, - const DivUType& divU, + const autoPtr& divU, const pressureReference& pressureReference, nonOrthogonalSolutionControl& pcorrControl ) @@ -98,7 +98,13 @@ void Foam::CorrectPhi // matches the divU provided (from previous iteration, time-step...) fvScalarMatrix pcorrEqn ( - fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU + fvm::laplacian(rAUf, pcorr) + == + ( + divU.valid() + ? fvc::div(phi) - divU() + : fvc::div(phi) + ) ); pcorrEqn.setReference(pressureReference.refCell(), 0); @@ -113,14 +119,14 @@ void Foam::CorrectPhi } -template +template void Foam::CorrectPhi ( surfaceScalarField& phi, const volScalarField& p, const volScalarField& psi, const RAUfType& rAUf, - const DivRhoUType& divRhoU, + const volScalarField& divRhoU, nonOrthogonalSolutionControl& pcorrControl ) { diff --git a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H b/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H index 21781f7845..bd853766c4 100644 --- a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H +++ b/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H @@ -70,26 +70,26 @@ namespace Foam const bool evaluateUBCs ); - template + template void CorrectPhi ( surfaceScalarField& phi, const volVectorField& U, const volScalarField& p, const RAUfType& rAUf, - const DivUType& divU, + const autoPtr& divU, const pressureReference& pressureReference, nonOrthogonalSolutionControl& pcorrControl ); - template + template void CorrectPhi ( surfaceScalarField& phi, const volScalarField& p, const volScalarField& psi, const RAUfType& rAUf, - const DivRhoUType& divRhoU, + const volScalarField& divRhoU, nonOrthogonalSolutionControl& pcorrControl ); }