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-2020 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 (
83 )
84 :
86  outletPatchName_(ptf.outletPatchName_),
87  phiName_(ptf.phiName_)
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 template<class Type>
95 {
96  if (this->updated())
97  {
98  return;
99  }
100 
102  (
104  (
105  this->internalField()
106  )
107  );
108 
109  const fvPatch& p = this->patch();
110  label outletPatchID =
111  p.patch().boundaryMesh().findPatchID(outletPatchName_);
112 
113  if (outletPatchID < 0)
114  {
116  << "Unable to find outlet patch " << outletPatchName_
117  << abort(FatalError);
118  }
119 
120  const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
121 
122  const fvPatchField<Type>& outletPatchField =
123  f.boundaryField()[outletPatchID];
124 
125  const surfaceScalarField& phi =
126  this->db().objectRegistry::template lookupObject<surfaceScalarField>
127  (phiName_);
128 
129  const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
130  scalar sumOutletPatchPhi = gSum(outletPatchPhi);
131 
132  if (sumOutletPatchPhi > small)
133  {
134  Type averageOutletField =
135  gSum(outletPatchPhi*outletPatchField)
136  /sumOutletPatchPhi;
137 
138  this->operator==(averageOutletField);
139  }
140  else
141  {
142  Type averageOutletField =
143  gSum(outletPatch.magSf()*outletPatchField)
144  /gSum(outletPatch.magSf());
145 
146  this->operator==(averageOutletField);
147  }
148 
150 }
151 
152 
153 template<class Type>
155 {
157  writeEntry(os, "outletPatch", outletPatchName_);
158  if (phiName_ != "phi")
159  {
160  writeEntry(os, "phi", phiName_);
161  }
162  writeEntry(os, "value", *this);
163 }
164 
165 
166 // ************************************************************************* //
Foam::surfaceFields.
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:180
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
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:142
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:291
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:62
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.
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:138
Foam::fvPatchFieldMapper.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
phi
Definition: correctPhi.H:3
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:54
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:844