OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

FieldFieldReuseFunctions.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #ifndef FieldFieldReuseFunctions_H
00028 #define FieldFieldReuseFunctions_H
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 template<template<class> class Field, class TypeR, class Type1>
00038 class reuseTmpFieldField
00039 {
00040 public:
00041 
00042     static tmp<FieldField<Field, TypeR> > New
00043     (
00044         const tmp<FieldField<Field, Type1> >& tf1
00045     )
00046     {
00047         return tmp<FieldField<Field, TypeR> >
00048         (
00049             FieldField<Field, TypeR>::NewCalculatedType(tf1())
00050         );
00051     }
00052 
00053     static void clear(const tmp<FieldField<Field, Type1> >& tf1)
00054     {
00055         tf1.clear();
00056     }
00057 };
00058 
00059 
00060 template<template<class> class Field, class TypeR>
00061 class reuseTmpFieldField<Field, TypeR, TypeR>
00062 {
00063 public:
00064 
00065     static tmp<FieldField<Field, TypeR> > New
00066     (
00067         const tmp<FieldField<Field, TypeR> >& tf1
00068     )
00069     {
00070         if (tf1.isTmp())
00071         {
00072             return tf1;
00073         }
00074         else
00075         {
00076             return tmp<FieldField<Field, TypeR> >
00077             (
00078                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00079             );
00080         }
00081     }
00082 
00083     static void clear(const tmp<FieldField<Field, TypeR> >& tf1)
00084     {
00085         if (tf1.isTmp())
00086         {
00087             tf1.ptr();
00088         }
00089     }
00090 };
00091 
00092 
00093 template
00094 <
00095     template<class> class Field,
00096     class TypeR,
00097     class Type1,
00098     class Type12,
00099     class Type2
00100 >
00101 class reuseTmpTmpFieldField
00102 {
00103 public:
00104 
00105     static tmp<FieldField<Field, TypeR> > New
00106     (
00107         const tmp<FieldField<Field, Type1> >& tf1,
00108         const tmp<FieldField<Field, Type2> >& tf2
00109     )
00110     {
00111         return tmp<FieldField<Field, TypeR> >
00112         (
00113             FieldField<Field, TypeR>::NewCalculatedType(tf1())
00114         );
00115     }
00116 
00117     static void clear
00118     (
00119         const tmp<FieldField<Field, Type1> >& tf1,
00120         const tmp<FieldField<Field, Type2> >& tf2
00121     )
00122     {
00123         tf1.clear();
00124         tf2.clear();
00125     }
00126 };
00127 
00128 
00129 template<template<class> class Field, class TypeR, class Type1, class Type12>
00130 class reuseTmpTmpFieldField<Field, TypeR, Type1, Type12, TypeR>
00131 {
00132 public:
00133 
00134     static tmp<FieldField<Field, TypeR> > New
00135     (
00136         const tmp<FieldField<Field, Type1> >& tf1,
00137         const tmp<FieldField<Field, TypeR> >& tf2
00138     )
00139     {
00140         if (tf2.isTmp())
00141         {
00142             return tf2;
00143         }
00144         else
00145         {
00146             return tmp<FieldField<Field, TypeR> >
00147             (
00148                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00149             );
00150         }
00151     }
00152 
00153     static void clear
00154     (
00155         const tmp<FieldField<Field, Type1> >& tf1,
00156         const tmp<FieldField<Field, TypeR> >& tf2
00157     )
00158     {
00159         tf1.clear();
00160         if (tf2.isTmp())
00161         {
00162             tf2.ptr();
00163         }
00164     }
00165 };
00166 
00167 
00168 template<template<class> class Field, class TypeR, class Type2>
00169 class reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, Type2>
00170 {
00171 public:
00172 
00173     static tmp<FieldField<Field, TypeR> > New
00174     (
00175         const tmp<FieldField<Field, TypeR> >& tf1,
00176         const tmp<FieldField<Field, Type2> >& tf2
00177     )
00178     {
00179         if (tf1.isTmp())
00180         {
00181             return tf1;
00182         }
00183         else
00184         {
00185             return tmp<FieldField<Field, TypeR> >
00186             (
00187                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00188             );
00189         }
00190     }
00191 
00192     static void clear
00193     (
00194         const tmp<FieldField<Field, TypeR> >& tf1,
00195         const tmp<FieldField<Field, Type2> >& tf2
00196     )
00197     {
00198         if (tf1.isTmp())
00199         {
00200             tf1.ptr();
00201         }
00202         tf2.clear();
00203     }
00204 };
00205 
00206 
00207 template<template<class> class Field, class TypeR>
00208 class reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, TypeR>
00209 {
00210 public:
00211 
00212     static tmp<FieldField<Field, TypeR> > New
00213     (
00214         const tmp<FieldField<Field, TypeR> >& tf1,
00215         const tmp<FieldField<Field, TypeR> >& tf2
00216     )
00217     {
00218         if (tf1.isTmp())
00219         {
00220             return tf1;
00221         }
00222         else if (tf2.isTmp())
00223         {
00224             return tf2;
00225         }
00226         else
00227         {
00228             return tmp<FieldField<Field, TypeR> >
00229             (
00230                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00231             );
00232         }
00233     }
00234 
00235     static void clear
00236     (
00237         const tmp<FieldField<Field, TypeR> >& tf1,
00238         const tmp<FieldField<Field, TypeR> >& tf2
00239     )
00240     {
00241         if (tf1.isTmp())
00242         {
00243             tf1.ptr();
00244             tf2.clear();
00245         }
00246         else if (tf2.isTmp())
00247         {
00248             tf1.clear();
00249             tf2.ptr();
00250         }
00251     }
00252 };
00253 
00254 
00255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00256 
00257 } // End namespace Foam
00258 
00259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00260 
00261 #endif
00262 
00263 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd