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-2021 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 "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
42  UnMean_(nullptr),
43  alphaName_("none")
44 {
45  refValue() = Zero;
46  refGrad() = Zero;
47  valueFraction() = 0.0;
48 }
49 
50 
53 (
54  const fvPatch& p,
56  const dictionary& dict
57 )
58 :
60  UnMean_(Function1<scalar>::New("UnMean", dict)),
61  alphaName_(dict.lookup("alpha"))
62 {
63  refValue() = Zero;
64  refGrad() = Zero;
65  valueFraction() = 0.0;
66 
67  if (dict.found("value"))
68  {
69  fvPatchVectorField::operator=
70  (
71  vectorField("value", dict, p.size())
72  );
73  }
74  else
75  {
76  fvPatchVectorField::operator=(patchInternalField());
77  }
78 }
79 
80 
83 (
85  const fvPatch& p,
87  const fvPatchFieldMapper& mapper
88 )
89 :
90  mixedFvPatchField<vector>(ptf, p, iF, mapper),
91  UnMean_(ptf.UnMean_, false),
92  alphaName_(ptf.alphaName_)
93 {}
94 
95 
98 (
101 )
102 :
103  mixedFvPatchField<vector>(ptf, iF),
104  UnMean_(ptf.UnMean_, false),
105  alphaName_(ptf.alphaName_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 {
113  if (updated())
114  {
115  return;
116  }
117 
118  const scalar t = this->db().time().userTimeValue();
119 
120  scalarField alphap =
121  patch().lookupPatchField<volScalarField, scalar>(alphaName_);
122 
123  alphap = max(alphap, scalar(0));
124  alphap = min(alphap, scalar(1));
125 
126  // Get the patchInternalField (zero-gradient field)
127  vectorField Uzg(patchInternalField());
128 
129  // Calculate the phase mean zero-gradient normal velocity
130  const scalar UnzgMean =
131  gSum(alphap*(patch().Sf() & Uzg))
132  /gSum(alphap*patch().magSf());
133 
134  // Set the refValue and valueFraction to adjust the boundary field
135  // such that the phase mean is UnMean_
136  const scalar UnMean = UnMean_->value(t);
137  if (UnzgMean >= UnMean)
138  {
139  refValue() = Zero;
140  valueFraction() = 1.0 - UnMean/UnzgMean;
141  }
142  else
143  {
144  refValue() = (UnMean + UnzgMean)*patch().nf();
145  valueFraction() = 1.0 - UnzgMean/UnMean;
146  }
147 
149 }
150 
151 
153 (
154  Ostream& os
155 ) const
156 {
158 
159  writeEntry(os, UnMean_());
160  writeEntry(os, "alpha", alphaName_);
161  writeEntry(os, "value", *this);
162 }
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 namespace Foam
168 {
170  (
173  );
174 }
175 
176 
177 // ************************************************************************* //
outletPhaseMeanVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Foam::surfaceFields.
Run-time selectable general function of one variable.
Definition: Function1.H:52
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
This boundary condition adjusts the velocity for the given phase to achieve the specified mean thus c...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
volVectorField vectorField(fieldObject, mesh)
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:243
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
Type gSum(const FieldField< Field, Type > &f)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Foam::fvPatchFieldMapper.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
static const zero Zero
Definition: zero.H:97
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:216
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864