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-2023 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  const dictionary& dict
40 )
41 :
42  mixedFvPatchField<vector>(p, iF, dict, false),
43  UnMean_(Function1<scalar>::New("UnMean", dict)),
44  alphaName_(dict.lookup("alpha"))
45 {
46  refValue() = Zero;
47  refGrad() = Zero;
48  valueFraction() = 0.0;
49 
50  if (dict.found("value"))
51  {
53  (
54  vectorField("value", dict, p.size())
55  );
56  }
57  else
58  {
59  fvPatchVectorField::operator=(patchInternalField());
60  }
61 }
62 
63 
66 (
68  const fvPatch& p,
70  const fvPatchFieldMapper& mapper
71 )
72 :
73  mixedFvPatchField<vector>(ptf, p, iF, mapper),
74  UnMean_(ptf.UnMean_, false),
75  alphaName_(ptf.alphaName_)
76 {}
77 
78 
81 (
84 )
85 :
86  mixedFvPatchField<vector>(ptf, iF),
87  UnMean_(ptf.UnMean_, false),
88  alphaName_(ptf.alphaName_)
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 {
96  if (updated())
97  {
98  return;
99  }
100 
101  const scalar t = this->db().time().userTimeValue();
102 
103  scalarField alphap =
104  patch().lookupPatchField<volScalarField, scalar>(alphaName_);
105 
106  alphap = max(alphap, scalar(0));
107  alphap = min(alphap, scalar(1));
108 
109  // Get the patchInternalField (zero-gradient field)
110  vectorField Uzg(patchInternalField());
111 
112  // Calculate the phase mean zero-gradient normal velocity
113  const scalar UnzgMean =
114  gSum(alphap*(patch().Sf() & Uzg))
115  /gSum(alphap*patch().magSf());
116 
117  // Set the refValue and valueFraction to adjust the boundary field
118  // such that the phase mean is UnMean_
119  const scalar UnMean = UnMean_->value(t);
120  if (UnzgMean >= UnMean)
121  {
122  refValue() = Zero;
123  valueFraction() = 1.0 - UnMean/UnzgMean;
124  }
125  else
126  {
127  refValue() = (UnMean + UnzgMean)*patch().nf();
128  valueFraction() = 1.0 - UnzgMean/UnMean;
129  }
130 
132 }
133 
134 
136 (
137  Ostream& os
138 ) const
139 {
141 
142  writeEntry(os, UnMean_());
143  writeEntry(os, "alpha", alphaName_);
144  writeEntry(os, "value", *this);
145 }
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 namespace Foam
151 {
153  (
156  );
157 }
158 
159 
160 // ************************************************************************* //
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...
Run-time selectable general function of one variable.
Definition: Function1.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:231
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:251
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
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...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
outletPhaseMeanVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
Type gSum(const FieldField< Field, Type > &f)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< vector > vectorField
Specialisation of Field<T> for vector.
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
dictionary dict
volScalarField & p
Foam::surfaceFields.