FreeFOAM The Cross-Platform CFD Toolkit
directionMixedFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenOAM: 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 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const fvPatch& p,
41 )
42 :
44  refValue_(p.size()),
45  refGrad_(p.size()),
46  valueFraction_(p.size())
47 {}
48 
49 
50 template<class Type>
52 (
54  const fvPatch& p,
56  const fvPatchFieldMapper& mapper
57 )
58 :
59  transformFvPatchField<Type>(ptf, p, iF, mapper),
60  refValue_(ptf.refValue_, mapper),
61  refGrad_(ptf.refGrad_, mapper),
62  valueFraction_(ptf.valueFraction_, mapper)
63 {}
64 
65 
66 template<class Type>
68 (
69  const fvPatch& p,
71  const dictionary& dict
72 )
73 :
74  transformFvPatchField<Type>(p, iF, dict),
75  refValue_("refValue", dict, p.size()),
76  refGrad_("refGradient", dict, p.size()),
77  valueFraction_("valueFraction", dict, p.size())
78 {
79  evaluate();
80 }
81 
82 
83 template<class Type>
85 (
88 )
89 :
91  refValue_(ptf.refValue_),
92  refGrad_(ptf.refGrad_),
93  valueFraction_(ptf.valueFraction_)
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 template<class Type>
101 (
102  const fvPatchFieldMapper& m
103 )
104 {
106  refValue_.autoMap(m);
107  refGrad_.autoMap(m);
108  valueFraction_.autoMap(m);
109 }
110 
111 
112 template<class Type>
114 (
115  const fvPatchField<Type>& ptf,
116  const labelList& addr
117 )
118 {
120 
121  const directionMixedFvPatchField<Type>& dmptf =
122  refCast<const directionMixedFvPatchField<Type> >(ptf);
123 
124  refValue_.rmap(dmptf.refValue_, addr);
125  refGrad_.rmap(dmptf.refGrad_, addr);
126  valueFraction_.rmap(dmptf.valueFraction_, addr);
127 }
128 
129 
130 template<class Type>
132 {
133  Field<Type> pif = this->patchInternalField();
134 
135  Field<Type> normalValue = transform(valueFraction_, refValue_);
136 
137  Field<Type> gradValue = pif + refGrad_/this->patch().deltaCoeffs();
138 
139  Field<Type> transformGradValue =
140  transform(I - valueFraction_, gradValue);
141 
142  return
143  (normalValue + transformGradValue - pif)*
144  this->patch().deltaCoeffs();
145 }
146 
147 
148 template<class Type>
150 {
151  if (!this->updated())
152  {
153  this->updateCoeffs();
154  }
155 
156  Field<Type> normalValue = transform(valueFraction_, refValue_);
157 
158  Field<Type> gradValue =
159  this->patchInternalField() + refGrad_/this->patch().deltaCoeffs();
160 
161  Field<Type> transformGradValue =
162  transform(I - valueFraction_, gradValue);
163 
164  Field<Type>::operator=(normalValue + transformGradValue);
165 
167 }
168 
169 
170 template<class Type>
172 {
173  vectorField diag(valueFraction_.size());
174 
175  diag.replace
176  (
177  vector::X,
178  sqrt(mag(valueFraction_.component(symmTensor::XX)))
179  );
180  diag.replace
181  (
182  vector::Y,
183  sqrt(mag(valueFraction_.component(symmTensor::YY)))
184  );
185  diag.replace
186  (
187  vector::Z,
188  sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
189  );
190 
191  return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
192 }
193 
194 
195 template<class Type>
197 {
199  refValue_.writeEntry("refValue", os);
200  refGrad_.writeEntry("refGradient", os);
201  valueFraction_.writeEntry("valueFraction", os);
202  this->writeEntry("value", os);
203 }
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // ************************ vim: set sw=4 sts=4 et: ************************ //