flowRateInletVelocityFvPatchVectorField.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-2015 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"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
42  flowRate_(new DataEntry<scalar>("massFlowRate")),
43  volumetric_(false),
44  rhoName_("rho"),
45  rhoInlet_(0.0)
46 {}
47 
48 
51 (
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
59  flowRate_(ptf.flowRate_, false),
60  volumetric_(ptf.volumetric_),
61  rhoName_(ptf.rhoName_),
62  rhoInlet_(ptf.rhoInlet_)
63 {}
64 
65 
68 (
69  const fvPatch& p,
71  const dictionary& dict
72 )
73 :
75  rhoInlet_(dict.lookupOrDefault<scalar>("rhoInlet", -VGREAT))
76 {
77  if (dict.found("volumetricFlowRate"))
78  {
79  volumetric_ = true;
80  flowRate_ = DataEntry<scalar>::New("volumetricFlowRate", dict);
81  rhoName_ = "rho";
82  }
83  else if (dict.found("massFlowRate"))
84  {
85  volumetric_ = false;
86  flowRate_ = DataEntry<scalar>::New("massFlowRate", dict);
87  rhoName_ = word(dict.lookupOrDefault<word>("rho", "rho"));
88  }
89  else
90  {
92  (
93  dict
94  ) << "Please supply either 'volumetricFlowRate' or"
95  << " 'massFlowRate' and 'rho'" << exit(FatalIOError);
96  }
97 
98  // Value field require if mass based
99  if (dict.found("value"))
100  {
102  (
103  vectorField("value", dict, p.size())
104  );
105  }
106  else
107  {
108  evaluate(Pstream::blocking);
109  }
110 }
111 
112 
115 (
117 )
118 :
120  flowRate_(ptf.flowRate_, false),
121  volumetric_(ptf.volumetric_),
122  rhoName_(ptf.rhoName_),
123  rhoInlet_(ptf.rhoInlet_)
124 {}
125 
126 
129 (
132 )
133 :
135  flowRate_(ptf.flowRate_, false),
136  volumetric_(ptf.volumetric_),
137  rhoName_(ptf.rhoName_),
138  rhoInlet_(ptf.rhoInlet_)
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
145 {
146  if (updated())
147  {
148  return;
149  }
150 
151  const scalar t = db().time().timeOutputValue();
152 
153  // a simpler way of doing this would be nice
154  const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf());
155 
156  tmp<vectorField> n = patch().nf();
157 
158  if (volumetric_ || rhoName_ == "none")
159  {
160  // volumetric flow-rate or density not given
161  operator==(n*avgU);
162  }
163  else
164  {
165  // mass flow-rate
166  if (db().foundObject<volScalarField>(rhoName_))
167  {
168  const fvPatchField<scalar>& rhop =
169  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
170 
171  operator==(n*avgU/rhop);
172  }
173  else
174  {
175  // Use constant density
176  if (rhoInlet_ < 0)
177  {
179  << "Did not find registered density field " << rhoName_
180  << " and no constant density 'rhoInlet' specified"
181  << exit(FatalError);
182  }
183  operator==(n*avgU/rhoInlet_);
184  }
185  }
186 
187  fixedValueFvPatchVectorField::updateCoeffs();
188 }
189 
190 
192 {
194  flowRate_->writeData(os);
195  if (!volumetric_)
196  {
197  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
198  writeEntryIfDifferent<scalar>(os, "rhoInlet", -VGREAT, rhoInlet_);
199  }
200  writeEntry("value", os);
201 }
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 namespace Foam
207 {
209  (
212  );
213 }
214 
215 
216 // ************************************************************************* //
flowRateInletVelocityFvPatchVectorField.H
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Foam::flowRateInletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: flowRateInletVelocityFvPatchVectorField.C:191
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::flowRateInletVelocityFvPatchVectorField::rhoInlet_
scalar rhoInlet_
Rho initialisation value (for start; if value not supplied)
Definition: flowRateInletVelocityFvPatchVectorField.H:143
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::FatalIOError
IOerror FatalIOError
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:79
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::flowRateInletVelocityFvPatchVectorField::flowRateInletVelocityFvPatchVectorField
flowRateInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: flowRateInletVelocityFvPatchVectorField.C:36
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
vectorField
volVectorField vectorField(fieldObject, mesh)
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::flowRateInletVelocityFvPatchVectorField::volumetric_
bool volumetric_
Is volumetric?
Definition: flowRateInletVelocityFvPatchVectorField.H:137
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: flowRateInletVelocityFvPatchVectorField.C:144
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::flowRateInletVelocityFvPatchVectorField::rhoName_
word rhoName_
Name of the density field used to normalize the mass flux.
Definition: flowRateInletVelocityFvPatchVectorField.H:140
Foam::flowRateInletVelocityFvPatchVectorField
This boundary condition provides a velocity boundary condition, derived from the flux (volumetric or ...
Definition: flowRateInletVelocityFvPatchVectorField.H:127
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
Foam::flowRateInletVelocityFvPatchVectorField::flowRate_
autoPtr< DataEntry< scalar > > flowRate_
Inlet integral flow rate.
Definition: flowRateInletVelocityFvPatchVectorField.H:134
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51