diff --git a/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C b/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C index c086d5f3ee..760a335465 100644 --- a/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C +++ b/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C @@ -43,48 +43,35 @@ void Foam::constrainPressure ) { const fvMesh& mesh = p.mesh(); + volScalarField::GeometricBoundaryField& pBf = p.boundaryField(); - bool hasFixedFluxBCs = false; + const volVectorField::GeometricBoundaryField& UBf = U.boundaryField(); + const surfaceScalarField::GeometricBoundaryField& phiHbyABf = + phiHbyA.boundaryField(); + const typename RAUType::GeometricBoundaryField& rhorAUBf = + rhorAU.boundaryField(); + const surfaceVectorField::GeometricBoundaryField& SfBf = + mesh.Sf().boundaryField(); + const surfaceScalarField::GeometricBoundaryField& magSfBf = + mesh.magSf().boundaryField(); + forAll(pBf, patchi) { if (isA(pBf[patchi])) { - hasFixedFluxBCs = true; - break; - } - } - - if (hasFixedFluxBCs) - { - const surfaceScalarField::GeometricBoundaryField& phiHbyABf = - phiHbyA.boundaryField(); - const typename RAUType::GeometricBoundaryField& rhorAUBf = - rhorAU.boundaryField(); - const surfaceScalarField::GeometricBoundaryField& magSfBf = - mesh.magSf().boundaryField(); - - // Pre-compute tho relative flux for all patches: currently MRFZone does - // not support computing the relative flux for individual patches - FieldField phiRelBf - ( - MRF.relative(mesh.Sf().boundaryField() & U.boundaryField()) - ); - - forAll(pBf, patchi) - { - if (isA(pBf[patchi])) - { - refCast(pBf[patchi]) - .updateCoeffs + refCast + ( + pBf[patchi] + ).updateCoeffs + ( ( - ( - phiHbyABf[patchi] - - rho.boundaryField()[patchi]*phiRelBf[patchi] - ) - /(magSfBf[patchi]*rhorAUBf[patchi]) - ); - } + phiHbyABf[patchi] + - rho.boundaryField()[patchi] + *MRF.relative(SfBf[patchi] & UBf[patchi], patchi) + ) + /(magSfBf[patchi]*rhorAUBf[patchi]) + ); } } } diff --git a/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.H b/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.H index b3e522ee05..06359c8ad2 100644 --- a/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.H +++ b/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.H @@ -68,6 +68,13 @@ public: { return U; } + + //- Return the argument unchanged + template + inline const Type& relative(const Type& U, const label patchi) const + { + return U; + } };