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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
43  outletPatchName_(),
44  phiName_("phi")
45 {}
46 
47 
48 template<class Type>
51 (
52  const fvPatch& p,
54  const dictionary& dict
55 )
56 :
58  outletPatchName_(dict.lookup("outletPatch")),
59  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
60 {}
61 
62 
63 template<class Type>
66 (
68  const fvPatch& p,
70  const fvPatchFieldMapper& mapper
71 )
72 :
73  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
74  outletPatchName_(ptf.outletPatchName_),
75  phiName_(ptf.phiName_)
76 {}
77 
78 
79 template<class Type>
82 (
84 )
85 :
87  outletPatchName_(ptf.outletPatchName_),
88  phiName_(ptf.phiName_)
89 {}
90 
91 
92 
93 template<class Type>
96 (
99 )
100 :
102  outletPatchName_(ptf.outletPatchName_),
103  phiName_(ptf.phiName_)
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
109 template<class Type>
111 {
112  if (this->updated())
113  {
114  return;
115  }
116 
118  (
120  (
121  this->internalField()
122  )
123  );
124 
125  const fvPatch& p = this->patch();
126  label outletPatchID =
127  p.patch().boundaryMesh().findPatchID(outletPatchName_);
128 
129  if (outletPatchID < 0)
130  {
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.writeEntry("outletPatch", outletPatchName_);
174  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
175  this->writeEntry("value", os);
176 }
177 
178 
179 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
volFields.H
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:231
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::outletMappedUniformInletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: outletMappedUniformInletFvPatchField.C:170
surfaceFields.H
Foam::surfaceFields.
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:594
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:80
Foam::outletMappedUniformInletFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: outletMappedUniformInletFvPatchField.C:110
Foam::label
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:62
Foam::Field< scalar >
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::outletMappedUniformInletFvPatchField
This boundary conditon averages the field over the "outlet" patch specified by name "outletPatch" and...
Definition: outletMappedUniformInletFvPatchField.H:92
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
f
labelList f(nPoints)
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
outletMappedUniformInletFvPatchField.H
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::outletMappedUniformInletFvPatchField::outletMappedUniformInletFvPatchField
outletMappedUniformInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: outletMappedUniformInletFvPatchField.C:37
Foam::fvPatch::magSf
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:132
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54