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

transformField.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 #include "diagTensor.H"
00030 
00031 // * * * * * * * * * * * * * * * global functions  * * * * * * * * * * * * * //
00032 
00033 void Foam::transform
00034 (
00035     vectorField& rtf,
00036     const quaternion& q,
00037     const vectorField& tf
00038 )
00039 {
00040     tensor t = q.R();
00041     TFOR_ALL_F_OP_FUNC_S_F(vector, rtf, =, transform, tensor, t, vector, tf)
00042 }
00043 
00044 
00045 Foam::tmp<Foam::vectorField> Foam::transform
00046 (
00047     const quaternion& q,
00048     const vectorField& tf
00049 )
00050 {
00051     tmp<vectorField > tranf(new vectorField(tf.size()));
00052     transform(tranf(), q, tf);
00053     return tranf;
00054 }
00055 
00056 
00057 Foam::tmp<Foam::vectorField> Foam::transform
00058 (
00059     const quaternion& q,
00060     const tmp<vectorField>& ttf
00061 )
00062 {
00063     tmp<vectorField > tranf = reuseTmp<vector, vector>::New(ttf);
00064     transform(tranf(), q, ttf());
00065     reuseTmp<vector, vector>::clear(ttf);
00066     return tranf;
00067 }
00068 
00069 
00070 void Foam::transform
00071 (
00072     vectorField& rtf,
00073     const septernion& tr,
00074     const vectorField& tf
00075 )
00076 {
00077     vector T = tr.t();
00078 
00079     // Check if any rotation
00080     if (mag(tr.r().R() - I) > SMALL)
00081     {
00082         transform(rtf, tr.r(), tf);
00083 
00084         if (mag(T) > VSMALL)
00085         {
00086             rtf += T;
00087         }
00088     }
00089     else
00090     {
00091         if (mag(T) > VSMALL)
00092         {
00093             TFOR_ALL_F_OP_S_OP_F(vector, rtf, =, vector, T, +, vector, tf);
00094         }
00095         else
00096         {
00097             rtf = tf;
00098         }
00099     }
00100 }
00101 
00102 
00103 Foam::tmp<Foam::vectorField> Foam::transform
00104 (
00105     const septernion& tr,
00106     const vectorField& tf
00107 )
00108 {
00109     tmp<vectorField > tranf(new vectorField(tf.size()));
00110     transform(tranf(), tr, tf);
00111     return tranf;
00112 }
00113 
00114 
00115 Foam::tmp<Foam::vectorField> Foam::transform
00116 (
00117     const septernion& tr,
00118     const tmp<vectorField>& ttf
00119 )
00120 {
00121     tmp<vectorField > tranf = reuseTmp<vector, vector>::New(ttf);
00122     transform(tranf(), tr, ttf());
00123     reuseTmp<vector, vector>::clear(ttf);
00124     return tranf;
00125 }
00126 
00127 
00128 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd