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-2018 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  ramp_(),
44  alphaName_("none")
45 {
46  refValue() = Zero;
47  refGrad() = Zero;
48  valueFraction() = 0.0;
49 }
50 
51 
54 (
56  const fvPatch& p,
58  const fvPatchFieldMapper& mapper
59 )
60 :
61  mixedFvPatchField<vector>(ptf, p, iF, mapper),
62  Umean_(ptf.Umean_),
63  ramp_(ptf.ramp_, false),
64  alphaName_(ptf.alphaName_)
65 {}
66 
67 
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
77  Umean_(readScalar(dict.lookup("Umean"))),
78  ramp_
79  (
80  dict.found("ramp")
81  ? Function1<scalar>::New("ramp", dict)
82  : autoPtr<Function1<scalar>>()
83  ),
84  alphaName_(dict.lookup("alpha"))
85 {
86  refValue() = Zero;
87  refGrad() = Zero;
88  valueFraction() = 0.0;
89 
90  if (dict.found("value"))
91  {
92  fvPatchVectorField::operator=
93  (
94  vectorField("value", dict, p.size())
95  );
96  }
97  else
98  {
99  fvPatchVectorField::operator=(patchInternalField());
100  }
101 }
102 
103 
106 (
108 )
109 :
111  Umean_(ptf.Umean_),
112  ramp_(ptf.ramp_, false),
113  alphaName_(ptf.alphaName_)
114 {}
115 
116 
119 (
122 )
123 :
124  mixedFvPatchField<vector>(ptf, iF),
125  Umean_(ptf.Umean_),
126  ramp_(ptf.ramp_, false),
127  alphaName_(ptf.alphaName_)
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
132 
134 {
135  if (updated())
136  {
137  return;
138  }
139 
140  const scalar t = this->db().time().timeOutputValue();
141 
142  scalarField alphap =
143  patch().lookupPatchField<volScalarField, scalar>(alphaName_);
144 
145  alphap = max(alphap, scalar(0));
146  alphap = min(alphap, scalar(1));
147 
148  // Get the patchInternalField (zero-gradient field)
149  vectorField Uzg(patchInternalField());
150 
151  // Calculate the phase mean zero-gradient velocity
152  scalar Uzgmean =
153  gSum(alphap*(patch().Sf() & Uzg))
154  /gSum(alphap*patch().magSf());
155 
156  // Set the refValue and valueFraction to adjust the boundary field
157  // such that the phase mean is Umean_
158  const scalar Umean = (ramp_.valid() ? ramp_->value(t) : 1)*Umean_;
159  if (Uzgmean >= Umean)
160  {
161  refValue() = Zero;
162  valueFraction() = 1.0 - Umean/Uzgmean;
163  }
164  else
165  {
166  refValue() = (Umean + Uzgmean)*patch().nf();
167  valueFraction() = 1.0 - Uzgmean/Umean;
168  }
169 
171 }
172 
173 
175 (
176  Ostream& os
177 ) const
178 {
180 
181  os.writeKeyword("Umean") << Umean_ << token::END_STATEMENT << nl;
182  if (ramp_.valid())
183  {
184  ramp_->writeData(os);
185  }
186  os.writeKeyword("alpha") << alphaName_ << token::END_STATEMENT << nl;
187  writeEntry("value", os);
188 }
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 namespace Foam
194 {
196  (
199  );
200 }
201 
202 
203 // ************************************************************************* //
outletPhaseMeanVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
#define readScalar
Definition: doubleScalar.C:38
Foam::surfaceFields.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:431
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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:362
Macros for easy insertion into run-time selection tables.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
stressControl lookup("compactNormalStress") >> compactNormalStress
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
static const char nl
Definition: Ostream.H:265
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:311
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
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:576