outletPhaseMeanVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "volFields.H"
29 #include "fieldMapper.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39  const dictionary& dict
40 )
41 :
42  mixedFvPatchField<vector>(p, iF, dict, false),
43  UnMean_
44  (
45  Function1<scalar>::New
46  (
47  "UnMean",
48  time().userUnits(),
50  dict
51  )
52  ),
53  alphaName_(dict.lookup("alpha"))
54 {
55  refValue() = Zero;
56  refGrad() = Zero;
57  valueFraction() = 0.0;
58 
59  if (dict.found("value"))
60  {
62  (
63  vectorField("value", iF.dimensions(), dict, p.size())
64  );
65  }
66  else
67  {
68  fvPatchVectorField::operator=(patchInternalField());
69  }
70 }
71 
72 
75 (
77  const fvPatch& p,
79  const fieldMapper& mapper
80 )
81 :
82  mixedFvPatchField<vector>(ptf, p, iF, mapper),
83  UnMean_(ptf.UnMean_, false),
84  alphaName_(ptf.alphaName_)
85 {}
86 
87 
90 (
93 )
94 :
95  mixedFvPatchField<vector>(ptf, iF),
96  UnMean_(ptf.UnMean_, false),
97  alphaName_(ptf.alphaName_)
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
104 {
105  if (updated())
106  {
107  return;
108  }
109 
110  scalarField alphap =
111  patch().lookupPatchField<volScalarField, scalar>(alphaName_);
112 
113  alphap = max(alphap, scalar(0));
114  alphap = min(alphap, scalar(1));
115 
116  // Get the patchInternalField (zero-gradient field)
117  vectorField Uzg(patchInternalField());
118 
119  // Calculate the phase mean zero-gradient normal velocity
120  const scalar UnzgMean =
121  gSum(alphap*(patch().Sf() & Uzg))
122  /gSum(alphap*patch().magSf());
123 
124  // Set the refValue and valueFraction to adjust the boundary field
125  // such that the phase mean is UnMean_
126  const scalar UnMean = UnMean_->value(time().value());
127  if (UnzgMean >= UnMean)
128  {
129  refValue() = Zero;
130  valueFraction() = 1.0 - UnMean/UnzgMean;
131  }
132  else
133  {
134  refValue() = (UnMean + UnzgMean)*patch().nf();
135  valueFraction() = 1.0 - UnzgMean/UnMean;
136  }
137 
139 }
140 
141 
143 (
144  Ostream& os
145 ) const
146 {
148 
149  writeEntry(os, time().userUnits(), dimVelocity, UnMean_());
150  writeEntry(os, "alpha", alphaName_);
151  writeEntry(os, "value", *this);
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 namespace Foam
158 {
160  (
163  );
164 }
165 
166 
167 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Run-time selectable general function of one variable.
Definition: Function1.H:62
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:235
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:255
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:208
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
This boundary condition provides a base class for 'mixed' type boundary conditions,...
This boundary condition adjusts the velocity for the given phase to achieve the specified mean thus c...
outletPhaseMeanVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const dimensionSet time
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
Type gSum(const UList< Type > &f, const label comm)
const dimensionSet & dimVelocity
Definition: dimensions.C:154
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Field< vector > vectorField
Specialisation of Field<T> for vector.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict
volScalarField & p
Foam::surfaceFields.