FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "transformField.H"
00027 #include <OpenFOAM/FieldM.H>
00028 #include <OpenFOAM/diagTensor.H>
00029 
00030 // * * * * * * * * * * * * * * * global functions  * * * * * * * * * * * * * //
00031 
00032 void Foam::transform
00033 (
00034     vectorField& rtf,
00035     const quaternion& q,
00036     const vectorField& tf
00037 )
00038 {
00039     tensor t = q.R();
00040     TFOR_ALL_F_OP_FUNC_S_F(vector, rtf, =, transform, tensor, t, vector, tf)
00041 }
00042 
00043 
00044 Foam::tmp<Foam::vectorField> Foam::transform
00045 (
00046     const quaternion& q,
00047     const vectorField& tf
00048 )
00049 {
00050     tmp<vectorField > tranf(new vectorField(tf.size()));
00051     transform(tranf(), q, tf);
00052     return tranf;
00053 }
00054 
00055 
00056 Foam::tmp<Foam::vectorField> Foam::transform
00057 (
00058     const quaternion& q,
00059     const tmp<vectorField>& ttf
00060 )
00061 {
00062     tmp<vectorField > tranf = reuseTmp<vector, vector>::New(ttf);
00063     transform(tranf(), q, ttf());
00064     reuseTmp<vector, vector>::clear(ttf);
00065     return tranf;
00066 }
00067 
00068 
00069 void Foam::transform
00070 (
00071     vectorField& rtf,
00072     const septernion& tr,
00073     const vectorField& tf
00074 )
00075 {
00076     vector T = tr.t();
00077 
00078     // Check if any rotation
00079     if (mag(tr.r().R() - I) > SMALL)
00080     {
00081         transform(rtf, tr.r(), tf);
00082 
00083         if (mag(T) > VSMALL)
00084         {
00085             rtf += T;
00086         }
00087     }
00088     else
00089     {
00090         if (mag(T) > VSMALL)
00091         {
00092             TFOR_ALL_F_OP_S_OP_F(vector, rtf, =, vector, T, +, vector, tf);
00093         }
00094         else
00095         {
00096             rtf = tf;
00097         }
00098     }
00099 }
00100 
00101 
00102 Foam::tmp<Foam::vectorField> Foam::transform
00103 (
00104     const septernion& tr,
00105     const vectorField& tf
00106 )
00107 {
00108     tmp<vectorField > tranf(new vectorField(tf.size()));
00109     transform(tranf(), tr, tf);
00110     return tranf;
00111 }
00112 
00113 
00114 Foam::tmp<Foam::vectorField> Foam::transform
00115 (
00116     const septernion& tr,
00117     const tmp<vectorField>& ttf
00118 )
00119 {
00120     tmp<vectorField > tranf = reuseTmp<vector, vector>::New(ttf);
00121     transform(tranf(), tr, ttf());
00122     reuseTmp<vector, vector>::clear(ttf);
00123     return tranf;
00124 }
00125 
00126 
00127 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines