From 18641f06499e4d814edf9905338c7821188ede59 Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Sat, 9 May 2015 23:45:15 +0100 Subject: [PATCH] twoPhaseEulerFoam: rationalize handling of fixed-flux BC update --- .../multiphase/twoPhaseEulerFoam/pU/pEqn.H | 24 +++--------------- .../multiphase/twoPhaseEulerFoam/pUf/pEqn.H | 22 ++-------------- .../cfdTools/general/MRF/MRFZone.C | 1 - .../cfdTools/general/MRF/MRFZone.H | 2 +- .../cfdTools/general/MRF/MRFZoneList.C | 25 +++++++++++++++++++ .../cfdTools/general/MRF/MRFZoneList.H | 9 ++++++- 6 files changed, 39 insertions(+), 44 deletions(-) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/pU/pEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/pU/pEqn.H index e9567bf7e22..13cb589dfde 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/pU/pEqn.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/pU/pEqn.H @@ -91,27 +91,9 @@ while (pimple.correct()) // Update continuity errors due to temperature changes #include "correctContErrs.H" - // Correct flux BCs to be consistent with the velocity BCs - forAll(mesh.boundary(), patchi) - { - if (isA<fixedValueFvsPatchScalarField>(phi1.boundaryField()[patchi])) - { - phi1.boundaryField()[patchi] == - mrfZones.relative - ( - mesh.Sf().boundaryField() & U1.boundaryField() - )()[patchi]; - } - - if (isA<fixedValueFvsPatchScalarField>(phi2.boundaryField()[patchi])) - { - phi2.boundaryField()[patchi] == - mrfZones.relative - ( - mesh.Sf().boundaryField() & U2.boundaryField() - )()[patchi]; - } - } + // Correct fixed-flux BCs to be consistent with the velocity BCs + mrfZones.correctBoundaryFlux(U1, phi1); + mrfZones.correctBoundaryFlux(U2, phi2); volVectorField HbyA1 ( diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/pUf/pEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/pUf/pEqn.H index 5f508913110..bb0b5f528fb 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/pUf/pEqn.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/pUf/pEqn.H @@ -99,26 +99,8 @@ while (pimple.correct()) surfaceScalarField rhof2(fvc::interpolate(rho2)); // Correct fixed-flux BCs to be consistent with the velocity BCs - forAll(mesh.boundary(), patchi) - { - if (isA<fixedValueFvsPatchScalarField>(phi1.boundaryField()[patchi])) - { - phi1.boundaryField()[patchi] == - mrfZones.relative - ( - mesh.Sf().boundaryField() & U1.boundaryField() - )()[patchi]; - } - - if (isA<fixedValueFvsPatchScalarField>(phi2.boundaryField()[patchi])) - { - phi2.boundaryField()[patchi] == - mrfZones.relative - ( - mesh.Sf().boundaryField() & U2.boundaryField() - )()[patchi]; - } - } + mrfZones.correctBoundaryFlux(U1, phi1); + mrfZones.correctBoundaryFlux(U2, phi2); surfaceScalarField alpharAUf1 ( diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index 4b45ed3fdc4..c1973f3df75 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -526,7 +526,6 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const { const vector Omega = this->Omega(); - // Included patches forAll(includedFaces_, patchi) { diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 43b1f8653c8..d6a41fcf9d7 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -246,7 +246,7 @@ public: surfaceScalarField& phi ) const; - //- Correct the boundary velocity for the roation of the MRF region + //- Correct the boundary velocity for the rotation of the MRF region void correctBoundaryVelocity(volVectorField& U) const; diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C index a9197ce5a5c..b14524a6765 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C @@ -25,6 +25,7 @@ License #include "MRFZoneList.H" #include "volFields.H" +#include "fixedValueFvsPatchFields.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -310,6 +311,30 @@ void Foam::MRFZoneList::correctBoundaryVelocity(volVectorField& U) const } +void Foam::MRFZoneList::correctBoundaryFlux +( + const volVectorField& U, + surfaceScalarField& phi +) const +{ + FieldField<fvsPatchField, scalar> phibf + ( + relative(mesh_.Sf().boundaryField() & U.boundaryField()) + ); + + forAll(mesh_.boundary(), patchi) + { + if + ( + isA<fixedValueFvsPatchScalarField>(phi.boundaryField()[patchi]) + ) + { + phi.boundaryField()[patchi] == phibf[patchi]; + } + } +} + + // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // Foam::Ostream& Foam::operator<< diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H index 52d992d1ce6..6f33035585c 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.H @@ -160,9 +160,16 @@ public: surfaceScalarField& phi ) const; - //- Correct the boundary velocity for the roation of the MRF region + //- Correct the boundary velocity for the rotation of the MRF region void correctBoundaryVelocity(volVectorField& U) const; + //- Correct the boundary flux for the rotation of the MRF region + void correctBoundaryFlux + ( + const volVectorField& U, + surfaceScalarField& phi + ) const; + // I-O -- GitLab