FreeFOAM The Cross-Platform CFD Toolkit
timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField.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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  timeVaryingMappedFixedValueFvPatchVectorField(p, iF),
42  phiName_("phi"),
43  rhoName_("rho")
44 {}
45 
46 
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
55  timeVaryingMappedFixedValueFvPatchVectorField(p, iF),
56  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
57  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
58 {
59  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
60 }
61 
62 
65 (
67  const fvPatch& p,
69  const fvPatchFieldMapper& mapper
70 )
71 :
72  timeVaryingMappedFixedValueFvPatchVectorField(ptf, p, iF, mapper),
73  phiName_(ptf.phiName_),
74  rhoName_(ptf.rhoName_)
75 {}
76 
77 
80 (
82  pivpvf
83 )
84 :
85  timeVaryingMappedFixedValueFvPatchVectorField(pivpvf),
86  phiName_(pivpvf.phiName_),
87  rhoName_(pivpvf.rhoName_)
88 {}
89 
90 
93 (
95  pivpvf,
97 )
98 :
99  timeVaryingMappedFixedValueFvPatchVectorField(pivpvf, iF),
100  phiName_(pivpvf.phiName_),
101  rhoName_(pivpvf.rhoName_)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 autoMap
109 (
110  const fvPatchFieldMapper& m
111 )
112 {
113  timeVaryingMappedFixedValueFvPatchVectorField::autoMap(m);
114 }
115 
116 
118 rmap
119 (
120  const fvPatchVectorField& ptf,
121  const labelList& addr
122 )
123 {
124  timeVaryingMappedFixedValueFvPatchVectorField::rmap(ptf, addr);
125 }
126 
127 
130 {
131  if (updated())
132  {
133  return;
134  }
135 
136  // Map the tabulated velocity field onto this field
138  vectorField inletDir = *this;
139 
140  // Normalise to obtain the flow direction
141  inletDir /= (mag(inletDir) + SMALL);
142 
143  const surfaceScalarField& phi =
144  db().lookupObject<surfaceScalarField>(phiName_);
145 
146  const fvsPatchField<scalar>& phip =
147  patch().patchField<surfaceScalarField, scalar>(phi);
148 
149  vectorField n = patch().nf();
150  scalarField ndmagS = (n & inletDir)*patch().magSf();
151 
152  if (phi.dimensions() == dimVelocity*dimArea)
153  {
154  operator==(inletDir*phip/ndmagS);
155  }
156  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
157  {
158  const fvPatchField<scalar>& rhop =
159  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
160 
161  operator==(inletDir*phip/(rhop*ndmagS));
162  }
163  else
164  {
166  (
167  "timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField"
168  "::updateCoeffs()"
169  ) << "dimensions of phi are not correct"
170  << "\n on patch " << this->patch().name()
171  << " of field " << this->dimensionedInternalField().name()
172  << " in file " << this->dimensionedInternalField().objectPath()
173  << exit(FatalError);
174  }
175 }
176 
177 
179 write
180 (
181  Ostream& os
182 ) const
183 {
184  if (phiName_ != "phi")
185  {
186  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
187  }
188  if (rhoName_ != "rho")
189  {
190  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
191  }
192  timeVaryingMappedFixedValueFvPatchVectorField::write(os);
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 namespace Foam
199 {
201  (
204  );
205 }
206 
207 
208 // ************************ vim: set sw=4 sts=4 et: ************************ //