FreeFOAM The Cross-Platform CFD Toolkit
pressureInletVelocityFvPatchVectorField.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 
28 #include <finiteVolume/volFields.H>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 (
40  const fvPatch& p,
42 )
43 :
44  fixedValueFvPatchVectorField(p, iF),
45  phiName_("phi"),
46  rhoName_("rho")
47 {}
48 
49 
51 (
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
59  phiName_(ptf.phiName_),
60  rhoName_(ptf.rhoName_)
61 {}
62 
63 
65 (
66  const fvPatch& p,
68  const dictionary& dict
69 )
70 :
71  fixedValueFvPatchVectorField(p, iF),
72  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
73  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
74 {
75  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
76 }
77 
78 
80 (
82 )
83 :
84  fixedValueFvPatchVectorField(pivpvf),
85  phiName_(pivpvf.phiName_),
86  rhoName_(pivpvf.rhoName_)
87 {}
88 
89 
91 (
94 )
95 :
96  fixedValueFvPatchVectorField(pivpvf, iF),
97  phiName_(pivpvf.phiName_),
98  rhoName_(pivpvf.rhoName_)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  if (updated())
107  {
108  return;
109  }
110 
111  const surfaceScalarField& phi =
112  db().lookupObject<surfaceScalarField>(phiName_);
113 
114  const fvsPatchField<scalar>& phip =
115  patch().patchField<surfaceScalarField, scalar>(phi);
116 
117  vectorField n = patch().nf();
118  const Field<scalar>& magS = patch().magSf();
119 
120  if (phi.dimensions() == dimVelocity*dimArea)
121  {
122  operator==(n*phip/magS);
123  }
124  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
125  {
126  const fvPatchField<scalar>& rhop =
127  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
128 
129  operator==(n*phip/(rhop*magS));
130  }
131  else
132  {
133  FatalErrorIn("pressureInletVelocityFvPatchVectorField::updateCoeffs()")
134  << "dimensions of phi are not correct"
135  << "\n on patch " << this->patch().name()
136  << " of field " << this->dimensionedInternalField().name()
137  << " in file " << this->dimensionedInternalField().objectPath()
138  << exit(FatalError);
139  }
140 
142 }
143 
144 
146 {
148  if (phiName_ != "phi")
149  {
150  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
151  }
152  if (rhoName_ != "rho")
153  {
154  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
155  }
156  writeEntry("value", os);
157 }
158 
159 
160 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
161 
162 void pressureInletVelocityFvPatchVectorField::operator=
163 (
164  const fvPatchField<vector>& pvf
165 )
166 {
167  fvPatchField<vector>::operator=(patch().nf()*(patch().nf() & pvf));
168 }
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
174 (
177 );
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // ************************ vim: set sw=4 sts=4 et: ************************ //