OpenFOAM logo
Open Source CFD Toolkit

transform.H

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-2005 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 Class
00026     transform
00027 
00028 Description
00029     3D tensor transformation operations.
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #ifndef transform_H
00034 #define transform_H
00035 
00036 #include "tensor.H"
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 namespace Foam
00041 {
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 inline tensor transformationTensor
00046 (
00047     const vector& n1,
00048     const vector& n2
00049 )
00050 {
00051     return
00052         (n1 & n2)*I
00053       + (1 - (n1 & n2))*sqr(n1 ^ n2)/(magSqr(n1 ^ n2) + VSMALL)
00054       + (n2*n1 - n1*n2);
00055 }
00056 
00057 
00058 inline scalar transform(const tensor&, const scalar s)
00059 {
00060     return s;
00061 }
00062 
00063 
00064 template<class Cmpt>
00065 inline Vector<Cmpt> transform(const tensor& tt, const Vector<Cmpt>& v)
00066 {
00067     return tt & v;
00068 }
00069 
00070 
00071 template<class Cmpt>
00072 inline Tensor<Cmpt> transform(const tensor& tt, const Tensor<Cmpt>& t)
00073 {
00074     return tt & t & tt.T();
00075 }
00076 
00077 
00078 template<class Cmpt>
00079 inline SphericalTensor<Cmpt> transform
00080 (
00081     const tensor& tt,
00082     const SphericalTensor<Cmpt>& st
00083 )
00084 {
00085     return st;
00086 }
00087 
00088 
00089 template<class Type1, class Type2>
00090 inline Type1 transformMask(const Type2& t)
00091 {
00092     return t;
00093 }
00094 
00095 
00096 template<>
00097 inline SphericalTensor<scalar> transformMask(const tensor& t)
00098 {
00099     return SphericalTensor<scalar>::one;
00100 }
00101 
00102 
00103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00104 
00105 } // End namespace Foam
00106 
00107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00108 
00109 #endif
00110 
00111 // ************************************************************************* //
For further information go to www.openfoam.org