From 29e4cc592a8aadefcaa47a6d2f2ddd363fc4ad59 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 18 Sep 2019 16:37:36 +0100 Subject: [PATCH] constrainHbyA: Added constrainPhiHbyA to constrain the predicted flux directly --- .../general/constrainHbyA/constrainHbyA.C | 44 +++++++++++++++++++ .../general/constrainHbyA/constrainHbyA.H | 10 ++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C b/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C index c41f176852..2a193d9e4f 100644 --- a/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C +++ b/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.C @@ -25,6 +25,7 @@ License #include "constrainHbyA.H" #include "volFields.H" +#include "surfaceFields.H" #include "fixedFluxExtrapolatedPressureFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,4 +71,47 @@ Foam::tmp Foam::constrainHbyA } +Foam::tmp Foam::constrainPhiHbyA +( + const tmp& tphiHbyA, + const volVectorField& U, + const volScalarField& p +) +{ + tmp tphiHbyANew; + + if (tphiHbyA.isTmp()) + { + tphiHbyANew = tphiHbyA; + tphiHbyANew.ref().rename("phiHbyA"); + } + else + { + tphiHbyANew = surfaceScalarField::New("phiHbyA", tphiHbyA); + } + + surfaceScalarField& phiHbyA = tphiHbyANew.ref(); + surfaceScalarField::Boundary& phiHbyAbf = phiHbyA.boundaryFieldRef(); + + forAll(U.boundaryField(), patchi) + { + if + ( + !U.boundaryField()[patchi].assignable() + && !isA + ( + p.boundaryField()[patchi] + ) + ) + { + phiHbyAbf[patchi] = + U.mesh().Sf().boundaryField()[patchi] + & U.boundaryField()[patchi]; + } + } + + return tphiHbyANew; +} + + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.H b/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.H index 0630cc1c04..6d96e630bf 100644 --- a/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.H +++ b/src/finiteVolume/cfdTools/general/constrainHbyA/constrainHbyA.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,6 +35,7 @@ SourceFiles #define constrainHbyA_H #include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,6 +51,13 @@ tmp constrainHbyA const volScalarField& p ); +tmp constrainPhiHbyA +( + const tmp& tphiHbyA, + const volVectorField& U, + const volScalarField& p +); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam