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-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"
28 #include "surfaceFields.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
35 (
36  const fvPatch& p,
38  const dictionary& dict
39 )
40 :
41  fixedValueFvPatchField<Type>(p, iF, dict),
42  outletPatchName_(dict.lookup("outletPatch")),
43  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
44 {}
45 
46 
47 template<class Type>
50 (
52  const fvPatch& p,
54  const fvPatchFieldMapper& mapper
55 )
56 :
57  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
58  outletPatchName_(ptf.outletPatchName_),
59  phiName_(ptf.phiName_)
60 {}
61 
62 
63 template<class Type>
66 (
69 )
70 :
71  fixedValueFvPatchField<Type>(ptf, iF),
72  outletPatchName_(ptf.outletPatchName_),
73  phiName_(ptf.phiName_)
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
79 template<class Type>
81 {
82  if (this->updated())
83  {
84  return;
85  }
86 
87  const VolField<Type>& f
88  (
89  dynamic_cast<const VolField<Type>&>
90  (
91  this->internalField()
92  )
93  );
94 
95  const fvPatch& p = this->patch();
96  label outletPatchID =
97  p.patch().boundaryMesh().findPatchID(outletPatchName_);
98 
99  if (outletPatchID < 0)
100  {
102  << "Unable to find outlet patch " << outletPatchName_
103  << abort(FatalError);
104  }
105 
106  const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
107 
108  const fvPatchField<Type>& outletPatchField =
109  f.boundaryField()[outletPatchID];
110 
111  const surfaceScalarField& phi =
112  this->db().objectRegistry::template lookupObject<surfaceScalarField>
113  (phiName_);
114 
115  const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
116  scalar sumOutletPatchPhi = gSum(outletPatchPhi);
117 
118  if (sumOutletPatchPhi > small)
119  {
120  Type averageOutletField =
121  gSum(outletPatchPhi*outletPatchField)
122  /sumOutletPatchPhi;
123 
124  this->operator==(averageOutletField);
125  }
126  else
127  {
128  Type averageOutletField =
129  gSum(outletPatch.magSf()*outletPatchField)
130  /gSum(outletPatch.magSf());
131 
132  this->operator==(averageOutletField);
133  }
134 
136 }
137 
138 
139 template<class Type>
141 {
143  writeEntry(os, "outletPatch", outletPatchName_);
144  if (phiName_ != "phi")
145  {
146  writeEntry(os, "phi", phiName_);
147  }
148  writeEntry(os, "value", *this);
149 }
150 
151 
152 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
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
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
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:142
This boundary condition averages the field over the "outlet" patch specified by name "outletPatch" an...
outletMappedUniformInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Type gSum(const FieldField< Field, Type > &f)
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
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
labelList f(nPoints)
dictionary dict
volScalarField & p
Foam::surfaceFields.