outletPhaseMeanVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2013 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  Umean_(0),
43  alphaName_("none")
44 {
45  refValue() = vector::zero;
46  refGrad() = vector::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  Umean_(ptf.Umean_),
62  alphaName_(ptf.alphaName_)
63 {}
64 
65 
68 (
69  const fvPatch& p,
71  const dictionary& dict
72 )
73 :
75  Umean_(readScalar(dict.lookup("Umean"))),
76  alphaName_(dict.lookup("alpha"))
77 {
78  refValue() = vector::zero;
79  refGrad() = vector::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  Umean_(ptf.Umean_),
104  alphaName_(ptf.alphaName_)
105 {}
106 
107 
110 (
113 )
114 :
115  mixedFvPatchField<vector>(ptf, iF),
116  Umean_(ptf.Umean_),
117  alphaName_(ptf.alphaName_)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
124 {
125  if (updated())
126  {
127  return;
128  }
129 
130  scalarField alphap =
131  patch().lookupPatchField<volScalarField, scalar>(alphaName_);
132 
133  alphap = max(alphap, scalar(0));
134  alphap = min(alphap, scalar(1));
135 
136  // Get the patchInternalField (zero-gradient field)
137  vectorField Uzg(patchInternalField());
138 
139  // Calculate the phase mean zero-gradient velocity
140  scalar Uzgmean =
141  gSum(alphap*(patch().Sf() & Uzg))
142  /gSum(alphap*patch().magSf());
143 
144  // Set the refValue and valueFraction to adjust the boundary field
145  // such that the phase mean is Umean_
146  if (Uzgmean >= Umean_)
147  {
148  refValue() = vector::zero;
149  valueFraction() = 1.0 - Umean_/Uzgmean;
150  }
151  else
152  {
153  refValue() = (Umean_ + Uzgmean)*patch().nf();
154  valueFraction() = 1.0 - Uzgmean/Umean_;
155  }
156 
158 }
159 
160 
162 (
163  Ostream& os
164 ) const
165 {
167 
168  os.writeKeyword("Umean") << Umean_
169  << token::END_STATEMENT << nl;
170  os.writeKeyword("alpha") << alphaName_
171  << token::END_STATEMENT << nl;
172  writeEntry("value", os);
173 }
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 namespace Foam
179 {
181  (
184  );
185 }
186 
187 
188 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
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.
Foam::surfaceFields.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
#define readScalar
Definition: doubleScalar.C:38
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:301
This boundary condition adjusts the velocity for the given phase to achieve the specified mean thus c...
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::fvPatchFieldMapper.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:354
Namespace for OpenFOAM.
Type gSum(const FieldField< Field, Type > &f)
static const char nl
Definition: Ostream.H:260
volVectorField vectorField(fieldObject, mesh)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
volScalarField & p
Definition: createFields.H:51
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Macros for easy insertion into run-time selection tables.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
static const Vector zero
Definition: Vector.H:80
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
outletPhaseMeanVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.