scalarFieldField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Description
28  Specialisation of FieldField<T> for scalar.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "scalarFieldField.H"
33 
34 #define TEMPLATE template<template<class> class Field>
35 #include "FieldFieldFunctionsM.C"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 template<template<class> class Field>
45 void stabilise
46 (
48  const FieldField<Field, scalar>& f1,
49  const scalar s
50 )
51 {
52  forAll(f, i)
53  {
54  stabilise(f[i], f1[i], s);
55  }
56 }
57 
58 template<template<class> class Field>
59 tmp<FieldField<Field, scalar>> stabilise
60 (
61  const FieldField<Field, scalar>& f1,
62  const scalar s
63 )
64 {
65  tmp<FieldField<Field, scalar>> tf
66  (
68  );
69  stabilise(tf(), f1, s);
70  return tf;
71 }
72 
73 template<template<class> class Field>
74 tmp<FieldField<Field, scalar>> stabilise
75 (
76  const tmp<FieldField<Field, scalar>>& tf1,
77  const scalar s
78 )
79 {
80  tmp<FieldField<Field, scalar>> tf(tf1.ptr());
81  stabilise(tf(), tf(), s);
82  return tf;
83 }
84 
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
89 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
90 
91 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
92 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
93 
94 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
95 
96 BINARY_FUNCTION(scalar, scalar, scalar, pow)
97 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
98 
99 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
100 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
101 
102 BINARY_FUNCTION(scalar, scalar, scalar, hypot)
103 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, hypot)
104 
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 UNARY_FUNCTION(scalar, scalar, pow3)
109 UNARY_FUNCTION(scalar, scalar, pow4)
110 UNARY_FUNCTION(scalar, scalar, pow5)
111 UNARY_FUNCTION(scalar, scalar, pow6)
112 UNARY_FUNCTION(scalar, scalar, pow025)
113 UNARY_FUNCTION(scalar, scalar, sqrt)
114 UNARY_FUNCTION(scalar, scalar, cbrt)
115 UNARY_FUNCTION(scalar, scalar, sign)
116 UNARY_FUNCTION(scalar, scalar, pos)
117 UNARY_FUNCTION(scalar, scalar, pos0)
118 UNARY_FUNCTION(scalar, scalar, neg)
119 UNARY_FUNCTION(scalar, scalar, neg0)
120 UNARY_FUNCTION(scalar, scalar, posPart)
121 UNARY_FUNCTION(scalar, scalar, negPart)
122 UNARY_FUNCTION(scalar, scalar, exp)
123 UNARY_FUNCTION(scalar, scalar, log)
124 UNARY_FUNCTION(scalar, scalar, log10)
125 UNARY_FUNCTION(scalar, scalar, sin)
126 UNARY_FUNCTION(scalar, scalar, cos)
127 UNARY_FUNCTION(scalar, scalar, tan)
128 UNARY_FUNCTION(scalar, scalar, asin)
129 UNARY_FUNCTION(scalar, scalar, acos)
130 UNARY_FUNCTION(scalar, scalar, atan)
131 UNARY_FUNCTION(scalar, scalar, sinh)
132 UNARY_FUNCTION(scalar, scalar, cosh)
133 UNARY_FUNCTION(scalar, scalar, tanh)
134 UNARY_FUNCTION(scalar, scalar, asinh)
135 UNARY_FUNCTION(scalar, scalar, acosh)
136 UNARY_FUNCTION(scalar, scalar, atanh)
137 UNARY_FUNCTION(scalar, scalar, erf)
138 UNARY_FUNCTION(scalar, scalar, erfc)
139 UNARY_FUNCTION(scalar, scalar, lgamma)
140 UNARY_FUNCTION(scalar, scalar, j0)
141 UNARY_FUNCTION(scalar, scalar, j1)
142 UNARY_FUNCTION(scalar, scalar, y0)
143 UNARY_FUNCTION(scalar, scalar, y1)
144 
145 
146 #define BesselFunc(func) \
147  \
148 template<template<class> class Field> \
149 void func \
150 ( \
151  FieldField<Field, scalar>& res, \
152  const int n, \
153  const FieldField<Field, scalar>& sf \
154 ) \
155 { \
156  forAll(res, i) \
157  { \
158  func(res[i], n, sf[i]); \
159  } \
160 } \
161  \
162 template<template<class> class Field> \
163 tmp<FieldField<Field, scalar>> func \
164 ( \
165  const int n, \
166  const FieldField<Field, scalar>& sf \
167 ) \
168 { \
169  tmp<FieldField<Field, scalar>> tRes \
170  ( \
171  FieldField<Field, scalar>::NewCalculatedType(sf) \
172  ); \
173  func(tRes(), n, sf); \
174  return tRes; \
175 } \
176  \
177 template<template<class> class Field> \
178 tmp<FieldField<Field, scalar>> func \
179 ( \
180  const int n, \
181  const tmp<FieldField<Field, scalar>>& tsf \
182 ) \
183 { \
184  tmp<FieldField<Field, scalar>> tRes(New(tsf)); \
185  func(tRes(), n, tsf()); \
186  tsf.clear(); \
187  return tRes; \
188 }
189 
190 BesselFunc(jn)
191 BesselFunc(yn)
192 
193 #undef BesselFunc
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #include "undefFieldFunctionsM.H"
203 
204 // ************************************************************************* //
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar tanh(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
dimensionedScalar log(const dimensionedScalar &ds)
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
dimensionedScalar yn(const int n, const dimensionedScalar &ds)
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar pow025(const dimensionedScalar &ds)
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
dimensionedScalar y0(const dimensionedScalar &ds)
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensionedScalar posPart(const dimensionedScalar &ds)
dimensionedScalar neg(const dimensionedScalar &ds)
dimensionedScalar asin(const dimensionedScalar &ds)
dimensionedScalar pow5(const dimensionedScalar &ds)
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
dimensionedScalar j1(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
dimensionedScalar pos(const dimensionedScalar &ds)
dimensionedScalar acosh(const dimensionedScalar &ds)
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedScalar exp(const dimensionedScalar &ds)
Generic templated field type.
Definition: Field.H:62
dimensionedScalar asinh(const dimensionedScalar &ds)
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
dimensionedScalar cbrt(const dimensionedScalar &ds)
dimensionedScalar neg0(const dimensionedScalar &ds)
dimensionedScalar atanh(const dimensionedScalar &ds)
Specialisation of FieldField<T> for scalar.
dimensionedScalar y1(const dimensionedScalar &ds)
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition: FieldField.C:191
dimensionedScalar pos0(const dimensionedScalar &ds)
dimensionedScalar sin(const dimensionedScalar &ds)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensionedScalar erf(const dimensionedScalar &ds)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
labelList f(nPoints)
#define BesselFunc(func)
dimensionedScalar lgamma(const dimensionedScalar &ds)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensionedScalar erfc(const dimensionedScalar &ds)
dimensionedScalar sinh(const dimensionedScalar &ds)
dimensionedScalar atan(const dimensionedScalar &ds)
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensionedScalar pow6(const dimensionedScalar &ds)
dimensionedScalar cosh(const dimensionedScalar &ds)
void multiply(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionedScalar tan(const dimensionedScalar &ds)
dimensionedScalar j0(const dimensionedScalar &ds)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
dimensionedScalar log10(const dimensionedScalar &ds)
Namespace for OpenFOAM.
dimensionedScalar negPart(const dimensionedScalar &ds)