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-2019 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 (
55  const fvPatch& p,
57  const fvPatchFieldMapper& mapper
58 )
59 :
60  mixedFvPatchField<vector>(ptf, p, iF, mapper),
61  UnMean_(ptf.UnMean_, false),
62  alphaName_(ptf.alphaName_)
63 {}
64 
65 
68 (
69  const fvPatch& p,
71  const dictionary& dict
72 )
73 :
75  UnMean_(Function1<scalar>::New("UnMean", dict)),
76  alphaName_(dict.lookup("alpha"))
77 {
78  refValue() = Zero;
79  refGrad() = Zero;
80  valueFraction() = 0.0;
81 
82  if (dict.found("value"))
83  {
84  fvPatchVectorField::operator=
85  (
86  vectorField("value", dict, p.size())
87  );
88  }
89  else
90  {
91  fvPatchVectorField::operator=(patchInternalField());
92  }
93 }
94 
95 
98 (
100 )
101 :
103  UnMean_(ptf.UnMean_, false),
104  alphaName_(ptf.alphaName_)
105 {}
106 
107 
110 (
113 )
114 :
115  mixedFvPatchField<vector>(ptf, iF),
116  UnMean_(ptf.UnMean_, false),
117  alphaName_(ptf.alphaName_)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
124 {
125  if (updated())
126  {
127  return;
128  }
129 
130  const scalar t = this->db().time().timeOutputValue();
131 
132  scalarField alphap =
133  patch().lookupPatchField<volScalarField, scalar>(alphaName_);
134 
135  alphap = max(alphap, scalar(0));
136  alphap = min(alphap, scalar(1));
137 
138  // Get the patchInternalField (zero-gradient field)
139  vectorField Uzg(patchInternalField());
140 
141  // Calculate the phase mean zero-gradient normal velocity
142  const scalar UnzgMean =
143  gSum(alphap*(patch().Sf() & Uzg))
144  /gSum(alphap*patch().magSf());
145 
146  // Set the refValue and valueFraction to adjust the boundary field
147  // such that the phase mean is UnMean_
148  const scalar UnMean = UnMean_->value(t);
149  if (UnzgMean >= UnMean)
150  {
151  refValue() = Zero;
152  valueFraction() = 1.0 - UnMean/UnzgMean;
153  }
154  else
155  {
156  refValue() = (UnMean + UnzgMean)*patch().nf();
157  valueFraction() = 1.0 - UnzgMean/UnMean;
158  }
159 
161 }
162 
163 
165 (
166  Ostream& os
167 ) const
168 {
170 
171  writeEntry(os, UnMean_());
172  writeEntry(os, "alpha", alphaName_);
173  writeEntry(os, "value", *this);
174 }
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 namespace Foam
180 {
182  (
185  );
186 }
187 
188 
189 // ************************************************************************* //
outletPhaseMeanVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Foam::surfaceFields.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:53
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:438
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
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:61
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:280
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Type gSum(const FieldField< Field, Type > &f)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Foam::fvPatchFieldMapper.
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:53
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:229
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
mesh Sf()
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:583