initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / Fields / transformList / transformList.C
blob5828381a6bebf57a87deb414fd61c31609d62070
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 "transformList.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 template <class T>
32 Foam::List<T> Foam::transform
34     const tensor& rotTensor,
35     const UList<T>& field
38     List<T> newField(field.size());
40     forAll(field, i)
41     {
42         newField[i] = transform(rotTensor, field[i]);
43     }
45     return newField;
49 template <class T>
50 void Foam::transformList
52     const tensorField& rotTensor,
53     UList<T>& field
56     if (rotTensor.size() == 1)
57     {
58         forAll(field, i)
59         {
60             field[i] = transform(rotTensor[0], field[i]);
61         }
62     }
63     else if (rotTensor.size() == field.size())
64     {
65         forAll(field, i)
66         {
67             field[i] = transform(rotTensor[i], field[i]);
68         }
69     }
70     else
71     {
72         FatalErrorIn
73         (
74             "transformList(const tensorField&, UList<T>&)"
75         )   << "Sizes of field and transformation not equal. field:"
76             << field.size() << " transformation:" << rotTensor.size()
77             << abort(FatalError);
78     }
82 template <class T>
83 void Foam::transformList
85     const tensorField& rotTensor,
86     Map<T>& field
89     if (rotTensor.size() == 1)
90     {
91         forAllIter(typename Map<T>, field, iter)
92         {
93             iter() = transform(rotTensor[0], iter());
94         }
95     }
96     else
97     {
98         FatalErrorIn
99         (
100             "transformList(const tensorField&, Map<T>&)"
101         )   << "Multiple transformation tensors not supported. field:"
102             << field.size() << " transformation:" << rotTensor.size()
103             << abort(FatalError);
104     }
108 template <class T>
109 void Foam::transformList
111     const tensorField& rotTensor,
112     EdgeMap<T>& field
115     if (rotTensor.size() == 1)
116     {
117         forAllIter(typename EdgeMap<T>, field, iter)
118         {
119             iter() = transform(rotTensor[0], iter());
120         }
121     }
122     else
123     {
124         FatalErrorIn
125         (
126             "transformList(const tensorField&, EdgeMap<T>&)"
127         )   << "Multiple transformation tensors not supported. field:"
128             << field.size() << " transformation:" << rotTensor.size()
129             << abort(FatalError);
130     }
134 // ************************************************************************* //