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

transformList.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 "transformList.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 template <class T>
00032 Foam::List<T> Foam::transform
00033 (
00034     const tensor& rotTensor,
00035     const UList<T>& field
00036 )
00037 {
00038     List<T> newField(field.size());
00039 
00040     forAll(field, i)
00041     {
00042         newField[i] = transform(rotTensor, field[i]);
00043     }
00044 
00045     return newField;
00046 }
00047 
00048 
00049 template <class T>
00050 void Foam::transformList
00051 (
00052     const tensorField& rotTensor,
00053     UList<T>& field
00054 )
00055 {
00056     if (rotTensor.size() == 1)
00057     {
00058         forAll(field, i)
00059         {
00060             field[i] = transform(rotTensor[0], field[i]);
00061         }
00062     }
00063     else if (rotTensor.size() == field.size())
00064     {
00065         forAll(field, i)
00066         {
00067             field[i] = transform(rotTensor[i], field[i]);
00068         }
00069     }
00070     else
00071     {
00072         FatalErrorIn
00073         (
00074             "transformList(const tensorField&, UList<T>&)"
00075         )   << "Sizes of field and transformation not equal. field:"
00076             << field.size() << " transformation:" << rotTensor.size()
00077             << abort(FatalError);
00078     }
00079 }
00080 
00081 
00082 template <class T>
00083 void Foam::transformList
00084 (
00085     const tensorField& rotTensor,
00086     Map<T>& field
00087 )
00088 {
00089     if (rotTensor.size() == 1)
00090     {
00091         forAllIter(typename Map<T>, field, iter)
00092         {
00093             iter() = transform(rotTensor[0], iter());
00094         }
00095     }
00096     else
00097     {
00098         FatalErrorIn
00099         (
00100             "transformList(const tensorField&, Map<T>&)"
00101         )   << "Multiple transformation tensors not supported. field:"
00102             << field.size() << " transformation:" << rotTensor.size()
00103             << abort(FatalError);
00104     }
00105 }
00106 
00107 
00108 template <class T>
00109 void Foam::transformList
00110 (
00111     const tensorField& rotTensor,
00112     EdgeMap<T>& field
00113 )
00114 {
00115     if (rotTensor.size() == 1)
00116     {
00117         forAllIter(typename EdgeMap<T>, field, iter)
00118         {
00119             iter() = transform(rotTensor[0], iter());
00120         }
00121     }
00122     else
00123     {
00124         FatalErrorIn
00125         (
00126             "transformList(const tensorField&, EdgeMap<T>&)"
00127         )   << "Multiple transformation tensors not supported. field:"
00128             << field.size() << " transformation:" << rotTensor.size()
00129             << abort(FatalError);
00130     }
00131 }
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd