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 | Copyright (C) 2011-2016 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 \*---------------------------------------------------------------------------*/
25 
26 #ifndef FieldFieldReuseFunctions_H
27 #define FieldFieldReuseFunctions_H
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 template<template<class> class Field, class TypeR>
37 tmp<FieldField<Field, TypeR>> New
38 (
39  const tmp<FieldField<Field, TypeR>>& tf1,
40  const bool initRet = false
41 )
42 {
43  if (tf1.isTmp())
44  {
45  return tf1;
46  }
47  else
48  {
50  (
52  );
53 
54  if (initRet)
55  {
56  rtf.ref() = tf1();
57  }
58 
59  return rtf;
60  }
61 }
62 
63 
64 template<template<class> class Field, class TypeR, class Type1>
66 {
67 public:
68 
70  (
71  const tmp<FieldField<Field, Type1>>& tf1
72  )
73  {
75  (
77  );
78  }
79 };
80 
81 
82 template<template<class> class Field, class TypeR>
83 class reuseTmpFieldField<Field, TypeR, TypeR>
84 {
85 public:
86 
88  (
89  const tmp<FieldField<Field, TypeR>>& tf1
90  )
91  {
92  if (tf1.isTmp())
93  {
94  return tf1;
95  }
96  else
97  {
99  (
101  );
102  }
103  }
104 };
105 
106 
107 template
108 <
109  template<class> class Field,
110  class TypeR,
111  class Type1,
112  class Type12,
113  class Type2
114 >
116 {
117 public:
118 
120  (
121  const tmp<FieldField<Field, Type1>>& tf1,
122  const tmp<FieldField<Field, Type2>>& tf2
123  )
124  {
126  (
128  );
129  }
130 };
131 
132 
133 template<template<class> class Field, class TypeR, class Type1, class Type12>
134 class reuseTmpTmpFieldField<Field, TypeR, Type1, Type12, TypeR>
135 {
136 public:
137 
139  (
140  const tmp<FieldField<Field, Type1>>& tf1,
141  const tmp<FieldField<Field, TypeR>>& tf2
142  )
143  {
144  if (tf2.isTmp())
145  {
146  return tf2;
147  }
148  else
149  {
151  (
153  );
154  }
155  }
156 };
157 
158 
159 template<template<class> class Field, class TypeR, class Type2>
160 class reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, Type2>
161 {
162 public:
163 
165  (
166  const tmp<FieldField<Field, TypeR>>& tf1,
167  const tmp<FieldField<Field, Type2>>& tf2
168  )
169  {
170  if (tf1.isTmp())
171  {
172  return tf1;
173  }
174  else
175  {
177  (
179  );
180  }
181  }
182 };
183 
184 
185 template<template<class> class Field, class TypeR>
186 class reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, TypeR>
187 {
188 public:
189 
191  (
192  const tmp<FieldField<Field, TypeR>>& tf1,
193  const tmp<FieldField<Field, TypeR>>& tf2
194  )
195  {
196  if (tf1.isTmp())
197  {
198  return tf1;
199  }
200  else if (tf2.isTmp())
201  {
202  return tf2;
203  }
204  else
205  {
207  (
209  );
210  }
211  }
212 };
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
static tmp< FieldField< Field, TypeR > > New(const tmp< FieldField< Field, Type1 >> &tf1)
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
Generic field type.
Definition: FieldField.H:51
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Pre-declare SubField and related Field type.
Definition: Field.H:57
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition: FieldField.C:191
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.