FreeFOAM The Cross-Platform CFD Toolkit
fvPatchField.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 
26 #include <OpenFOAM/IOobject.H>
27 #include <OpenFOAM/dictionary.H>
28 #include <finiteVolume/fvMesh.H>
29 #include "fvPatchFieldMapper.H"
30 //#include "fvMatrices.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
41  Field<Type>(p.size()),
42  patch_(p),
43  internalField_(iF),
44  updated_(false),
45  patchType_(word::null)
46 {}
47 
48 
49 template<class Type>
51 (
52  const fvPatch& p,
54  const Field<Type>& f
55 )
56 :
57  Field<Type>(f),
58  patch_(p),
59  internalField_(iF),
60  updated_(false),
61  patchType_(word::null)
62 {}
63 
64 
65 template<class Type>
67 (
68  const fvPatchField<Type>& ptf,
69  const fvPatch& p,
71  const fvPatchFieldMapper& mapper
72 )
73 :
74  Field<Type>(ptf, mapper),
75  patch_(p),
76  internalField_(iF),
77  updated_(false),
78  patchType_(ptf.patchType_)
79 {}
80 
81 
82 template<class Type>
84 (
85  const fvPatch& p,
87  const dictionary& dict,
88  const bool valueRequired
89 )
90 :
91  Field<Type>(p.size()),
92  patch_(p),
93  internalField_(iF),
94  updated_(false),
95  patchType_(dict.lookupOrDefault<word>("patchType", word::null))
96 {
97  if (dict.found("value"))
98  {
100  (
101  Field<Type>("value", dict, p.size())
102  );
103  }
104  else if (!valueRequired)
105  {
107  }
108  else
109  {
111  (
112  "fvPatchField<Type>::fvPatchField"
113  "("
114  "const fvPatch& p,"
115  "const DimensionedField<Type, volMesh>& iF,"
116  "const dictionary& dict,"
117  "const bool valueRequired"
118  ")",
119  dict
120  ) << "Essential entry 'value' missing"
121  << exit(FatalIOError);
122  }
123 }
124 
125 
126 template<class Type>
128 (
129  const fvPatchField<Type>& ptf
130 )
131 :
132  Field<Type>(ptf),
133  patch_(ptf.patch_),
134  internalField_(ptf.internalField_),
135  updated_(false),
136  patchType_(ptf.patchType_)
137 {}
138 
139 
140 template<class Type>
142 (
143  const fvPatchField<Type>& ptf,
145 )
146 :
147  Field<Type>(ptf),
148  patch_(ptf.patch_),
149  internalField_(iF),
150  updated_(false),
151  patchType_(ptf.patchType_)
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
157 template<class Type>
159 {
160  return patch_.boundaryMesh().mesh();
161 }
162 
163 
164 template<class Type>
166 {
167  if (&patch_ != &(ptf.patch_))
168  {
169  FatalErrorIn("PatchField<Type>::check(const fvPatchField<Type>&)")
170  << "different patches for fvPatchField<Type>s"
171  << abort(FatalError);
172  }
173 }
174 
175 
176 // Return gradient at boundary
177 template<class Type>
179 {
180  return (*this - patchInternalField())*patch_.deltaCoeffs();
181 }
182 
183 
184 // Return internal field next to patch as patch field
185 template<class Type>
188 {
189  return patch_.patchInternalField(internalField_);
190 }
191 
192 
193 template<class Type>
195 (
196  const fvPatchFieldMapper& m
197 )
198 {
200 }
201 
202 
203 template<class Type>
205 (
206  const fvPatchField<Type>& ptf,
207  const labelList& addr
208 )
209 {
210  Field<Type>::rmap(ptf, addr);
211 }
212 
213 
214 template<class Type>
216 {
217  if (!updated_)
218  {
219  updateCoeffs();
220  }
221 
222  updated_ = false;
223 }
224 
225 
226 template<class Type>
228 {
229  // do nothing
230 }
231 
232 
233 template<class Type>
235 {
236  os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
237 
238  if (patchType_.size())
239  {
240  os.writeKeyword("patchType") << patchType_
241  << token::END_STATEMENT << nl;
242  }
243 }
244 
245 
246 template<class Type>
247 template<class EntryType>
249 (
250  Ostream& os,
251  const word& entryName,
252  const EntryType& value1,
253  const EntryType& value2
254 ) const
255 {
256  if (value1 != value2)
257  {
258  os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
259  }
260 }
261 
262 
263 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
264 
265 template<class Type>
267 (
268  const UList<Type>& ul
269 )
270 {
272 }
273 
274 
275 template<class Type>
276 void Foam::fvPatchField<Type>::operator=
277 (
278  const fvPatchField<Type>& ptf
279 )
280 {
281  check(ptf);
283 }
284 
285 
286 template<class Type>
287 void Foam::fvPatchField<Type>::operator+=
288 (
289  const fvPatchField<Type>& ptf
290 )
291 {
292  check(ptf);
294 }
295 
296 
297 template<class Type>
298 void Foam::fvPatchField<Type>::operator-=
299 (
300  const fvPatchField<Type>& ptf
301 )
302 {
303  check(ptf);
305 }
306 
307 
308 template<class Type>
309 void Foam::fvPatchField<Type>::operator*=
310 (
311  const fvPatchField<scalar>& ptf
312 )
313 {
314  if (&patch_ != &ptf.patch())
315  {
317  (
318  "PatchField<Type>::operator*=(const fvPatchField<scalar>& ptf)"
319  ) << "incompatible patches for patch fields"
320  << abort(FatalError);
321  }
322 
324 }
325 
326 
327 template<class Type>
328 void Foam::fvPatchField<Type>::operator/=
329 (
330  const fvPatchField<scalar>& ptf
331 )
332 {
333  if (&patch_ != &ptf.patch())
334  {
336  (
337  "PatchField<Type>::operator/=(const fvPatchField<scalar>& ptf)"
338  ) << " incompatible patches for patch fields"
339  << abort(FatalError);
340  }
341 
343 }
344 
345 
346 template<class Type>
347 void Foam::fvPatchField<Type>::operator+=
348 (
349  const Field<Type>& tf
350 )
351 {
353 }
354 
355 
356 template<class Type>
357 void Foam::fvPatchField<Type>::operator-=
358 (
359  const Field<Type>& tf
360 )
361 {
363 }
364 
365 
366 template<class Type>
367 void Foam::fvPatchField<Type>::operator*=
368 (
369  const scalarField& tf
370 )
371 {
373 }
374 
375 
376 template<class Type>
377 void Foam::fvPatchField<Type>::operator/=
378 (
379  const scalarField& tf
380 )
381 {
383 }
384 
385 
386 template<class Type>
387 void Foam::fvPatchField<Type>::operator=
388 (
389  const Type& t
390 )
391 {
393 }
394 
395 
396 template<class Type>
397 void Foam::fvPatchField<Type>::operator+=
398 (
399  const Type& t
400 )
401 {
403 }
404 
405 
406 template<class Type>
407 void Foam::fvPatchField<Type>::operator-=
408 (
409  const Type& t
410 )
411 {
413 }
414 
415 
416 template<class Type>
417 void Foam::fvPatchField<Type>::operator*=
418 (
419  const scalar s
420 )
421 {
423 }
424 
425 
426 template<class Type>
427 void Foam::fvPatchField<Type>::operator/=
428 (
429  const scalar s
430 )
431 {
433 }
434 
435 
436 // Force an assignment, overriding fixedValue status
437 template<class Type>
438 void Foam::fvPatchField<Type>::operator==
439 (
440  const fvPatchField<Type>& ptf
441 )
442 {
444 }
445 
446 
447 template<class Type>
448 void Foam::fvPatchField<Type>::operator==
449 (
450  const Field<Type>& tf
451 )
452 {
454 }
455 
456 
457 template<class Type>
458 void Foam::fvPatchField<Type>::operator==
459 (
460  const Type& t
461 )
462 {
464 }
465 
466 
467 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
468 
469 template<class Type>
470 Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField<Type>& ptf)
471 {
472  ptf.write(os);
473 
474  os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
475 
476  return os;
477 }
478 
479 
480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
481 
482 # include "newFvPatchField.C"
483 
484 // ************************ vim: set sw=4 sts=4 et: ************************ //