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

transformFieldTemplates.C

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 #include "transformField.H"
00028 #include "FieldM.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * global functions  * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 void transform
00039 (
00040     Field<Type>& rtf,
00041     const tensorField& trf,
00042     const Field<Type>& tf
00043 )
00044 {
00045     if (trf.size() == 1)
00046     {
00047         return transform(rtf, trf[0], tf);
00048     }
00049     else
00050     {
00051         TFOR_ALL_F_OP_FUNC_F_F
00052         (
00053             Type, rtf, =, transform, tensor, trf, Type, tf
00054         )
00055     }
00056 }
00057 
00058 
00059 template<class Type>
00060 tmp<Field<Type> > transform
00061 (
00062     const tensorField& trf,
00063     const Field<Type>& tf
00064 )
00065 {
00066     tmp<Field<Type> > tranf(new Field<Type> (tf.size()));
00067     transform(tranf(), trf, tf);
00068     return tranf;
00069 }
00070 
00071 
00072 template<class Type>
00073 tmp<Field<Type> > transform
00074 (
00075     const tensorField& trf,
00076     const tmp<Field<Type> >& ttf
00077 )
00078 {
00079     tmp<Field<Type> > tranf = reuseTmp<Type, Type>::New(ttf);
00080     transform(tranf(), trf, ttf());
00081     reuseTmp<Type, Type>::clear(ttf);
00082     return tranf;
00083 }
00084 
00085 
00086 template<class Type>
00087 tmp<Field<Type> > transform
00088 (
00089     const tmp<tensorField>& ttrf,
00090     const Field<Type>& tf
00091 )
00092 {
00093     tmp<Field<Type> > tranf(new Field<Type> (tf.size()));
00094     transform(tranf(), ttrf(), tf);
00095     ttrf.clear();
00096     return tranf;
00097 }
00098 
00099 
00100 template<class Type>
00101 tmp<Field<Type> > transform
00102 (
00103     const tmp<tensorField>& ttrf,
00104     const tmp<Field<Type> >& ttf
00105 )
00106 {
00107     tmp<Field<Type> > tranf = reuseTmp<Type, Type>::New(ttf);
00108     transform(tranf(), ttrf(), ttf());
00109     reuseTmp<Type, Type>::clear(ttf);
00110     ttrf.clear();
00111     return tranf;
00112 }
00113 
00114 
00115 template<class Type>
00116 void transform
00117 (
00118     Field<Type>& rtf,
00119     const tensor& t,
00120     const Field<Type>& tf
00121 )
00122 {
00123     TFOR_ALL_F_OP_FUNC_S_F(Type, rtf, =, transform, tensor, t, Type, tf)
00124 }
00125 
00126 
00127 template<class Type>
00128 tmp<Field<Type> > transform
00129 (
00130     const tensor& t,
00131     const Field<Type>& tf
00132 )
00133 {
00134     tmp<Field<Type> > tranf(new Field<Type>(tf.size()));
00135     transform(tranf(), t, tf);
00136     return tranf;
00137 }
00138 
00139 
00140 template<class Type>
00141 tmp<Field<Type> > transform
00142 (
00143     const tensor& t,
00144     const tmp<Field<Type> >& ttf
00145 )
00146 {
00147     tmp<Field<Type> > tranf = reuseTmp<Type, Type>::New(ttf);
00148     transform(tranf(), t, ttf());
00149     reuseTmp<Type, Type>::clear(ttf);
00150     return tranf;
00151 }
00152 
00153 
00154 template<class Type1, class Type2>
00155 tmp<Field<Type1> > transformFieldMask(const Field<Type2>& f)
00156 {
00157     return f;
00158 }
00159 
00160 template<class Type1, class Type2>
00161 tmp<Field<Type1> > transformFieldMask(const tmp<Field<Type2> >& tf)
00162 {
00163     return tmp<Field<Type1> >(tf.ptr());
00164 }
00165 
00166 
00167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00168 
00169 } // End namespace Foam
00170 
00171 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd