FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #ifndef FieldFieldReuseFunctions_H
00027 #define FieldFieldReuseFunctions_H
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 template<template<class> class Field, class TypeR, class Type1>
00037 class reuseTmpFieldField
00038 {
00039 public:
00040 
00041     static tmp<FieldField<Field, TypeR> > New
00042     (
00043         const tmp<FieldField<Field, Type1> >& tf1
00044     )
00045     {
00046         return tmp<FieldField<Field, TypeR> >
00047         (
00048             FieldField<Field, TypeR>::NewCalculatedType(tf1())
00049         );
00050     }
00051 
00052     static void clear(const tmp<FieldField<Field, Type1> >& tf1)
00053     {
00054         tf1.clear();
00055     }
00056 };
00057 
00058 
00059 template<template<class> class Field, class TypeR>
00060 class reuseTmpFieldField<Field, TypeR, TypeR>
00061 {
00062 public:
00063 
00064     static tmp<FieldField<Field, TypeR> > New
00065     (
00066         const tmp<FieldField<Field, TypeR> >& tf1
00067     )
00068     {
00069         if (tf1.isTmp())
00070         {
00071             return tf1;
00072         }
00073         else
00074         {
00075             return tmp<FieldField<Field, TypeR> >
00076             (
00077                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00078             );
00079         }
00080     }
00081 
00082     static void clear(const tmp<FieldField<Field, TypeR> >& tf1)
00083     {
00084         if (tf1.isTmp())
00085         {
00086             tf1.ptr();
00087         }
00088     }
00089 };
00090 
00091 
00092 template
00093 <
00094     template<class> class Field,
00095     class TypeR,
00096     class Type1,
00097     class Type12,
00098     class Type2
00099 >
00100 class reuseTmpTmpFieldField
00101 {
00102 public:
00103 
00104     static tmp<FieldField<Field, TypeR> > New
00105     (
00106         const tmp<FieldField<Field, Type1> >& tf1,
00107         const tmp<FieldField<Field, Type2> >& tf2
00108     )
00109     {
00110         return tmp<FieldField<Field, TypeR> >
00111         (
00112             FieldField<Field, TypeR>::NewCalculatedType(tf1())
00113         );
00114     }
00115 
00116     static void clear
00117     (
00118         const tmp<FieldField<Field, Type1> >& tf1,
00119         const tmp<FieldField<Field, Type2> >& tf2
00120     )
00121     {
00122         tf1.clear();
00123         tf2.clear();
00124     }
00125 };
00126 
00127 
00128 template<template<class> class Field, class TypeR, class Type1, class Type12>
00129 class reuseTmpTmpFieldField<Field, TypeR, Type1, Type12, TypeR>
00130 {
00131 public:
00132 
00133     static tmp<FieldField<Field, TypeR> > New
00134     (
00135         const tmp<FieldField<Field, Type1> >& tf1,
00136         const tmp<FieldField<Field, TypeR> >& tf2
00137     )
00138     {
00139         if (tf2.isTmp())
00140         {
00141             return tf2;
00142         }
00143         else
00144         {
00145             return tmp<FieldField<Field, TypeR> >
00146             (
00147                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00148             );
00149         }
00150     }
00151 
00152     static void clear
00153     (
00154         const tmp<FieldField<Field, Type1> >& tf1,
00155         const tmp<FieldField<Field, TypeR> >& tf2
00156     )
00157     {
00158         tf1.clear();
00159         if (tf2.isTmp())
00160         {
00161             tf2.ptr();
00162         }
00163     }
00164 };
00165 
00166 
00167 template<template<class> class Field, class TypeR, class Type2>
00168 class reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, Type2>
00169 {
00170 public:
00171 
00172     static tmp<FieldField<Field, TypeR> > New
00173     (
00174         const tmp<FieldField<Field, TypeR> >& tf1,
00175         const tmp<FieldField<Field, Type2> >& tf2
00176     )
00177     {
00178         if (tf1.isTmp())
00179         {
00180             return tf1;
00181         }
00182         else
00183         {
00184             return tmp<FieldField<Field, TypeR> >
00185             (
00186                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00187             );
00188         }
00189     }
00190 
00191     static void clear
00192     (
00193         const tmp<FieldField<Field, TypeR> >& tf1,
00194         const tmp<FieldField<Field, Type2> >& tf2
00195     )
00196     {
00197         if (tf1.isTmp())
00198         {
00199             tf1.ptr();
00200         }
00201         tf2.clear();
00202     }
00203 };
00204 
00205 
00206 template<template<class> class Field, class TypeR>
00207 class reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, TypeR>
00208 {
00209 public:
00210 
00211     static tmp<FieldField<Field, TypeR> > New
00212     (
00213         const tmp<FieldField<Field, TypeR> >& tf1,
00214         const tmp<FieldField<Field, TypeR> >& tf2
00215     )
00216     {
00217         if (tf1.isTmp())
00218         {
00219             return tf1;
00220         }
00221         else if (tf2.isTmp())
00222         {
00223             return tf2;
00224         }
00225         else
00226         {
00227             return tmp<FieldField<Field, TypeR> >
00228             (
00229                 FieldField<Field, TypeR>::NewCalculatedType(tf1())
00230             );
00231         }
00232     }
00233 
00234     static void clear
00235     (
00236         const tmp<FieldField<Field, TypeR> >& tf1,
00237         const tmp<FieldField<Field, TypeR> >& tf2
00238     )
00239     {
00240         if (tf1.isTmp())
00241         {
00242             tf1.ptr();
00243             tf2.clear();
00244         }
00245         else if (tf2.isTmp())
00246         {
00247             tf1.clear();
00248             tf2.ptr();
00249         }
00250     }
00251 };
00252 
00253 
00254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00255 
00256 } // End namespace Foam
00257 
00258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00259 
00260 #endif
00261 
00262 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines