FreeFOAM The Cross-Platform CFD Toolkit
pressureDirectedInletVelocityFvPatchVectorField.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) 1991-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 
29 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
41 (
42  const fvPatch& p,
44 )
45 :
46  fixedValueFvPatchVectorField(p, iF),
47  phiName_("phi"),
48  rhoName_("rho"),
49  inletDir_(p.size())
50 {}
51 
52 
55 (
57  const fvPatch& p,
59  const fvPatchFieldMapper& mapper
60 )
61 :
62  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
63  phiName_(ptf.phiName_),
64  rhoName_(ptf.rhoName_),
65  inletDir_(ptf.inletDir_, mapper)
66 {}
67 
68 
71 (
72  const fvPatch& p,
74  const dictionary& dict
75 )
76 :
77  fixedValueFvPatchVectorField(p, iF),
78  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
79  rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
80  inletDir_("inletDirection", dict, p.size())
81 {
82  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
83 }
84 
85 
88 (
90 )
91 :
92  fixedValueFvPatchVectorField(pivpvf),
93  phiName_(pivpvf.phiName_),
94  rhoName_(pivpvf.rhoName_),
95  inletDir_(pivpvf.inletDir_)
96 {}
97 
98 
101 (
104 )
105 :
106  fixedValueFvPatchVectorField(pivpvf, iF),
107  phiName_(pivpvf.phiName_),
108  rhoName_(pivpvf.rhoName_),
109  inletDir_(pivpvf.inletDir_)
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 (
117  const fvPatchFieldMapper& m
118 )
119 {
120  fixedValueFvPatchVectorField::autoMap(m);
121  inletDir_.autoMap(m);
122 }
123 
124 
126 (
127  const fvPatchVectorField& ptf,
128  const labelList& addr
129 )
130 {
131  fixedValueFvPatchVectorField::rmap(ptf, addr);
132 
134  refCast<const pressureDirectedInletVelocityFvPatchVectorField>(ptf);
135 
136  inletDir_.rmap(tiptf.inletDir_, addr);
137 }
138 
139 
141 {
142  if (updated())
143  {
144  return;
145  }
146 
147  const surfaceScalarField& phi =
148  db().lookupObject<surfaceScalarField>(phiName_);
149 
150  const fvsPatchField<scalar>& phip =
151  patch().patchField<surfaceScalarField, scalar>(phi);
152 
153  vectorField n = patch().nf();
154  scalarField ndmagS = (n & inletDir_)*patch().magSf();
155 
156  if (phi.dimensions() == dimVelocity*dimArea)
157  {
158  operator==(inletDir_*phip/ndmagS);
159  }
160  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
161  {
162  const fvPatchField<scalar>& rhop =
163  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
164 
165  operator==(inletDir_*phip/(rhop*ndmagS));
166  }
167  else
168  {
170  (
171  "pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()"
172  ) << "dimensions of phi are not correct"
173  << "\n on patch " << this->patch().name()
174  << " of field " << this->dimensionedInternalField().name()
175  << " in file " << this->dimensionedInternalField().objectPath()
176  << exit(FatalError);
177  }
178 
180 }
181 
182 
184 {
186  if (phiName_ != "phi")
187  {
188  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
189  }
190  if (rhoName_ != "rho")
191  {
192  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
193  }
194  inletDir_.writeEntry("inletDirection", os);
195  writeEntry("value", os);
196 }
197 
198 
199 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
200 
201 void pressureDirectedInletVelocityFvPatchVectorField::operator=
202 (
203  const fvPatchField<vector>& pvf
204 )
205 {
206  fvPatchField<vector>::operator=(inletDir_*(inletDir_ & pvf));
207 }
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
213 (
216 );
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // ************************ vim: set sw=4 sts=4 et: ************************ //