Loading...
Searching...
No Matches
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-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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 Foam_FieldFieldReuseFunctions_H
30#define Foam_FieldFieldReuseFunctions_H
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38// One-parameter versions
40template<template<class> class Field, class TypeR, class Type1>
42{
43 //- Pass-through to NewCalculatedType
45 (
47 )
48 {
50 }
51
52 //- Dissimilar types: just use size
54 (
56 )
57 {
59 }
60};
62
63template<template<class> class Field, class TypeR>
64struct reuseTmpFieldField<Field, TypeR, TypeR>
65{
66 //- Identical input and return types:
67 //- allow optional copy assignment of the initial content
69 (
70 const tmp<FieldField<Field, TypeR>>& tf1,
71 const bool initCopy = false
72 )
73 {
74 if (tf1.movable())
75 {
76 return tf1;
77 }
78
80
81 if (initCopy)
82 {
83 tresult.ref() = tf1();
84 }
85
86 return tresult;
87 }
88};
89
90
91//- This global function forwards to reuseTmpFieldField::New
92template<template<class> class Field, class TypeR>
93tmp<FieldField<Field, TypeR>> New
95 const tmp<FieldField<Field, TypeR>>& tf1,
96 const bool initCopy = false
97)
98{
100}
101
102
103// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104// Two-parameter versions
105
106template
107<
108 template<class> class Field,
109 class TypeR,
110 class Type1,
111 class Type12,
112 class Type2
113>
114struct reuseTmpTmpFieldField
116 //- Dissimilar types: just use size
118 (
119 const tmp<FieldField<Field, Type1>>& tf1,
121 )
122 {
124 }
125};
126
127
128template<template<class> class Field, class TypeR, class Type1, class Type12>
129struct reuseTmpTmpFieldField<Field, TypeR, Type1, Type12, TypeR>
130{
131 //- Second input has return type
133 (
134 const tmp<FieldField<Field, Type1>>& tf1,
135 const tmp<FieldField<Field, TypeR>>& tf2
136 )
138 if (tf2.movable())
139 {
140 return tf2;
141 }
142
144 }
145};
146
147
148template<template<class> class Field, class TypeR, class Type2>
149struct reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, Type2>
150{
151 //- First input has return type
152 static tmp<FieldField<Field, TypeR>> New
153 (
155 const tmp<FieldField<Field, Type2>>& tf2
156 )
157 {
158 if (tf1.movable())
160 return tf1;
161 }
162
164 }
165};
166
167
168template<template<class> class Field, class TypeR>
169struct reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, TypeR>
170{
171 //- Both inputs have return type
172 static tmp<FieldField<Field, TypeR>> New
173 (
174 const tmp<FieldField<Field, TypeR>>& tf1,
175 const tmp<FieldField<Field, TypeR>>& tf2
177 {
178 if (tf1.movable())
179 {
180 return tf1;
182 if (tf2.movable())
183 {
184 return tf2;
185 }
186
188 }
189};
190
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194} // End namespace Foam
195
196// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197
198#endif
199
200// ************************************************************************* //
A field of fields is a PtrList of fields with reference counting.
Definition FieldField.H:77
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition FieldField.C:191
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A class for managing temporary objects.
Definition tmp.H:75
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, TypeR > > &tf1, const bool initCopy=false)
Identical input and return types: allow optional copy assignment of the initial content.
static tmp< FieldField< Field, TypeR > > New(const FieldField< Field, Type1 > &f1)
Pass-through to NewCalculatedType.
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, Type1 > > &tf1)
Dissimilar types: just use size.
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, Type1 > > &tf1, const tmp< FieldField< Field, TypeR > > &tf2)
Second input has return type.
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, TypeR > > &tf1, const tmp< FieldField< Field, Type2 > > &tf2)
First input has return type.
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, TypeR > > &tf1, const tmp< FieldField< Field, TypeR > > &tf2)
Both inputs have return type.
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, Type1 > > &tf1, const tmp< FieldField< Field, Type2 > > &tf2)
Dissimilar types: just use size.