FreeFOAM The Cross-Platform CFD Toolkit
mixedFvPatchField.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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
42  fvPatchField<Type>(p, iF),
43  refValue_(p.size()),
44  refGrad_(p.size()),
45  valueFraction_(p.size())
46 {}
47 
48 
49 template<class Type>
51 (
52  const mixedFvPatchField<Type>& ptf,
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  fvPatchField<Type>(ptf, p, iF, mapper),
59  refValue_(ptf.refValue_, mapper),
60  refGrad_(ptf.refGrad_, mapper),
61  valueFraction_(ptf.valueFraction_, mapper)
62 {}
63 
64 
65 template<class Type>
67 (
68  const fvPatch& p,
70  const dictionary& dict
71 )
72 :
73  fvPatchField<Type>(p, iF, dict),
74  refValue_("refValue", dict, p.size()),
75  refGrad_("refGradient", dict, p.size()),
76  valueFraction_("valueFraction", dict, p.size())
77 {
78  evaluate();
79 }
80 
81 
82 template<class Type>
84 (
85  const mixedFvPatchField<Type>& ptf
86 )
87 :
88  fvPatchField<Type>(ptf),
89  refValue_(ptf.refValue_),
90  refGrad_(ptf.refGrad_),
91  valueFraction_(ptf.valueFraction_)
92 {}
93 
94 
95 template<class Type>
97 (
98  const mixedFvPatchField<Type>& ptf,
100 )
101 :
102  fvPatchField<Type>(ptf, iF),
103  refValue_(ptf.refValue_),
104  refGrad_(ptf.refGrad_),
105  valueFraction_(ptf.valueFraction_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class Type>
113 (
114  const fvPatchFieldMapper& m
115 )
116 {
118  refValue_.autoMap(m);
119  refGrad_.autoMap(m);
120  valueFraction_.autoMap(m);
121 }
122 
123 
124 template<class Type>
126 (
127  const fvPatchField<Type>& ptf,
128  const labelList& addr
129 )
130 {
131  fvPatchField<Type>::rmap(ptf, addr);
132 
133  const mixedFvPatchField<Type>& mptf =
134  refCast<const mixedFvPatchField<Type> >(ptf);
135 
136  refValue_.rmap(mptf.refValue_, addr);
137  refGrad_.rmap(mptf.refGrad_, addr);
138  valueFraction_.rmap(mptf.valueFraction_, addr);
139 }
140 
141 
142 template<class Type>
144 {
145  if (!this->updated())
146  {
147  this->updateCoeffs();
148  }
149 
151  (
152  valueFraction_*refValue_
153  +
154  (1.0 - valueFraction_)*
155  (
156  this->patchInternalField()
157  + refGrad_/this->patch().deltaCoeffs()
158  )
159  );
160 
162 }
163 
164 
165 template<class Type>
167 {
168  return
169  valueFraction_
170  *(refValue_ - this->patchInternalField())
171  *this->patch().deltaCoeffs()
172  + (1.0 - valueFraction_)*refGrad_;
173 }
174 
175 
176 template<class Type>
178 (
179  const tmp<scalarField>&
180 ) const
181 {
182  return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
183 
184 }
185 
186 
187 template<class Type>
189 (
190  const tmp<scalarField>&
191 ) const
192 {
193  return
194  valueFraction_*refValue_
195  + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
196 }
197 
198 
199 template<class Type>
201 {
202  return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
203 }
204 
205 
206 template<class Type>
208 {
209  return
210  valueFraction_*this->patch().deltaCoeffs()*refValue_
211  + (1.0 - valueFraction_)*refGrad_;
212 }
213 
214 
215 template<class Type>
217 {
219  refValue_.writeEntry("refValue", os);
220  refGrad_.writeEntry("refGradient", os);
221  valueFraction_.writeEntry("valueFraction", os);
222  this->writeEntry("value", os);
223 }
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // ************************ vim: set sw=4 sts=4 et: ************************ //