outletMappedUniformInletFvPatchField.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) 2011 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 (
51  const fvPatch& p,
53  const fvPatchFieldMapper& mapper
54 )
55 :
56  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
57  outletPatchName_(ptf.outletPatchName_),
58  phiName_(ptf.phiName_)
59 {}
60 
61 
62 template<class Type>
65 (
66  const fvPatch& p,
68  const dictionary& dict
69 )
70 :
72  outletPatchName_(dict.lookup("outletPatchName")),
73  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
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  (
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  (
131  "void outletMappedUniformInletFvPatchField<Type>::updateCoeffs()"
132  ) << "Unable to find outlet patch " << outletPatchName_
133  << abort(FatalError);
134  }
135 
136  const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
137 
138  const fvPatchField<Type>& outletPatchField =
139  f.boundaryField()[outletPatchID];
140 
141  const surfaceScalarField& phi =
142  this->db().objectRegistry::template lookupObject<surfaceScalarField>
143  (phiName_);
144 
145  const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
146  scalar sumOutletPatchPhi = gSum(outletPatchPhi);
147 
148  if (sumOutletPatchPhi > SMALL)
149  {
150  Type averageOutletField =
151  gSum(outletPatchPhi*outletPatchField)
152  /sumOutletPatchPhi;
153 
154  this->operator==(averageOutletField);
155  }
156  else
157  {
158  Type averageOutletField =
159  gSum(outletPatch.magSf()*outletPatchField)
160  /gSum(outletPatch.magSf());
161 
162  this->operator==(averageOutletField);
163  }
164 
166 }
167 
168 
169 template<class Type>
171 {
173  os.writeKeyword("outletPatchName")
174  << outletPatchName_ << token::END_STATEMENT << nl;
175  if (phiName_ != "phi")
176  {
177  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
178  }
179  this->writeEntry("value", os);
180 }
181 
182 
183 // ************************************************************************* //
Foam::surfaceFields.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
labelList f(nPoints)
A class for handling words, derived from string.
Definition: word.H:59
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
Foam::fvPatchFieldMapper.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
outletMappedUniformInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
runTime write()
Type gSum(const FieldField< Field, Type > &f)
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:143
dictionary dict
static const char nl
Definition: Ostream.H:260
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:185
volScalarField & p
Definition: createFields.H:51
This boundary conditon averages the field over the "outlet" patch specified by name "outletPatchName"...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
surfaceScalarField & phi
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
rDeltaT dimensionedInternalField()
Generic GeometricField class.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:136
label findPatchID(const word &patchName) const
Find patch index given a name.