Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
finiteVolume
fields
fvPatchFields
derived
flowRateInletVelocity
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) 2006-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
26
#include "
flowRateInletVelocityFvPatchVectorField.H
"
27
#include <
finiteVolume/volFields.H
>
28
#include <
OpenFOAM/addToRunTimeSelectionTable.H
>
29
#include <
finiteVolume/fvPatchFieldMapper.H
>
30
#include <
finiteVolume/surfaceFields.H
>
31
32
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34
Foam::
35
flowRateInletVelocityFvPatchVectorField::
36
flowRateInletVelocityFvPatchVectorField
37
(
38
const
fvPatch
&
p
,
39
const
DimensionedField<vector, volMesh>
& iF
40
)
41
:
42
fixedValueFvPatchField<vector>
(
p
, iF),
43
flowRate_(0),
44
phiName_(
"phi"
),
45
rhoName_(
"rho"
)
46
{}
47
48
49
Foam::
50
flowRateInletVelocityFvPatchVectorField::
51
flowRateInletVelocityFvPatchVectorField
52
(
53
const
flowRateInletVelocityFvPatchVectorField
& ptf,
54
const
fvPatch
& p,
55
const
DimensionedField<vector, volMesh>
& iF,
56
const
fvPatchFieldMapper
& mapper
57
)
58
:
59
fixedValueFvPatchField<vector>
(ptf,
p
, iF, mapper),
60
flowRate_(ptf.flowRate_),
61
phiName_(ptf.phiName_),
62
rhoName_(ptf.rhoName_)
63
{}
64
65
66
Foam::
67
flowRateInletVelocityFvPatchVectorField::
68
flowRateInletVelocityFvPatchVectorField
69
(
70
const
fvPatch
& p,
71
const
DimensionedField<vector, volMesh>
& iF,
72
const
dictionary
& dict
73
)
74
:
75
fixedValueFvPatchField<vector>
(
p
, iF, dict),
76
flowRate_(
readScalar
(dict.
lookup
(
"flowRate"
))),
77
phiName_(dict.
lookupOrDefault
<
word
>(
"phi"
,
"phi"
)),
78
rhoName_(dict.
lookupOrDefault
<
word
>(
"rho"
,
"rho"
))
79
{}
80
81
82
Foam::
83
flowRateInletVelocityFvPatchVectorField::
84
flowRateInletVelocityFvPatchVectorField
85
(
86
const
flowRateInletVelocityFvPatchVectorField
& ptf
87
)
88
:
89
fixedValueFvPatchField<vector>
(ptf),
90
flowRate_(ptf.flowRate_),
91
phiName_(ptf.phiName_),
92
rhoName_(ptf.rhoName_)
93
{}
94
95
96
Foam::
97
flowRateInletVelocityFvPatchVectorField::
98
flowRateInletVelocityFvPatchVectorField
99
(
100
const
flowRateInletVelocityFvPatchVectorField
& ptf,
101
const
DimensionedField<vector, volMesh>
& iF
102
)
103
:
104
fixedValueFvPatchField<vector>
(ptf, iF),
105
flowRate_(ptf.flowRate_),
106
phiName_(ptf.phiName_),
107
rhoName_(ptf.rhoName_)
108
{}
109
110
111
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112
113
void
Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs
()
114
{
115
if
(updated())
116
{
117
return
;
118
}
119
120
// a simpler way of doing this would be nice
121
scalar avgU = -flowRate_/
gSum
(patch().magSf());
122
123
vectorField
n = patch().nf();
124
125
const
surfaceScalarField
&
phi
=
126
db().lookupObject<
surfaceScalarField
>(phiName_);
127
128
if
(phi.
dimensions
() ==
dimVelocity
*
dimArea
)
129
{
130
// volumetric flow-rate
131
operator==
(n*avgU);
132
}
133
else
if
(phi.
dimensions
() ==
dimDensity
*
dimVelocity
*
dimArea
)
134
{
135
const
fvPatchField<scalar>
& rhop =
136
patch().lookupPatchField<
volScalarField
, scalar>(rhoName_);
137
138
// mass flow-rate
139
operator==
(n*avgU/rhop);
140
}
141
else
142
{
143
FatalErrorIn
144
(
145
"flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
146
) <<
"dimensions of "
<< phiName_ <<
" are incorrect"
<<
nl
147
<<
" on patch "
<< this->patch().name()
148
<<
" of field "
<< this->dimensionedInternalField().name()
149
<<
" in file "
<< this->dimensionedInternalField().objectPath()
150
<<
nl
<<
exit
(
FatalError
);
151
}
152
153
fixedValueFvPatchField<vector>::updateCoeffs
();
154
}
155
156
157
void
Foam::flowRateInletVelocityFvPatchVectorField::write
(
Ostream
& os)
const
158
{
159
fvPatchField<vector>::write
(os);
160
os.
writeKeyword
(
"flowRate"
) << flowRate_ <<
token::END_STATEMENT
<<
nl
;
161
if
(phiName_ !=
"phi"
)
162
{
163
os.
writeKeyword
(
"phi"
) << phiName_ <<
token::END_STATEMENT
<<
nl
;
164
}
165
if
(rhoName_ !=
"rho"
)
166
{
167
os.
writeKeyword
(
"rho"
) << rhoName_ <<
token::END_STATEMENT
<<
nl
;
168
}
169
writeEntry(
"value"
, os);
170
}
171
172
173
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175
namespace
Foam
176
{
177
makePatchTypeField
178
(
179
fvPatchVectorField
,
180
flowRateInletVelocityFvPatchVectorField
181
);
182
}
183
184
185
// ************************ vim: set sw=4 sts=4 et: ************************ //