FreeFOAM The Cross-Platform CFD Toolkit
GeometricScalarField.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 #define TEMPLATE template<template<class> class PatchField, class GeoMesh>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 
38 template<template<class> class PatchField, class GeoMesh>
39 void stabilise
40 (
43  const dimensioned<scalar>& ds
44 )
45 {
46  stabilise(result.internalField(), gsf.internalField(), ds.value());
47  stabilise(result.boundaryField(), gsf.boundaryField(), ds.value());
48 }
49 
50 
51 template<template<class> class PatchField, class GeoMesh>
52 tmp<GeometricField<scalar, PatchField, GeoMesh> > stabilise
53 (
55  const dimensioned<scalar>& ds
56 )
57 {
59  (
61  (
62  IOobject
63  (
64  "stabilise(" + gsf.name() + ',' + ds.name() + ')',
65  gsf.instance(),
66  gsf.db(),
69  ),
70  gsf.mesh(),
71  ds.dimensions() + gsf.dimensions()
72  )
73  );
74 
75  stabilise(tRes(), gsf, ds);
76 
77  return tRes;
78 }
79 
80 
81 template<template<class> class PatchField, class GeoMesh>
82 tmp<GeometricField<scalar, PatchField, GeoMesh> > stabilise
83 (
85  const dimensioned<scalar>& ds
86 )
87 {
89 
91  (
93  (
94  tgsf,
95  "stabilise(" + gsf.name() + ',' + ds.name() + ')',
96  ds.dimensions() + gsf.dimensions()
97  )
98  );
99 
100  stabilise(tRes(), gsf, ds);
101 
103 
104  return tRes;
105 }
106 
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, '+', add)
111 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, '-', subtract)
112 
113 BINARY_OPERATOR(scalar, scalar, scalar, *, '*', multiply)
114 BINARY_OPERATOR(scalar, scalar, scalar, /, '|', divide)
115 
116 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, '|', divide)
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 template<template<class> class PatchField, class GeoMesh>
121 void pow
122 (
123  GeometricField<scalar, PatchField, GeoMesh>& Pow,
124  const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
125  const GeometricField<scalar, PatchField, GeoMesh>& gsf2
126 )
127 {
128  pow(Pow.internalField(), gsf1.internalField(), gsf2.internalField());
129  pow(Pow.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField());
130 }
131 
132 
133 template<template<class> class PatchField, class GeoMesh>
134 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
135 (
138 )
139 {
141  (
143  (
144  IOobject
145  (
146  "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
147  gsf1.instance(),
148  gsf1.db(),
151  ),
152  gsf1.mesh(),
153  pow
154  (
155  gsf1.dimensions(),
156  dimensionedScalar("1", gsf2.dimensions(), 1.0)
157  )
158  )
159  );
160 
161  pow(tPow(), gsf1, gsf2);
162 
163  return tPow;
164 }
165 
166 
167 template<template<class> class PatchField, class GeoMesh>
168 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
169 (
172 )
173 {
174  const GeometricField<scalar, PatchField, GeoMesh>& gsf1 = tgsf1();
175 
177  (
179  (
180  tgsf1,
181  "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
182  pow
183  (
184  gsf1.dimensions(),
185  dimensionedScalar("1", gsf2.dimensions(), 1.0)
186  )
187  )
188  );
189 
190  pow(tPow(), gsf1, gsf2);
191 
193 
194  return tPow;
195 }
196 
197 
198 template<template<class> class PatchField, class GeoMesh>
199 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
200 (
203 )
204 {
205  const GeometricField<scalar, PatchField, GeoMesh>& gsf2 = tgsf2();
206 
208  (
210  (
211  tgsf2,
212  "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
213  pow
214  (
215  gsf1.dimensions(),
216  dimensionedScalar("1", gsf2.dimensions(), 1.0)
217  )
218  )
219  );
220 
221  pow(tPow(), gsf1, gsf2);
222 
224 
225  return tPow;
226 }
227 
228 template<template<class> class PatchField, class GeoMesh>
229 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
230 (
233 )
234 {
235  const GeometricField<scalar, PatchField, GeoMesh>& gsf1 = tgsf1();
236  const GeometricField<scalar, PatchField, GeoMesh>& gsf2 = tgsf2();
237 
239  (
241  <scalar, scalar, scalar, scalar, PatchField, GeoMesh>::New
242  (
243  tgsf1,
244  tgsf2,
245  "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
246  pow
247  (
248  gsf1.dimensions(),
249  dimensionedScalar("1", gsf2.dimensions(), 1.0)
250  )
251  )
252  );
253 
254  pow(tPow(), gsf1, gsf2);
255 
257  <scalar, scalar, scalar, scalar, PatchField, GeoMesh>
258  ::clear(tgsf1, tgsf2);
259 
260  return tPow;
261 }
262 
263 
264 template<template<class> class PatchField, class GeoMesh>
265 void pow
266 (
269  const dimensioned<scalar>& ds
270 )
271 {
272  pow(tPow.internalField(), gsf.internalField(), ds.value());
273  pow(tPow.boundaryField(), gsf.boundaryField(), ds.value());
274 }
275 
276 
277 template<template<class> class PatchField, class GeoMesh>
278 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
279 (
281  const dimensionedScalar& ds
282 )
283 {
285  (
287  (
288  IOobject
289  (
290  "pow(" + gsf.name() + ',' + ds.name() + ')',
291  gsf.instance(),
292  gsf.db(),
295  ),
296  gsf.mesh(),
297  pow(gsf.dimensions(), ds)
298  )
299  );
300 
301  pow(tPow(), gsf, ds);
302 
303  return tPow;
304 }
305 
306 template<template<class> class PatchField, class GeoMesh>
307 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
308 (
310  const dimensionedScalar& ds
311 )
312 {
314 
316  (
318  (
319  tgsf,
320  "pow(" + gsf.name() + ',' + ds.name() + ')',
321  pow(gsf.dimensions(), ds)
322  )
323  );
324 
325  pow(tPow(), gsf, ds);
326 
328 
329  return tPow;
330 }
331 
332 template<template<class> class PatchField, class GeoMesh>
333 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
334 (
336  const scalar& s
337 )
338 {
339  return pow(gsf, dimensionedScalar(s));
340 }
341 
342 template<template<class> class PatchField, class GeoMesh>
343 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
344 (
346  const scalar& s
347 )
348 {
349  return pow(tgsf, dimensionedScalar(s));
350 }
351 
352 
353 template<template<class> class PatchField, class GeoMesh>
354 void pow
355 (
357  const dimensioned<scalar>& ds,
359 )
360 {
361  pow(tPow.internalField(), ds.value(), gsf.internalField());
362  pow(tPow.boundaryField(), ds.value(), gsf.boundaryField());
363 }
364 
365 
366 template<template<class> class PatchField, class GeoMesh>
367 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
368 (
369  const dimensionedScalar& ds,
371 )
372 {
374  (
376  (
377  IOobject
378  (
379  "pow(" + ds.name() + ',' + gsf.name() + ')',
380  gsf.instance(),
381  gsf.db(),
384  ),
385  gsf.mesh(),
386  pow(ds, gsf.dimensions())
387  )
388  );
389 
390  pow(tPow(), ds, gsf);
391 
392  return tPow;
393 }
394 
395 
396 template<template<class> class PatchField, class GeoMesh>
397 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
398 (
399  const dimensionedScalar& ds,
401 )
402 {
404 
406  (
408  (
409  tgsf,
410  "pow(" + ds.name() + ',' + gsf.name() + ')',
411  pow(ds, gsf.dimensions())
412  )
413  );
414 
415  pow(tPow(), ds, gsf);
416 
418 
419  return tPow;
420 }
421 
422 template<template<class> class PatchField, class GeoMesh>
423 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
424 (
425  const scalar& s,
427 )
428 {
429  return pow(dimensionedScalar(s), gsf);
430 }
431 
432 template<template<class> class PatchField, class GeoMesh>
433 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
434 (
435  const scalar& s,
437 )
438 {
439  return pow(dimensionedScalar(s), tgsf);
440 }
441 
442 
443 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
444 
445 UNARY_FUNCTION(scalar, scalar, pow3, pow3)
446 UNARY_FUNCTION(scalar, scalar, pow4, pow4)
447 UNARY_FUNCTION(scalar, scalar, pow5, pow5)
448 UNARY_FUNCTION(scalar, scalar, pow6, pow6)
449 UNARY_FUNCTION(scalar, scalar, sqrt, sqrt)
450 UNARY_FUNCTION(scalar, scalar, sign, sign)
451 UNARY_FUNCTION(scalar, scalar, pos, pos)
452 UNARY_FUNCTION(scalar, scalar, neg, neg)
453 
454 UNARY_FUNCTION(scalar, scalar, exp, trans)
455 UNARY_FUNCTION(scalar, scalar, log, trans)
456 UNARY_FUNCTION(scalar, scalar, log10, trans)
457 UNARY_FUNCTION(scalar, scalar, sin, trans)
458 UNARY_FUNCTION(scalar, scalar, cos, trans)
459 UNARY_FUNCTION(scalar, scalar, tan, trans)
460 UNARY_FUNCTION(scalar, scalar, asin, trans)
461 UNARY_FUNCTION(scalar, scalar, acos, trans)
462 UNARY_FUNCTION(scalar, scalar, atan, trans)
463 UNARY_FUNCTION(scalar, scalar, sinh, trans)
464 UNARY_FUNCTION(scalar, scalar, cosh, trans)
465 UNARY_FUNCTION(scalar, scalar, tanh, trans)
466 UNARY_FUNCTION(scalar, scalar, asinh, trans)
467 UNARY_FUNCTION(scalar, scalar, acosh, trans)
468 UNARY_FUNCTION(scalar, scalar, atanh, trans)
469 UNARY_FUNCTION(scalar, scalar, erf, trans)
470 UNARY_FUNCTION(scalar, scalar, erfc, trans)
471 UNARY_FUNCTION(scalar, scalar, lgamma, trans)
472 UNARY_FUNCTION(scalar, scalar, j0, trans)
473 UNARY_FUNCTION(scalar, scalar, j1, trans)
474 UNARY_FUNCTION(scalar, scalar, y0, trans)
475 UNARY_FUNCTION(scalar, scalar, y1, trans)
476 
477 
478 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
479 
480 #define BesselFunc(func) \
481  \
482 template<template<class> class PatchField, class GeoMesh> \
483 void func \
484 ( \
485  GeometricField<scalar, PatchField, GeoMesh>& gsf, \
486  const int n, \
487  const GeometricField<scalar, PatchField, GeoMesh>& gsf1 \
488 ) \
489 { \
490  func(gsf.internalField(), n, gsf1.internalField()); \
491  func(gsf.boundaryField(), n, gsf1.boundaryField()); \
492 } \
493  \
494 template<template<class> class PatchField, class GeoMesh> \
495 tmp<GeometricField<scalar, PatchField, GeoMesh> > func \
496 ( \
497  const int n, \
498  const GeometricField<scalar, PatchField, GeoMesh>& gsf \
499 ) \
500 { \
501  if (!gsf.dimensions().dimensionless()) \
502  { \
503  FatalErrorIn \
504  ( \
505  #func"(const int n, " \
506  "const GeometricField<scalar, PatchField, GeoMesh>& gsf)" \
507  ) << "gsf not dimensionless" \
508  << abort(FatalError); \
509  } \
510  \
511  tmp<GeometricField<scalar, PatchField, GeoMesh> > tFunc \
512  ( \
513  new GeometricField<scalar, PatchField, GeoMesh> \
514  ( \
515  IOobject \
516  ( \
517  #func "(" + gsf.name() + ')', \
518  gsf.instance(), \
519  gsf.db(), \
520  IOobject::NO_READ, \
521  IOobject::NO_WRITE \
522  ), \
523  gsf.mesh(), \
524  dimless \
525  ) \
526  ); \
527  \
528  func(tFunc(), n, gsf); \
529  \
530  return tFunc; \
531 } \
532  \
533 template<template<class> class PatchField, class GeoMesh> \
534 tmp<GeometricField<scalar, PatchField, GeoMesh> > func \
535 ( \
536  const int n, \
537  const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf \
538 ) \
539 { \
540  const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf(); \
541  \
542  if (!gsf.dimensions().dimensionless()) \
543  { \
544  FatalErrorIn \
545  ( \
546  #func"(const int n, " \
547  "const tmp<GeometricField<scalar, PatchField, GeoMesh> >& gsf)" \
548  ) << " : gsf not dimensionless" \
549  << abort(FatalError); \
550  } \
551  \
552  tmp<GeometricField<scalar, PatchField, GeoMesh> > tFunc \
553  ( \
554  reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New \
555  ( \
556  tgsf, \
557  #func "(" + gsf.name() + ')', \
558  dimless \
559  ) \
560  ); \
561  \
562  func(tFunc(), n, gsf); \
563  \
564  reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh> \
565  ::clear(tgsf); \
566  \
567  return tFunc; \
568 }
569 
572 
573 #undef BesselFunc
574 
575 
576 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
577 
578 } // End namespace Foam
579 
580 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
581 
583 
584 // ************************ vim: set sw=4 sts=4 et: ************************ //