From 5af5222141dc3c3c5ec8639235850f88ce28ec0c Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin <kutalmis.bercin@esi-group.com> Date: Wed, 16 Dec 2020 11:00:56 +0000 Subject: [PATCH] ENH: outletMappedUniformInlet: add optional fraction and offset entries The new functionality optionally allows the patch-averaged value to be scaled and/or offset by a pair of specified values. Example of the boundary condition specification: ``` <patchName> { // Mandatory entries (unmodifiable) type outletMappedFilterInlet; outletPatch <outletPatchName>; // Optional entries (unmodifiable) fraction 0.1; offset 10; // (1 0 0); phi phi; // Optional (inherited) entries ... } ``` --- .../outletMappedUniformInletFvPatchField.C | 33 +++++--- .../outletMappedUniformInletFvPatchField.H | 76 ++++++++++++++----- 2 files changed, 80 insertions(+), 29 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C index 86323db7ed9..082588d127f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C @@ -42,7 +42,9 @@ outletMappedUniformInletFvPatchField : fixedValueFvPatchField<Type>(p, iF), outletPatchName_(), - phiName_("phi") + phiName_("phi"), + fraction_(1), + offset_(Zero) {} @@ -56,8 +58,10 @@ outletMappedUniformInletFvPatchField ) : fixedValueFvPatchField<Type>(p, iF, dict), - outletPatchName_(dict.lookup("outletPatch")), - phiName_(dict.getOrDefault<word>("phi", "phi")) + outletPatchName_(dict.get<word>("outletPatch")), + phiName_(dict.getOrDefault<word>("phi", "phi")), + fraction_(dict.getOrDefault<scalar>("fraction", 1)), + offset_(dict.getOrDefault<Type>("offset", Zero)) {} @@ -73,7 +77,9 @@ outletMappedUniformInletFvPatchField : fixedValueFvPatchField<Type>(ptf, p, iF, mapper), outletPatchName_(ptf.outletPatchName_), - phiName_(ptf.phiName_) + phiName_(ptf.phiName_), + fraction_(ptf.fraction_), + offset_(ptf.offset_) {} @@ -86,11 +92,12 @@ outletMappedUniformInletFvPatchField : fixedValueFvPatchField<Type>(ptf), outletPatchName_(ptf.outletPatchName_), - phiName_(ptf.phiName_) + phiName_(ptf.phiName_), + fraction_(ptf.fraction_), + offset_(ptf.offset_) {} - template<class Type> Foam::outletMappedUniformInletFvPatchField<Type>:: outletMappedUniformInletFvPatchField @@ -101,7 +108,9 @@ outletMappedUniformInletFvPatchField : fixedValueFvPatchField<Type>(ptf, iF), outletPatchName_(ptf.outletPatchName_), - phiName_(ptf.phiName_) + phiName_(ptf.phiName_), + fraction_(ptf.fraction_), + offset_(ptf.offset_) {} @@ -124,7 +133,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs() ); const fvPatch& p = this->patch(); - label outletPatchID = + const label outletPatchID = p.patch().boundaryMesh().findPatchID(outletPatchName_); if (outletPatchID < 0) @@ -139,12 +148,12 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs() const fvPatchField<Type>& outletPatchField = f.boundaryField()[outletPatchID]; - const surfaceScalarField& phi = + const auto& phi = this->db().objectRegistry::template lookupObject<surfaceScalarField> (phiName_); const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID]; - scalar sumOutletPatchPhi = gSum(outletPatchPhi); + const scalar sumOutletPatchPhi = gSum(outletPatchPhi); if (sumOutletPatchPhi > SMALL) { @@ -152,7 +161,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs() gSum(outletPatchPhi*outletPatchField) /sumOutletPatchPhi; - this->operator==(averageOutletField); + this->operator==(averageOutletField*fraction_ + offset_); } else { @@ -173,6 +182,8 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const fvPatchField<Type>::write(os); os.writeEntry("outletPatch", outletPatchName_); os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntry("fraction", fraction_); + os.writeEntry("offset", offset_); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.H index d340a153a66..0b586c771ca 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,33 +31,66 @@ Group grpInletBoundaryConditions Description - This boundary condition averages the field over the "outlet" patch specified - by name "outletPatch" and applies this as the uniform value of the field - over this patch. + The \c outletMappedUniformInlet is an inlet boundary condition that + - averages the patch field of \<Type\> over a specified "outlet" patch + and uniformly applies the averaged value over a specified inlet patch. + - optionally, the averaged value can be scaled + and/or offset by a pair of specified values. + + The governing equation of the boundary condition is: + + \f[ + \phi_{inlet} = f \phi_{outlet} + \phi_{offset} + \f] + + where + \vartable + \phi_{inlet} | Spatially-uniform patch-field value at an inlet patch + \phi_{outlet} | Averaged patch-field value at an outlet patch + f | User-defined fraction value + \phi_{offset} | User-defined offset value + \endvartable Usage - \table - Property | Description | Required | Default value - outletPatch | Name of outlet patch | yes | - phi | Flux field name | no | phi - \endtable - Example of the boundary condition specification: \verbatim <patchName> { - type outletMappedUniformInlet; - outletPatch aPatch; + // Mandatory entries (unmodifiable) + type outletMappedFilterInlet; + outletPatch <outletPatchName>; + + // Optional entries (unmodifiable) + fraction 0.1; + offset 10; // (1 0 0); phi phi; - value uniform 0; + + // Optional (inherited) entries + ... } \endverbatim + where the entries mean: + \table + Property | Description | Type | Reqd | Dflt + type | Type name: outletMappedUniformInlet | word | yes | - + outletPatch | Name of patch to be mapped | word | yes | - + fraction | Fraction value | scalar | no | 1 + offset | Offset value | Type | no | Zero + phi | Name of operand flux field | word | no | phi + \endtable + + The inherited entries are elaborated in: + - \link fixedValueFvPatchFields.H \endlink + See also - Foam::fixedValueFvPatchField + - Foam::fixedValueFvPatchField + - Foam::outletMappedUniformInletHeatAdditionFvPatchField + - Foam::outletMappedUniformInletTemperatureFvPatchField SourceFiles outletMappedUniformInletFvPatchField.C + outletMappedUniformInletFvPatchFields.C \*---------------------------------------------------------------------------*/ @@ -79,14 +113,20 @@ class outletMappedUniformInletFvPatchField : public fixedValueFvPatchField<Type> { - // Private data + // Private Data //- Name of the outlet patch to be mapped word outletPatchName_; - //- Name of the flux transporting the field + //- Name of operand flux field word phiName_; + //- Fraction value + scalar fraction_; + + //- Offset value + Type offset_; + public: @@ -112,7 +152,7 @@ public: ); //- Construct by mapping given outletMappedUniformInletFvPatchField - // onto a new patch + //- onto a new patch outletMappedUniformInletFvPatchField ( const outletMappedUniformInletFvPatchField<Type>&, @@ -156,7 +196,7 @@ public: } - // Member functions + // Member Functions // Access @@ -167,7 +207,7 @@ public: } - // Evaluation functions + // Evaluation //- Update the coefficients associated with the patch field virtual void updateCoeffs(); -- GitLab