FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <finiteVolume/volFields.H>
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
37 template<class Type>
40 (
41  const fvPatch& p,
43 )
44 :
46  outletPatchName_(),
47  phiName_("phi")
48 {}
49 
50 
51 template<class Type>
54 (
56  const fvPatch& p,
58  const fvPatchFieldMapper& mapper
59 )
60 :
61  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
62  outletPatchName_(ptf.outletPatchName_),
63  phiName_(ptf.phiName_)
64 {}
65 
66 
67 template<class Type>
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
77  outletPatchName_(dict.lookup("outletPatchName")),
78  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
79 {}
80 
81 
82 template<class Type>
85 (
87 )
88 :
90  outletPatchName_(ptf.outletPatchName_),
91  phiName_(ptf.phiName_)
92 {}
93 
94 
95 
96 template<class Type>
99 (
102 )
103 :
105  outletPatchName_(ptf.outletPatchName_),
106  phiName_(ptf.phiName_)
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 template<class Type>
114 {
115  if (this->updated())
116  {
117  return;
118  }
119 
121  (
123  (
124  this->dimensionedInternalField()
125  )
126  );
127 
128  const fvPatch& p = this->patch();
129  label outletPatchID =
130  p.patch().boundaryMesh().findPatchID(outletPatchName_);
131 
132  if (outletPatchID < 0)
133  {
135  (
136  "void outletMappedUniformInletFvPatchField<Type>::updateCoeffs()"
137  ) << "Unable to find outlet patch " << outletPatchName_
138  << abort(FatalError);
139  }
140 
141  const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
142 
143  const fvPatchField<Type>& outletPatchField =
144  f.boundaryField()[outletPatchID];
145 
146  const surfaceScalarField& phi =
147  this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_);
148  const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
149  scalar sumOutletPatchPhi = gSum(outletPatchPhi);
150 
151  if (sumOutletPatchPhi > SMALL)
152  {
153  Type averageOutletField =
154  gSum(outletPatchPhi*outletPatchField)
155  /sumOutletPatchPhi;
156 
157  this->operator==(averageOutletField);
158  }
159  else
160  {
161  Type averageOutletField =
162  gSum(outletPatch.magSf()*outletPatchField)
163  /gSum(outletPatch.magSf());
164 
165  this->operator==(averageOutletField);
166  }
167 
169 }
170 
171 
172 template<class Type>
174 {
176  os.writeKeyword("outletPatchName")
177  << outletPatchName_ << token::END_STATEMENT << nl;
178  if (phiName_ != "phi")
179  {
180  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
181  }
182  this->writeEntry("value", os);
183 }
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace Foam
189 
190 // ************************************************************************* //