FreeFOAM The Cross-Platform CFD Toolkit
pressureNormalInletOutletVelocityFvPatchVectorField.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  mixedFvPatchVectorField(p, iF),
47  phiName_("phi"),
48  rhoName_("rho")
49 {
50  refValue() = *this;
51  refGrad() = vector::zero;
52  valueFraction() = 0.0;
53 }
54 
55 
58 (
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  mixedFvPatchVectorField(ptf, p, iF, mapper),
66  phiName_(ptf.phiName_),
67  rhoName_(ptf.rhoName_)
68 {}
69 
70 
73 (
74  const fvPatch& p,
76  const dictionary& dict
77 )
78 :
79  mixedFvPatchVectorField(p, iF),
80  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
81  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
82 {
83  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
84  refValue() = *this;
85  refGrad() = vector::zero;
86  valueFraction() = 0.0;
87 }
88 
89 
92 (
94 )
95 :
96  mixedFvPatchVectorField(pivpvf),
97  phiName_(pivpvf.phiName_),
98  rhoName_(pivpvf.rhoName_)
99 {}
100 
101 
104 (
107 )
108 :
109  mixedFvPatchVectorField(pivpvf, iF),
110  phiName_(pivpvf.phiName_),
111  rhoName_(pivpvf.rhoName_)
112 {}
113 
114 
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 
118 {
119  if (updated())
120  {
121  return;
122  }
123 
124  const surfaceScalarField& phi =
125  db().lookupObject<surfaceScalarField>(phiName_);
126 
127  const fvsPatchField<scalar>& phip =
128  patch().patchField<surfaceScalarField, scalar>(phi);
129 
130  vectorField n = patch().nf();
131  const Field<scalar>& magS = patch().magSf();
132 
133  if (phi.dimensions() == dimVelocity*dimArea)
134  {
135  refValue() = n*phip/magS;
136  }
137  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
138  {
139  const fvPatchField<scalar>& rhop =
140  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
141 
142  refValue() = n*phip/(rhop*magS);
143  }
144  else
145  {
147  (
148  "pressureNormalInletOutletVelocityFvPatchVectorField::"
149  "updateCoeffs()"
150  ) << "dimensions of phi are not correct"
151  << "\n on patch " << this->patch().name()
152  << " of field " << this->dimensionedInternalField().name()
153  << " in file " << this->dimensionedInternalField().objectPath()
154  << exit(FatalError);
155  }
156 
157  valueFraction() = 1.0 - pos(phip);
158 
160 }
161 
162 
164 write(Ostream& os) const
165 {
167  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
168  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
169  writeEntry("value", os);
170 }
171 
172 
173 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
174 
175 void pressureNormalInletOutletVelocityFvPatchVectorField::operator=
176 (
177  const fvPatchField<vector>& pvf
178 )
179 {
181  (
182  valueFraction()*(patch().nf()*(patch().nf() & pvf))
183  + (1 - valueFraction())*pvf
184  );
185 }
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
191 (
194 );
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // ************************ vim: set sw=4 sts=4 et: ************************ //