outletMappedUniformInletFvPatchField.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) 2011-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"
28 #include "surfaceFields.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
41  outletPatchName_(),
42  phiName_("phi")
43 {}
44 
45 
46 template<class Type>
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
56  outletPatchName_(dict.lookup("outletPatch")),
57  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
58 {}
59 
60 
61 template<class Type>
64 (
66  const fvPatch& p,
68  const fvPatchFieldMapper& mapper
69 )
70 :
71  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
72  outletPatchName_(ptf.outletPatchName_),
73  phiName_(ptf.phiName_)
74 {}
75 
76 
77 template<class Type>
80 (
82 )
83 :
85  outletPatchName_(ptf.outletPatchName_),
86  phiName_(ptf.phiName_)
87 {}
88 
89 
90 
91 template<class Type>
94 (
97 )
98 :
100  outletPatchName_(ptf.outletPatchName_),
101  phiName_(ptf.phiName_)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 template<class Type>
109 {
110  if (this->updated())
111  {
112  return;
113  }
114 
116  (
118  (
119  this->internalField()
120  )
121  );
122 
123  const fvPatch& p = this->patch();
124  label outletPatchID =
125  p.patch().boundaryMesh().findPatchID(outletPatchName_);
126 
127  if (outletPatchID < 0)
128  {
130  << "Unable to find outlet patch " << outletPatchName_
131  << abort(FatalError);
132  }
133 
134  const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
135 
136  const fvPatchField<Type>& outletPatchField =
137  f.boundaryField()[outletPatchID];
138 
139  const surfaceScalarField& phi =
140  this->db().objectRegistry::template lookupObject<surfaceScalarField>
141  (phiName_);
142 
143  const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
144  scalar sumOutletPatchPhi = gSum(outletPatchPhi);
145 
146  if (sumOutletPatchPhi > small)
147  {
148  Type averageOutletField =
149  gSum(outletPatchPhi*outletPatchField)
150  /sumOutletPatchPhi;
151 
152  this->operator==(averageOutletField);
153  }
154  else
155  {
156  Type averageOutletField =
157  gSum(outletPatch.magSf()*outletPatchField)
158  /gSum(outletPatch.magSf());
159 
160  this->operator==(averageOutletField);
161  }
162 
164 }
165 
166 
167 template<class Type>
169 {
171  writeEntry(os, "outletPatch", outletPatchName_);
172  if (phiName_ != "phi")
173  {
174  writeEntry(os, "phi", phiName_);
175  }
176  writeEntry(os, "value", *this);
177 }
178 
179 
180 // ************************************************************************* //
Foam::surfaceFields.
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:179
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
surfaceScalarField & phi
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:136
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
This boundary condition averages the field over the "outlet" patch specified by name "outletPatch" an...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
label findPatchID(const word &patchName) const
Find patch index given a name.
Generic GeometricField class.
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
Type gSum(const FieldField< Field, Type > &f)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:137
Foam::fvPatchFieldMapper.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
labelList f(nPoints)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
outletMappedUniformInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:583