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 | Copyright (C) 2011-2015 OpenFOAM Foundation
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 Description
25  Specialisation of FieldField<T> for scalar.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "scalarFieldField.H"
30 
31 #define TEMPLATE template<template<class> class Field>
32 #include "FieldFieldFunctionsM.C"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 template<template<class> class Field>
42 void stabilise
43 (
46  const scalar s
47 )
48 {
49  forAll(f, i)
50  {
51  stabilise(f[i], f1[i], s);
52  }
53 }
54 
55 template<template<class> class Field>
56 tmp<FieldField<Field, scalar> > stabilise
57 (
59  const scalar s
60 )
61 {
63  (
65  );
66  stabilise(tf(), f1, s);
67  return tf;
68 }
69 
70 template<template<class> class Field>
71 tmp<FieldField<Field, scalar> > stabilise
72 (
73  const tmp<FieldField<Field, scalar> >& tf1,
74  const scalar s
75 )
76 {
77  tmp<FieldField<Field, scalar> > tf(tf1.ptr());
78  stabilise(tf(), tf(), s);
79  return tf;
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
86 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
87 
88 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
89 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
90 
91 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
92 
93 BINARY_FUNCTION(scalar, scalar, scalar, pow)
94 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
95 
96 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
97 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
98 
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 UNARY_FUNCTION(scalar, scalar, pow3)
103 UNARY_FUNCTION(scalar, scalar, pow4)
104 UNARY_FUNCTION(scalar, scalar, pow5)
105 UNARY_FUNCTION(scalar, scalar, pow6)
106 UNARY_FUNCTION(scalar, scalar, pow025)
107 UNARY_FUNCTION(scalar, scalar, sqrt)
108 UNARY_FUNCTION(scalar, scalar, cbrt)
109 UNARY_FUNCTION(scalar, scalar, sign)
110 UNARY_FUNCTION(scalar, scalar, pos)
111 UNARY_FUNCTION(scalar, scalar, neg)
112 UNARY_FUNCTION(scalar, scalar, posPart)
113 UNARY_FUNCTION(scalar, scalar, negPart)
114 UNARY_FUNCTION(scalar, scalar, exp)
115 UNARY_FUNCTION(scalar, scalar, log)
116 UNARY_FUNCTION(scalar, scalar, log10)
117 UNARY_FUNCTION(scalar, scalar, sin)
118 UNARY_FUNCTION(scalar, scalar, cos)
119 UNARY_FUNCTION(scalar, scalar, tan)
120 UNARY_FUNCTION(scalar, scalar, asin)
121 UNARY_FUNCTION(scalar, scalar, acos)
122 UNARY_FUNCTION(scalar, scalar, atan)
123 UNARY_FUNCTION(scalar, scalar, sinh)
124 UNARY_FUNCTION(scalar, scalar, cosh)
125 UNARY_FUNCTION(scalar, scalar, tanh)
126 UNARY_FUNCTION(scalar, scalar, asinh)
127 UNARY_FUNCTION(scalar, scalar, acosh)
128 UNARY_FUNCTION(scalar, scalar, atanh)
129 UNARY_FUNCTION(scalar, scalar, erf)
130 UNARY_FUNCTION(scalar, scalar, erfc)
131 UNARY_FUNCTION(scalar, scalar, lgamma)
132 UNARY_FUNCTION(scalar, scalar, j0)
133 UNARY_FUNCTION(scalar, scalar, j1)
134 UNARY_FUNCTION(scalar, scalar, y0)
135 UNARY_FUNCTION(scalar, scalar, y1)
136 
137 
138 #define BesselFunc(func) \
139  \
140 template<template<class> class Field> \
141 void func \
142 ( \
143  FieldField<Field, scalar>& res, \
144  const int n, \
145  const FieldField<Field, scalar>& sf \
146 ) \
147 { \
148  forAll(res, i) \
149  { \
150  func(res[i], n, sf[i]); \
151  } \
152 } \
153  \
154 template<template<class> class Field> \
155 tmp<FieldField<Field, scalar> > func \
156 ( \
157  const int n, \
158  const FieldField<Field, scalar>& sf \
159 ) \
160 { \
161  tmp<FieldField<Field, scalar> > tRes \
162  ( \
163  FieldField<Field, scalar>::NewCalculatedType(sf) \
164  ); \
165  func(tRes(), n, sf); \
166  return tRes; \
167 } \
168  \
169 template<template<class> class Field> \
170 tmp<FieldField<Field, scalar> > func \
171 ( \
172  const int n, \
173  const tmp<FieldField<Field, scalar> >& tsf \
174 ) \
175 { \
176  tmp<FieldField<Field, scalar> > tRes \
177  ( \
178  reuseTmpFieldField<Field, scalar, scalar>::New(tsf) \
179  ); \
180  func(tRes(), n, tsf()); \
181  reuseTmpFieldField<Field, scalar, scalar>::clear(tsf); \
182  return tRes; \
183 }
184 
187 
188 #undef BesselFunc
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #include "undefFieldFunctionsM.H"
198 
199 // ************************************************************************* //
BINARY_TYPE_OPERATOR_SF
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:531
BINARY_OPERATOR
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:417
Foam::subtract
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:871
Foam::tan
dimensionedScalar tan(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:257
UNARY_FUNCTION
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
Definition: DimensionedFieldFunctionsM.C:30
Foam::FieldField
Generic field type.
Definition: FieldField.H:51
Foam::cosh
dimensionedScalar cosh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
Foam::y1
dimensionedScalar y1(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:273
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
Foam::jn
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
Definition: dimensionedScalar.C:296
Foam::posPart
dimensionedScalar posPart(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:212
Foam::atan2
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
Definition: dimensionedScalar.C:303
BINARY_TYPE_OPERATOR
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:684
undefFieldFunctionsM.H
Foam::exp
dimensionedScalar exp(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:252
BINARY_FUNCTION
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:142
Foam::sign
dimensionedScalar sign(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:179
Foam::erf
dimensionedScalar erf(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:267
Foam::divide
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Foam::pow025
dimensionedScalar pow025(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:131
tf
const tensorField & tf
Definition: getPatchFieldTensor.H:36
Foam::atanh
dimensionedScalar atanh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:266
Foam::lgamma
dimensionedScalar lgamma(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:269
Foam::pow4
dimensionedScalar pow4(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:98
Foam::pow6
dimensionedScalar pow6(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:120
Foam::tanh
dimensionedScalar tanh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:263
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:87
Foam::stabilise
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
Definition: DimensionedScalarField.C:40
Foam::log10
dimensionedScalar log10(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:254
Foam::y0
dimensionedScalar y0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:272
Foam::erfc
dimensionedScalar erfc(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:268
f1
scalar f1
Definition: createFields.H:28
Foam::asinh
dimensionedScalar asinh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:264
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
FieldFieldFunctionsM.C
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:870
Foam::pow5
dimensionedScalar pow5(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:109
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:253
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
BINARY_TYPE_FUNCTION
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:410
BesselFunc
#define BesselFunc(func)
Definition: scalarFieldField.C:138
Foam::yn
dimensionedScalar yn(const int n, const dimensionedScalar &ds)
Definition: dimensionedScalar.C:297
Foam::acosh
dimensionedScalar acosh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265
scalarFieldField.H
Specialisation of FieldField<T> for scalar.
Foam::negPart
dimensionedScalar negPart(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:223
f
labelList f(nPoints)
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
Foam::j0
dimensionedScalar j0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:270
Foam::acos
dimensionedScalar acos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:259
Foam::atan
dimensionedScalar atan(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:260
Foam::multiply
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Foam::cbrt
dimensionedScalar cbrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:153
Foam::j1
dimensionedScalar j1(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:271
Foam::neg
dimensionedScalar neg(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:201
Foam::asin
dimensionedScalar asin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:258
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190
Foam::sinh
dimensionedScalar sinh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:261