Newer
Older
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
Henry Weller
committed
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
\*---------------------------------------------------------------------------*/
#include "GeometricFieldReuseFunctions.H"
#define TEMPLATE \
template<class Type, template<class> class PatchField, class GeoMesh>
#include "GeometricFieldFunctionsM.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void component
(
GeometricField
<
typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
PatchField,
GeoMesh
>& gcf,
const GeometricField<Type, PatchField, GeoMesh>& gf,
const direction d
)
{
component(gcf.internalField(), gf.internalField(), d);
component(gcf.boundaryField(), gf.boundaryField(), d);
}
template<class Type, template<class> class PatchField, class GeoMesh>
void T
(
GeometricField<Type, PatchField, GeoMesh>& gf,
const GeometricField<Type, PatchField, GeoMesh>& gf1
)
{
T(gf.internalField(), gf1.internalField());
T(gf.boundaryField(), gf1.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh, int r>
void pow
(
GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
const GeometricField<Type, PatchField, GeoMesh>& gf1
)
{
pow(gf.internalField(), gf1.internalField(), r);
pow(gf.boundaryField(), gf1.boundaryField(), r);
}
template<class Type, template<class> class PatchField, class GeoMesh, int r>
Henry Weller
committed
tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>>
pow
(
const GeometricField<Type, PatchField, GeoMesh>& gf,
typename powProduct<Type, r>::type
)
{
typedef typename powProduct<Type, r>::type powProductType;
Henry Weller
committed
tmp<GeometricField<powProductType, PatchField, GeoMesh>> tPow
(
new GeometricField<powProductType, PatchField, GeoMesh>
(
IOobject
(
"pow(" + gf.name() + ',' + name(r) + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
pow(gf.dimensions(), r)
)
);
pow<Type, r, PatchField, GeoMesh>(tPow(), gf);
return tPow;
}
template<class Type, template<class> class PatchField, class GeoMesh, int r>
Henry Weller
committed
tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>>
Henry Weller
committed
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
typename powProduct<Type, r>::type
)
{
typedef typename powProduct<Type, r>::type powProductType;
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
Henry Weller
committed
tmp<GeometricField<powProductType, PatchField, GeoMesh>> tPow
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
(
new GeometricField<powProductType, PatchField, GeoMesh>
(
IOobject
(
"pow(" + gf.name() + ',' + name(r) + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
pow(gf.dimensions(), r)
)
);
pow<Type, r, PatchField, GeoMesh>(tPow(), gf);
tgf.clear();
return tPow;
}
template<class Type, template<class> class PatchField, class GeoMesh>
void sqr
(
GeometricField
<typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
const GeometricField<Type, PatchField, GeoMesh>& gf1
)
{
sqr(gf.internalField(), gf1.internalField());
sqr(gf.boundaryField(), gf1.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename outerProduct<Type, Type>::type,
PatchField,
GeoMesh
>
>
sqr(const GeometricField<Type, PatchField, GeoMesh>& gf)
{
typedef typename outerProduct<Type, Type>::type outerProductType;
Henry Weller
committed
tmp<GeometricField<outerProductType, PatchField, GeoMesh>> tSqr
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
(
new GeometricField<outerProductType, PatchField, GeoMesh>
(
IOobject
(
"sqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
sqr(tSqr(), gf);
return tSqr;
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename outerProduct<Type, Type>::type,
PatchField,
GeoMesh
>
>
Henry Weller
committed
sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
{
typedef typename outerProduct<Type, Type>::type outerProductType;
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
Henry Weller
committed
tmp<GeometricField<outerProductType, PatchField, GeoMesh>> tSqr
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
(
new GeometricField<outerProductType, PatchField, GeoMesh>
(
IOobject
(
"sqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
sqr(tSqr(), gf);
tgf.clear();
return tSqr;
}
template<class Type, template<class> class PatchField, class GeoMesh>
void magSqr
(
GeometricField<scalar, PatchField, GeoMesh>& gsf,
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
magSqr(gsf.internalField(), gf.internalField());
magSqr(gsf.boundaryField(), gf.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
(
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMagSqr
(
new GeometricField<scalar, PatchField, GeoMesh>
(
IOobject
(
"magSqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
magSqr(tMagSqr(), gf);
return tMagSqr;
}
template<class Type, template<class> class PatchField, class GeoMesh>
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
Henry Weller
committed
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
)
{
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMagSqr
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
(
new GeometricField<scalar, PatchField, GeoMesh>
(
IOobject
(
"magSqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
magSqr(tMagSqr(), gf);
tgf.clear();
return tMagSqr;
}
template<class Type, template<class> class PatchField, class GeoMesh>
void mag
(
GeometricField<scalar, PatchField, GeoMesh>& gsf,
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
mag(gsf.internalField(), gf.internalField());
mag(gsf.boundaryField(), gf.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
(
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMag
(
new GeometricField<scalar, PatchField, GeoMesh>
(
IOobject
(
"mag(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
mag(tMag(), gf);
return tMag;
}
template<class Type, template<class> class PatchField, class GeoMesh>
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
Henry Weller
committed
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
)
{
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
Henry Weller
committed
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMag
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
(
new GeometricField<scalar, PatchField, GeoMesh>
(
IOobject
(
"mag(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
mag(tMag(), gf);
tgf.clear();
return tMag;
}
template<class Type, template<class> class PatchField, class GeoMesh>
void cmptAv
(
GeometricField
<
typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
PatchField,
GeoMesh
>& gcf,
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
cmptAv(gcf.internalField(), gf.internalField());
cmptAv(gcf.boundaryField(), gf.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
PatchField,
GeoMesh
>
>
cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf)
{
typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType
cmptType;
Henry Weller
committed
tmp<GeometricField<cmptType, PatchField, GeoMesh>> CmptAv
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
(
new GeometricField<scalar, PatchField, GeoMesh>
(
IOobject
(
"cmptAv(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
cmptAv(CmptAv(), gf);
return CmptAv;
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
PatchField,
GeoMesh
>
>
Henry Weller
committed
cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType
cmptType;
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
Henry Weller
committed
tmp<GeometricField<cmptType, PatchField, GeoMesh>> CmptAv
(
new GeometricField<scalar, PatchField, GeoMesh>
(
IOobject
(
"cmptAv(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
cmptAv(CmptAv(), gf);
tgf.clear();
return CmptAv;
}
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
dimensioned<returnType> func \
( \
const GeometricField<Type, PatchField, GeoMesh>& gf \
) \
{ \
return dimensioned<Type> \
( \
#func "(" + gf.name() + ')', \
gf.dimensions(), \
Foam::func(gFunc(gf.internalField()), gFunc(gf.boundaryField())) \
); \
} \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
dimensioned<returnType> func \
( \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
) \
{ \
dimensioned<returnType> res = func(tgf1()); \
tgf1.clear(); \
return res; \
}
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
#define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc) \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
dimensioned<returnType> func \
( \
const GeometricField<Type, PatchField, GeoMesh>& gf \
) \
{ \
return dimensioned<Type> \
( \
#func "(" + gf.name() + ')', \
gf.dimensions(), \
gFunc(gf.internalField()) \
); \
} \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
dimensioned<returnType> func \
( \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
) \
{ \
dimensioned<returnType> res = func(tgf1()); \
tgf1.clear(); \
return res; \
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
}
UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
#undef UNARY_REDUCTION_FUNCTION
BINARY_FUNCTION(Type, Type, Type, max)
BINARY_FUNCTION(Type, Type, Type, min)
BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
BINARY_FUNCTION(Type, Type, Type, cmptDivide)
BINARY_TYPE_FUNCTION(Type, Type, Type, max)
BINARY_TYPE_FUNCTION(Type, Type, Type, min)
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
UNARY_OPERATOR(Type, Type, -, negate, transform)
BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define PRODUCT_OPERATOR(product, op, opFunc) \
\
template \
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
void opFunc \
( \
GeometricField \
<typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
Foam::opFunc(gf.internalField(), gf1.internalField(), gf2.internalField());\
Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
} \
\
template \
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
tmp \
< \
GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
> \
operator op \
( \
const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
typedef typename product<Type1, Type2>::type productType; \
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<productType, PatchField, GeoMesh> \
( \
IOobject \
( \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.instance(), \
gf1.db(), \
IOobject::NO_READ, \
IOobject::NO_WRITE \
), \
gf1.mesh(), \
gf1.dimensions() op gf2.dimensions() \
) \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
return tRes; \
} \
\
template \
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
tmp \
< \
GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
> \
operator op \
( \
const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
) \
{ \
typedef typename product<Type1, Type2>::type productType; \
\
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh>::New \
( \
tgf2, \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh> \
::clear(tgf2); \
\
return tRes; \
} \
\
template \
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
tmp \
< \
GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
> \
operator op \
( \
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
typedef typename product<Type1, Type2>::type productType; \
\
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh> \
::clear(tgf1); \
\
return tRes; \
} \
\
template \
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
tmp \
< \
GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
> \
operator op \
( \
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
) \
{ \
typedef typename product<Type1, Type2>::type productType; \
\
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
reuseTmpTmpGeometricField \
<productType, Type1, Type1, Type2, PatchField, GeoMesh>::New \
( \
tgf1, \
tgf2, \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
reuseTmpTmpGeometricField \
<productType, Type1, Type1, Type2, PatchField, GeoMesh> \
::clear(tgf1, tgf2); \
\
return tRes; \
} \
\
template \
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
void opFunc \
( \
GeometricField \
<typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
const GeometricField<Type, PatchField, GeoMesh>& gf1, \
const dimensioned<Form>& dvs \
) \
{ \
Foam::opFunc(gf.internalField(), gf1.internalField(), dvs.value()); \
Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), dvs.value()); \
} \
\
template \
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
Henry Weller
committed
tmp<GeometricField<typename product<Type, Form>::type, PatchField, GeoMesh>> \
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
operator op \
( \
const GeometricField<Type, PatchField, GeoMesh>& gf1, \
const dimensioned<Form>& dvs \
) \
{ \
typedef typename product<Type, Form>::type productType; \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<productType, PatchField, GeoMesh> \
( \
IOobject \
( \
'(' + gf1.name() + #op + dvs.name() + ')', \
gf1.instance(), \
gf1.db(), \
IOobject::NO_READ, \
IOobject::NO_WRITE \
), \
gf1.mesh(), \
gf1.dimensions() op dvs.dimensions() \
) \
); \
\
Foam::opFunc(tRes(), gf1, dvs); \
\
return tRes; \
} \
\
template \
< \
class Form, \
class Cmpt, \
int nCmpt, \
class Type, template<class> class PatchField, \
class GeoMesh \
> \
Henry Weller
committed
tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh>> \
operator op \
( \
const GeometricField<Type, PatchField, GeoMesh>& gf1, \
const VectorSpace<Form,Cmpt,nCmpt>& vs \
) \
{ \
return gf1 op dimensioned<Form>(static_cast<const Form&>(vs)); \
} \
\
\
template \
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
Henry Weller
committed
tmp<GeometricField<typename product<Type, Form>::type, PatchField, GeoMesh>> \
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
operator op \
( \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
const dimensioned<Form>& dvs \
) \
{ \
typedef typename product<Type, Form>::type productType; \
\
const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New \
( \
tgf1, \
'(' + gf1.name() + #op + dvs.name() + ')', \
gf1.dimensions() op dvs.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, dvs); \
\
reuseTmpGeometricField<productType, Type, PatchField, GeoMesh> \
::clear(tgf1); \
\
return tRes; \
} \
\
template \
< \
class Form, \
class Cmpt, \
int nCmpt, \
class Type, template<class> class PatchField, \
class GeoMesh \
> \
Henry Weller
committed
tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh>> \
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
operator op \
( \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
const VectorSpace<Form,Cmpt,nCmpt>& vs \
) \
{ \
return tgf1 op dimensioned<Form>(static_cast<const Form&>(vs)); \
} \
\
\
template \
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
void opFunc \
( \
GeometricField \
<typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
const dimensioned<Form>& dvs, \
const GeometricField<Type, PatchField, GeoMesh>& gf1 \
) \
{ \
Foam::opFunc(gf.internalField(), dvs.value(), gf1.internalField()); \
Foam::opFunc(gf.boundaryField(), dvs.value(), gf1.boundaryField()); \
} \
\
template \
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
Henry Weller
committed
tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh>> \
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
operator op \
( \
const dimensioned<Form>& dvs, \
const GeometricField<Type, PatchField, GeoMesh>& gf1 \
) \
{ \
typedef typename product<Form, Type>::type productType; \
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<productType, PatchField, GeoMesh> \
( \
IOobject \
( \
'(' + dvs.name() + #op + gf1.name() + ')', \
gf1.instance(), \
gf1.db(), \
IOobject::NO_READ, \
IOobject::NO_WRITE \
), \
gf1.mesh(), \
dvs.dimensions() op gf1.dimensions() \
) \
); \
\
Foam::opFunc(tRes(), dvs, gf1); \
\
return tRes; \
} \
\
template \
< \
class Form, \
class Cmpt, \
int nCmpt, \
class Type, template<class> class PatchField, \
class GeoMesh \
> \
Henry Weller
committed
tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh>> \
operator op \
( \
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
const GeometricField<Type, PatchField, GeoMesh>& gf1 \
) \
{ \
return dimensioned<Form>(static_cast<const Form&>(vs)) op gf1; \
} \
\
template \
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
Henry Weller
committed
tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh>> \
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
operator op \
( \
const dimensioned<Form>& dvs, \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
) \
{ \
typedef typename product<Form, Type>::type productType; \
\
const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New \
( \
tgf1, \
'(' + dvs.name() + #op + gf1.name() + ')', \
dvs.dimensions() op gf1.dimensions() \
); \
\
Foam::opFunc(tRes(), dvs, gf1); \
\
reuseTmpGeometricField<productType, Type, PatchField, GeoMesh> \
::clear(tgf1); \
\
return tRes; \
} \
\
template \
< \
class Form, \
class Cmpt, \
int nCmpt, \
class Type, template<class> class PatchField, \
class GeoMesh \
> \
Henry Weller
committed
tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh>> \
operator op \
( \
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
) \
{ \
return dimensioned<Form>(static_cast<const Form&>(vs)) op tgf1; \
}
PRODUCT_OPERATOR(typeOfSum, +, add)
PRODUCT_OPERATOR(typeOfSum, -, subtract)
PRODUCT_OPERATOR(outerProduct, *, outer)
PRODUCT_OPERATOR(crossProduct, ^, cross)
PRODUCT_OPERATOR(innerProduct, &, dot)
PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
#undef PRODUCT_OPERATOR
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "undefFieldFunctionsM.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //