initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / Fields / transformField / transformFieldTemplates.C
blob7c0c1248d24b7885762c1a7c2e17c88f6a6abb61
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "transformField.H"
28 #include "FieldM.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * global functions  * * * * * * * * * * * * * //
37 template<class Type>
38 void transform
40     Field<Type>& rtf,
41     const tensorField& trf,
42     const Field<Type>& tf
45     if (trf.size() == 1)
46     {
47         return transform(rtf, trf[0], tf);
48     }
49     else
50     {
51         TFOR_ALL_F_OP_FUNC_F_F
52         (
53             Type, rtf, =, transform, tensor, trf, Type, tf
54         )
55     }
59 template<class Type>
60 tmp<Field<Type> > transform
62     const tensorField& trf,
63     const Field<Type>& tf
66     tmp<Field<Type> > tranf(new Field<Type> (tf.size()));
67     transform(tranf(), trf, tf);
68     return tranf;
72 template<class Type>
73 tmp<Field<Type> > transform
75     const tensorField& trf,
76     const tmp<Field<Type> >& ttf
79     tmp<Field<Type> > tranf = reuseTmp<Type, Type>::New(ttf);
80     transform(tranf(), trf, ttf());
81     reuseTmp<Type, Type>::clear(ttf);
82     return tranf;
86 template<class Type>
87 tmp<Field<Type> > transform
89     const tmp<tensorField>& ttrf,
90     const Field<Type>& tf
93     tmp<Field<Type> > tranf(new Field<Type> (tf.size()));
94     transform(tranf(), ttrf(), tf);
95     ttrf.clear();
96     return tranf;
100 template<class Type>
101 tmp<Field<Type> > transform
103     const tmp<tensorField>& ttrf,
104     const tmp<Field<Type> >& ttf
107     tmp<Field<Type> > tranf = reuseTmp<Type, Type>::New(ttf);
108     transform(tranf(), ttrf(), ttf());
109     reuseTmp<Type, Type>::clear(ttf);
110     ttrf.clear();
111     return tranf;
115 template<class Type>
116 void transform
118     Field<Type>& rtf,
119     const tensor& t,
120     const Field<Type>& tf
123     TFOR_ALL_F_OP_FUNC_S_F(Type, rtf, =, transform, tensor, t, Type, tf)
127 template<class Type>
128 tmp<Field<Type> > transform
130     const tensor& t,
131     const Field<Type>& tf
134     tmp<Field<Type> > tranf(new Field<Type>(tf.size()));
135     transform(tranf(), t, tf);
136     return tranf;
140 template<class Type>
141 tmp<Field<Type> > transform
143     const tensor& t,
144     const tmp<Field<Type> >& ttf
147     tmp<Field<Type> > tranf = reuseTmp<Type, Type>::New(ttf);
148     transform(tranf(), t, ttf());
149     reuseTmp<Type, Type>::clear(ttf);
150     return tranf;
154 template<class Type1, class Type2>
155 tmp<Field<Type1> > transformFieldMask(const Field<Type2>& f)
157     return f;
160 template<class Type1, class Type2>
161 tmp<Field<Type1> > transformFieldMask(const tmp<Field<Type2> >& tf)
163     return tmp<Field<Type1> >(tf.ptr());
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // ************************************************************************* //