FreeFOAM The Cross-Platform CFD Toolkit
inletOutletFvPatchField.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 
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
43  phiName_("phi")
44 {
45  this->refValue() = pTraits<Type>::zero;
46  this->refGrad() = pTraits<Type>::zero;
47  this->valueFraction() = 0.0;
48 }
49 
50 
51 template<class Type>
53 (
55  const fvPatch& p,
57  const fvPatchFieldMapper& mapper
58 )
59 :
60  mixedFvPatchField<Type>(ptf, p, iF, mapper),
61  phiName_(ptf.phiName_)
62 {}
63 
64 
65 template<class Type>
67 (
68  const fvPatch& p,
70  const dictionary& dict
71 )
72 :
74  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
75 {
76  this->refValue() = Field<Type>("inletValue", dict, p.size());
77 
78  if (dict.found("value"))
79  {
81  (
82  Field<Type>("value", dict, p.size())
83  );
84  }
85  else
86  {
87  fvPatchField<Type>::operator=(this->refValue());
88  }
89 
90  this->refGrad() = pTraits<Type>::zero;
91  this->valueFraction() = 0.0;
92 }
93 
94 
95 template<class Type>
97 (
99 )
100 :
102  phiName_(ptf.phiName_)
103 {}
104 
105 
106 template<class Type>
108 (
111 )
112 :
113  mixedFvPatchField<Type>(ptf, iF),
114  phiName_(ptf.phiName_)
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 template<class Type>
122 {
123  if (this->updated())
124  {
125  return;
126  }
127 
128  const Field<scalar>& phip = this->patch().lookupPatchField
129  (
130  phiName_,
131  reinterpret_cast<const surfaceScalarField*>(0),
132  reinterpret_cast<const scalar*>(0)
133  );
134 
135  this->valueFraction() = 1.0 - pos(phip);
136 
138 }
139 
140 
141 template<class Type>
143 {
145  if (phiName_ != "phi")
146  {
147  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
148  }
149  this->refValue().writeEntry("inletValue", os);
150  this->writeEntry("value", os);
151 }
152 
153 
154 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
155 
156 template<class Type>
158 (
159  const fvPatchField<Type>& ptf
160 )
161 {
163  (
164  this->valueFraction()*this->refValue()
165  + (1 - this->valueFraction())*ptf
166  );
167 }
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // ************************ vim: set sw=4 sts=4 et: ************************ //