FreeFOAM The Cross-Platform CFD Toolkit
pressureInletOutletVelocityFvPatchVectorField.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 
40 (
41  const fvPatch& p,
43 )
44 :
45  directionMixedFvPatchVectorField(p, iF),
46  phiName_("phi")
47 {
48  refValue() = vector::zero;
49  refGrad() = vector::zero;
50  valueFraction() = symmTensor::zero;
51 }
52 
53 
56 (
58  const fvPatch& p,
60  const fvPatchFieldMapper& mapper
61 )
62 :
63  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
64  phiName_(ptf.phiName_)
65 {
66  if (ptf.tangentialVelocity_.size())
67  {
68  tangentialVelocity_ = mapper(ptf.tangentialVelocity_);
69  }
70 }
71 
72 
75 (
76  const fvPatch& p,
78  const dictionary& dict
79 )
80 :
81  directionMixedFvPatchVectorField(p, iF),
82  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
83 {
84  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
85 
86  if (dict.found("tangentialVelocity"))
87  {
88  setTangentialVelocity
89  (
90  vectorField("tangentialVelocity", dict, p.size())
91  );
92  }
93  else
94  {
95  refValue() = vector::zero;
96  }
97 
98  refGrad() = vector::zero;
99  valueFraction() = symmTensor::zero;
100 }
101 
102 
105 (
107 )
108 :
109  directionMixedFvPatchVectorField(pivpvf),
110  phiName_(pivpvf.phiName_),
111  tangentialVelocity_(pivpvf.tangentialVelocity_)
112 {}
113 
114 
117 (
120 )
121 :
122  directionMixedFvPatchVectorField(pivpvf, iF),
123  phiName_(pivpvf.phiName_),
124  tangentialVelocity_(pivpvf.tangentialVelocity_)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
131 setTangentialVelocity(const vectorField& tangentialVelocity)
132 {
133  tangentialVelocity_ = tangentialVelocity;
134  vectorField n = patch().nf();
135  refValue() = tangentialVelocity_ - n*(n & tangentialVelocity_);
136 }
137 
138 
140 (
141  const fvPatchFieldMapper& m
142 )
143 {
144  directionMixedFvPatchVectorField::autoMap(m);
145  if (tangentialVelocity_.size())
146  {
147  tangentialVelocity_.autoMap(m);
148  }
149 }
150 
151 
153 (
154  const fvPatchVectorField& ptf,
155  const labelList& addr
156 )
157 {
158  directionMixedFvPatchVectorField::rmap(ptf, addr);
159 
160  if (tangentialVelocity_.size())
161  {
163  refCast<const pressureInletOutletVelocityFvPatchVectorField>(ptf);
164 
165  tangentialVelocity_.rmap(tiptf.tangentialVelocity_, addr);
166  }
167 }
168 
169 
171 {
172  if (updated())
173  {
174  return;
175  }
176 
177  const fvsPatchField<scalar>& phip =
178  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
179 
180  valueFraction() = neg(phip)*(I - sqr(patch().nf()));
181 
183  directionMixedFvPatchVectorField::evaluate();
184 }
185 
186 
188 {
190  if (phiName_ != "phi")
191  {
192  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
193  }
194  if (tangentialVelocity_.size())
195  {
196  tangentialVelocity_.writeEntry("tangentialVelocity", os);
197  }
198  writeEntry("value", os);
199 }
200 
201 
202 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
203 
204 void pressureInletOutletVelocityFvPatchVectorField::operator=
205 (
206  const fvPatchField<vector>& pvf
207 )
208 {
209  vectorField normalValue = transform(valueFraction(), refValue());
210  vectorField transformGradValue = transform(I - valueFraction(), pvf);
211  fvPatchField<vector>::operator=(normalValue + transformGradValue);
212 }
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
218 (
221 );
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // ************************ vim: set sw=4 sts=4 et: ************************ //