diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H index 34a9a2600a..cd2c6b7ad8 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H @@ -59,12 +59,13 @@ ); } - phi = alpha1f*phi1 + alpha2f*phi2; + surfaceScalarField phi0("phi0", alpha1f*phi1 + alpha2f*phi2); + phi = phi0; adjustPhi(phi, U, p); surfaceScalarField Dp ( - "(rho*1|A(U))", + "Dp", mag(alpha1f*rAlphaAU1f/fvc::interpolate(rho1) + alpha2f*rAlphaAU2f/fvc::interpolate(rho2)) ); diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H index 1788dd2808..a75e533ce6 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H @@ -50,11 +50,12 @@ phib = (fvc::interpolate(Ub) & mesh.Sf()) + fvc::ddtPhiCorr(rUbA, Ub, phib) + phiDragb; - phi = alphaf*phia + betaf*phib; + surfaceScalarField phi0("phi0", alphaf*phia + betaf*phib); + phi = phi0; surfaceScalarField Dp ( - "(rho*(1|A(U)))", + "Dp", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob ); diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index db1aee788a..3652bea89a 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -127,6 +127,7 @@ $(derivedFvPatchFields)/mappedFlowRate/mappedFlowRateFvPatchVectorField.C $(derivedFvPatchFields)/fan/fanFvPatchFields.C $(derivedFvPatchFields)/fanPressure/fanPressureFvPatchScalarField.C $(derivedFvPatchFields)/buoyantPressure/buoyantPressureFvPatchScalarField.C +$(derivedFvPatchFields)/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C $(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C $(derivedFvPatchFields)/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C $(derivedFvPatchFields)/fixedNormalSlip/fixedNormalSlipFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C new file mode 100644 index 0000000000..635b3d21f8 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "multiphaseFixedFluxPressureFvPatchScalarField.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::multiphaseFixedFluxPressureFvPatchScalarField:: +multiphaseFixedFluxPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(p, iF), + phi0Name_("phi0"), + phiName_("phi"), + rhoName_("rho") +{} + + +Foam::multiphaseFixedFluxPressureFvPatchScalarField:: +multiphaseFixedFluxPressureFvPatchScalarField +( + const multiphaseFixedFluxPressureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), + phi0Name_(ptf.phi0Name_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::multiphaseFixedFluxPressureFvPatchScalarField:: +multiphaseFixedFluxPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchScalarField(p, iF), + phi0Name_(dict.lookupOrDefault("phi0", "phi0")), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) +{ + if (dict.found("gradient")) + { + gradient() = scalarField("gradient", dict, p.size()); + fixedGradientFvPatchScalarField::updateCoeffs(); + fixedGradientFvPatchScalarField::evaluate(); + } + else + { + fvPatchField::operator=(patchInternalField()); + gradient() = 0.0; + } +} + + +Foam::multiphaseFixedFluxPressureFvPatchScalarField:: +multiphaseFixedFluxPressureFvPatchScalarField +( + const multiphaseFixedFluxPressureFvPatchScalarField& wbppsf +) +: + fixedGradientFvPatchScalarField(wbppsf), + phi0Name_(wbppsf.phi0Name_), + phiName_(wbppsf.phiName_), + rhoName_(wbppsf.rhoName_) +{} + + +Foam::multiphaseFixedFluxPressureFvPatchScalarField:: +multiphaseFixedFluxPressureFvPatchScalarField +( + const multiphaseFixedFluxPressureFvPatchScalarField& wbppsf, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(wbppsf, iF), + phi0Name_(wbppsf.phi0Name_), + phiName_(wbppsf.phiName_), + rhoName_(wbppsf.rhoName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const surfaceScalarField& phi0 = + db().lookupObject(phi0Name_); + + const surfaceScalarField& phi = + db().lookupObject(phiName_); + + fvsPatchField phi0p = + patch().patchField(phi0); + + fvsPatchField phip = + patch().patchField(phi); + + if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField& rhop = + patch().lookupPatchField(rhoName_); + + phip /= rhop; + } + + const fvsPatchField& Dpp = + patch().lookupPatchField("Dp"); + + gradient() = (phi0p - phip)/patch().magSf()/Dpp; + + fixedGradientFvPatchScalarField::updateCoeffs(); +} + + +void Foam::multiphaseFixedFluxPressureFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + writeEntryIfDifferent(os, "phi0", "phi0", phi0Name_); + writeEntryIfDifferent(os, "phi", "phi", phiName_); + writeEntryIfDifferent(os, "rho", "rho", rhoName_); + gradient().writeEntry("gradient", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + multiphaseFixedFluxPressureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H new file mode 100644 index 0000000000..f1699309b1 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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::multiphaseFixedFluxPressureFvPatchScalarField + +Description + Foam::multiphaseFixedFluxPressureFvPatchScalarField + +SourceFiles + multiphaseFixedFluxPressureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef multiphaseFixedFluxPressureFvPatchScalarFields_H +#define multiphaseFixedFluxPressureFvPatchScalarFields_H + +#include "fvPatchFields.H" +#include "fixedGradientFvPatchFields.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class multiphaseFixedFluxPressureFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class multiphaseFixedFluxPressureFvPatchScalarField +: + public fixedGradientFvPatchScalarField +{ + // Private data + + //- Name of the predicted flux transporting the field + word phi0Name_; + + //- Name of the flux transporting the field + word phiName_; + + //- Name of the density field used to normalise the mass flux + // if neccessary + word rhoName_; + + +public: + + //- Runtime type information + TypeName("multiphaseFixedFluxPressure"); + + + // Constructors + + //- Construct from patch and internal field + multiphaseFixedFluxPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + multiphaseFixedFluxPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // multiphaseFixedFluxPressureFvPatchScalarField onto a new patch + multiphaseFixedFluxPressureFvPatchScalarField + ( + const multiphaseFixedFluxPressureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + multiphaseFixedFluxPressureFvPatchScalarField + ( + const multiphaseFixedFluxPressureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new multiphaseFixedFluxPressureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + multiphaseFixedFluxPressureFvPatchScalarField + ( + const multiphaseFixedFluxPressureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new multiphaseFixedFluxPressureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p index 47437d39f1..8f2ec50ff3 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p @@ -22,16 +22,18 @@ boundaryField { inlet { - type zeroGradient; + type multiphaseFixedFluxPressure; + value $internalField; } outlet { type fixedValue; - value uniform 1e5; + value $internalField; } walls { - type zeroGradient; + type multiphaseFixedFluxPressure; + value $internalField; } } diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p b/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p index f0f3628591..63e3f73b31 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p @@ -22,20 +22,20 @@ boundaryField { bottom { - type buoyantPressure; - value uniform 0; + type multiphaseFixedFluxPressure; + value $internalField; } top { type fixedValue; - value uniform 0; + value $internalField; } walls { - type buoyantPressure; - value uniform 0; + type multiphaseFixedFluxPressure; + value $internalField; } frontBack diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed/system/fvSchemes b/tutorials/multiphase/twoPhaseEulerFoam/bed/system/fvSchemes index 22ba134885..5296dc91b9 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed/system/fvSchemes +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed/system/fvSchemes @@ -44,7 +44,7 @@ laplacianSchemes default none; laplacian(nuEffa,Ua) Gauss linear corrected; laplacian(nuEffb,Ub) Gauss linear corrected; - laplacian((rho*(1|A(U))),p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; laplacian(alphaPpMag,alpha) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p b/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p index c7dd8b8427..d8384de3d5 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p @@ -22,16 +22,18 @@ boundaryField { walls { - type zeroGradient; + type multiphaseFixedFluxPressure; + value $internalField; } outlet { type fixedValue; - value uniform 0; + value $internalField; } inlet { - type zeroGradient; + type multiphaseFixedFluxPressure; + value $internalField; } frontAndBackPlanes { diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/fvSchemes b/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/fvSchemes index a7196ec07a..ab4c5fa0eb 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/fvSchemes +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/fvSchemes @@ -44,7 +44,7 @@ laplacianSchemes default none; laplacian(nuEffa,Ua) Gauss linear corrected; laplacian(nuEffb,Ub) Gauss linear corrected; - laplacian((rho*(1|A(U))),p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; laplacian(alphaPpMag,alpha) Gauss linear corrected; laplacian(Galphaf,alpha) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p index 709bf07cef..db1aca2e2a 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p @@ -1901,7 +1901,8 @@ boundaryField { inlet { - type zeroGradient; + type multiphaseFixedFluxPressure; + value uniform 0; } outlet @@ -1912,7 +1913,7 @@ boundaryField walls { - type buoyantPressure; + type multiphaseFixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/fvSchemes b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/fvSchemes index 4df2fcbcab..470c7aae79 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/fvSchemes +++ b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/fvSchemes @@ -44,7 +44,7 @@ laplacianSchemes default none; laplacian(nuEffa,Ua) Gauss linear corrected; laplacian(nuEffb,Ub) Gauss linear corrected; - laplacian((rho*(1|A(U))),p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; laplacian(alphaPpMag,alpha) Gauss linear corrected; laplacian((alphak*nuEffb),k) Gauss linear corrected; laplacian((alphaEps*nuEffb),epsilon) Gauss linear corrected;