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