Skip to content
Snippets Groups Projects
Commit 5af52221 authored by Kutalmış Berçin's avatar Kutalmış Berçin Committed by Andrew Heather
Browse files

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
    ...
}
```
parent 4a80672a
Branches
Tags
1 merge request!399ENH: outletMappedUniformInlet: add optional fraction and offset
...@@ -42,7 +42,9 @@ outletMappedUniformInletFvPatchField ...@@ -42,7 +42,9 @@ outletMappedUniformInletFvPatchField
: :
fixedValueFvPatchField<Type>(p, iF), fixedValueFvPatchField<Type>(p, iF),
outletPatchName_(), outletPatchName_(),
phiName_("phi") phiName_("phi"),
fraction_(1),
offset_(Zero)
{} {}
...@@ -56,8 +58,10 @@ outletMappedUniformInletFvPatchField ...@@ -56,8 +58,10 @@ outletMappedUniformInletFvPatchField
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict), fixedValueFvPatchField<Type>(p, iF, dict),
outletPatchName_(dict.lookup("outletPatch")), outletPatchName_(dict.get<word>("outletPatch")),
phiName_(dict.getOrDefault<word>("phi", "phi")) phiName_(dict.getOrDefault<word>("phi", "phi")),
fraction_(dict.getOrDefault<scalar>("fraction", 1)),
offset_(dict.getOrDefault<Type>("offset", Zero))
{} {}
...@@ -73,7 +77,9 @@ outletMappedUniformInletFvPatchField ...@@ -73,7 +77,9 @@ outletMappedUniformInletFvPatchField
: :
fixedValueFvPatchField<Type>(ptf, p, iF, mapper), fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
outletPatchName_(ptf.outletPatchName_), outletPatchName_(ptf.outletPatchName_),
phiName_(ptf.phiName_) phiName_(ptf.phiName_),
fraction_(ptf.fraction_),
offset_(ptf.offset_)
{} {}
...@@ -86,11 +92,12 @@ outletMappedUniformInletFvPatchField ...@@ -86,11 +92,12 @@ outletMappedUniformInletFvPatchField
: :
fixedValueFvPatchField<Type>(ptf), fixedValueFvPatchField<Type>(ptf),
outletPatchName_(ptf.outletPatchName_), outletPatchName_(ptf.outletPatchName_),
phiName_(ptf.phiName_) phiName_(ptf.phiName_),
fraction_(ptf.fraction_),
offset_(ptf.offset_)
{} {}
template<class Type> template<class Type>
Foam::outletMappedUniformInletFvPatchField<Type>:: Foam::outletMappedUniformInletFvPatchField<Type>::
outletMappedUniformInletFvPatchField outletMappedUniformInletFvPatchField
...@@ -101,7 +108,9 @@ outletMappedUniformInletFvPatchField ...@@ -101,7 +108,9 @@ outletMappedUniformInletFvPatchField
: :
fixedValueFvPatchField<Type>(ptf, iF), fixedValueFvPatchField<Type>(ptf, iF),
outletPatchName_(ptf.outletPatchName_), outletPatchName_(ptf.outletPatchName_),
phiName_(ptf.phiName_) phiName_(ptf.phiName_),
fraction_(ptf.fraction_),
offset_(ptf.offset_)
{} {}
...@@ -124,7 +133,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs() ...@@ -124,7 +133,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
); );
const fvPatch& p = this->patch(); const fvPatch& p = this->patch();
label outletPatchID = const label outletPatchID =
p.patch().boundaryMesh().findPatchID(outletPatchName_); p.patch().boundaryMesh().findPatchID(outletPatchName_);
if (outletPatchID < 0) if (outletPatchID < 0)
...@@ -139,12 +148,12 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs() ...@@ -139,12 +148,12 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
const fvPatchField<Type>& outletPatchField = const fvPatchField<Type>& outletPatchField =
f.boundaryField()[outletPatchID]; f.boundaryField()[outletPatchID];
const surfaceScalarField& phi = const auto& phi =
this->db().objectRegistry::template lookupObject<surfaceScalarField> this->db().objectRegistry::template lookupObject<surfaceScalarField>
(phiName_); (phiName_);
const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID]; const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
scalar sumOutletPatchPhi = gSum(outletPatchPhi); const scalar sumOutletPatchPhi = gSum(outletPatchPhi);
if (sumOutletPatchPhi > SMALL) if (sumOutletPatchPhi > SMALL)
{ {
...@@ -152,7 +161,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs() ...@@ -152,7 +161,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
gSum(outletPatchPhi*outletPatchField) gSum(outletPatchPhi*outletPatchField)
/sumOutletPatchPhi; /sumOutletPatchPhi;
this->operator==(averageOutletField); this->operator==(averageOutletField*fraction_ + offset_);
} }
else else
{ {
...@@ -173,6 +182,8 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const ...@@ -173,6 +182,8 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
os.writeEntry("outletPatch", outletPatchName_); os.writeEntry("outletPatch", outletPatchName_);
os.writeEntryIfDifferent<word>("phi", "phi", phiName_); os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
os.writeEntry("fraction", fraction_);
os.writeEntry("offset", offset_);
this->writeEntry("value", os); this->writeEntry("value", os);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -30,33 +31,66 @@ Group ...@@ -30,33 +31,66 @@ Group
grpInletBoundaryConditions grpInletBoundaryConditions
Description Description
This boundary condition averages the field over the "outlet" patch specified The \c outletMappedUniformInlet is an inlet boundary condition that
by name "outletPatch" and applies this as the uniform value of the field - averages the patch field of \<Type\> over a specified "outlet" patch
over this 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 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: Example of the boundary condition specification:
\verbatim \verbatim
<patchName> <patchName>
{ {
type outletMappedUniformInlet; // Mandatory entries (unmodifiable)
outletPatch aPatch; type outletMappedFilterInlet;
outletPatch <outletPatchName>;
// Optional entries (unmodifiable)
fraction 0.1;
offset 10; // (1 0 0);
phi phi; phi phi;
value uniform 0;
// Optional (inherited) entries
...
} }
\endverbatim \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 See also
Foam::fixedValueFvPatchField - Foam::fixedValueFvPatchField
- Foam::outletMappedUniformInletHeatAdditionFvPatchField
- Foam::outletMappedUniformInletTemperatureFvPatchField
SourceFiles SourceFiles
outletMappedUniformInletFvPatchField.C outletMappedUniformInletFvPatchField.C
outletMappedUniformInletFvPatchFields.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
...@@ -79,14 +113,20 @@ class outletMappedUniformInletFvPatchField ...@@ -79,14 +113,20 @@ class outletMappedUniformInletFvPatchField
: :
public fixedValueFvPatchField<Type> public fixedValueFvPatchField<Type>
{ {
// Private data // Private Data
//- Name of the outlet patch to be mapped //- Name of the outlet patch to be mapped
word outletPatchName_; word outletPatchName_;
//- Name of the flux transporting the field //- Name of operand flux field
word phiName_; word phiName_;
//- Fraction value
scalar fraction_;
//- Offset value
Type offset_;
public: public:
...@@ -112,7 +152,7 @@ public: ...@@ -112,7 +152,7 @@ public:
); );
//- Construct by mapping given outletMappedUniformInletFvPatchField //- Construct by mapping given outletMappedUniformInletFvPatchField
// onto a new patch //- onto a new patch
outletMappedUniformInletFvPatchField outletMappedUniformInletFvPatchField
( (
const outletMappedUniformInletFvPatchField<Type>&, const outletMappedUniformInletFvPatchField<Type>&,
...@@ -156,7 +196,7 @@ public: ...@@ -156,7 +196,7 @@ public:
} }
// Member functions // Member Functions
// Access // Access
...@@ -167,7 +207,7 @@ public: ...@@ -167,7 +207,7 @@ public:
} }
// Evaluation functions // Evaluation
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment