OpenFOAM: API Guide
v2112
The open source CFD toolbox
FieldFieldReuseFunctions.H
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-2016 OpenFOAM Foundation
9
Copyright (C) 2018-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
\*---------------------------------------------------------------------------*/
28
29
#ifndef FieldFieldReuseFunctions_H
30
#define FieldFieldReuseFunctions_H
31
32
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
37
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39
template
<
template
<
class
>
class
Field,
class
TypeR,
class
Type1>
40
struct
reuseTmpFieldField
41
{
42
static
tmp<FieldField<Field, TypeR>
>
New
43
(
44
const
tmp
<
FieldField<Field, Type1>
>& tf1
45
)
46
{
47
return
FieldField<Field, TypeR>::NewCalculatedType
(tf1());
48
}
49
};
50
51
52
template
<
template
<
class
>
class
Field,
class
TypeR>
53
struct
reuseTmpFieldField
<
Field
, TypeR, TypeR>
54
{
55
static
tmp<FieldField<Field, TypeR>
>
New
56
(
57
const
tmp
<
FieldField<Field, TypeR>
>& tf1,
58
const
bool
initCopy =
false
59
)
60
{
61
if
(tf1.isTmp())
62
{
63
return
tf1;
64
}
65
66
auto
rtf =
FieldField<Field, TypeR>::NewCalculatedType
(tf1());
67
68
if
(initCopy)
69
{
70
rtf.ref() = tf1();
71
}
72
73
return
rtf;
74
}
75
};
76
77
78
//- Global function forwards to reuseTmpFieldField::New
79
template
<
template
<
class
>
class
Field,
class
TypeR>
80
tmp<FieldField<Field, TypeR>>
New
81
(
82
const
tmp
<
FieldField<Field, TypeR>
>& tf1,
83
const
bool
initCopy =
false
84
)
85
{
86
return
reuseTmpFieldField<Field, TypeR, TypeR>::New
(tf1, initCopy);
87
}
88
89
90
template
91
<
92
template
<
class
>
class
Field,
93
class
TypeR,
94
class
Type1,
95
class
Type12,
96
class
Type2
97
>
98
struct
reuseTmpTmpFieldField
99
{
100
static
tmp<FieldField<Field, TypeR>
>
New
101
(
102
const
tmp
<
FieldField<Field, Type1>
>& tf1,
103
const
tmp
<
FieldField<Field, Type2>
>& tf2
104
)
105
{
106
return
FieldField<Field, TypeR>::NewCalculatedType
(tf1());
107
}
108
};
109
110
111
template
<
template
<
class
>
class
Field,
class
TypeR,
class
Type1,
class
Type12>
112
struct
reuseTmpTmpFieldField
<
Field
, TypeR, Type1, Type12, TypeR>
113
{
114
static
tmp<FieldField<Field, TypeR>
>
New
115
(
116
const
tmp
<
FieldField<Field, Type1>
>& tf1,
117
const
tmp
<
FieldField<Field, TypeR>
>& tf2
118
)
119
{
120
if
(tf2.isTmp())
121
{
122
return
tf2;
123
}
124
125
return
FieldField<Field, TypeR>::NewCalculatedType
(tf1());
126
}
127
};
128
129
130
template
<
template
<
class
>
class
Field,
class
TypeR,
class
Type2>
131
struct
reuseTmpTmpFieldField
<
Field
, TypeR, TypeR, TypeR, Type2>
132
{
133
static
tmp<FieldField<Field, TypeR>
>
New
134
(
135
const
tmp
<
FieldField<Field, TypeR>
>& tf1,
136
const
tmp
<
FieldField<Field, Type2>
>& tf2
137
)
138
{
139
if
(tf1.isTmp())
140
{
141
return
tf1;
142
}
143
144
return
FieldField<Field, TypeR>::NewCalculatedType
(tf1());
145
}
146
};
147
148
149
template
<
template
<
class
>
class
Field,
class
TypeR>
150
struct
reuseTmpTmpFieldField
<
Field
, TypeR, TypeR, TypeR, TypeR>
151
{
152
static
tmp<FieldField<Field, TypeR>
>
New
153
(
154
const
tmp
<
FieldField<Field, TypeR>
>& tf1,
155
const
tmp
<
FieldField<Field, TypeR>
>& tf2
156
)
157
{
158
if
(tf1.isTmp())
159
{
160
return
tf1;
161
}
162
else
if
(tf2.isTmp())
163
{
164
return
tf2;
165
}
166
167
return
FieldField<Field, TypeR>::NewCalculatedType
(tf1());
168
}
169
};
170
171
172
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174
}
// End namespace Foam
175
176
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178
#endif
179
180
// ************************************************************************* //
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition:
FieldField.H:53
Foam::tmp
A class for managing temporary objects.
Definition:
PtrList.H:61
Foam::Field
Generic templated field type.
Definition:
Field.H:63
Foam::FieldField::NewCalculatedType
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition:
FieldField.C:198
Foam::reuseTmpFieldField::New
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, Type1 >> &tf1)
Definition:
FieldFieldReuseFunctions.H:43
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:33
Foam::reuseTmpTmpFieldField
Definition:
FieldFieldReuseFunctions.H:98
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition:
DimensionedFieldReuseFunctions.H:105
Foam::reuseTmpFieldField
Definition:
FieldFieldReuseFunctions.H:40
Foam::reuseTmpTmpFieldField::New
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, Type1 >> &tf1, const tmp< FieldField< Field, Type2 >> &tf2)
Definition:
FieldFieldReuseFunctions.H:101
src
OpenFOAM
fields
FieldFields
FieldField
FieldFieldReuseFunctions.H
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.