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

products.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-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 InNamespace
00025     Foam
00026 
00027 Description
00028     Traits classes for inner and outer products of primitives.
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 #ifndef products_H
00033 #define products_H
00034 
00035 #include <OpenFOAM/pTraits.H>
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 namespace Foam
00040 {
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 template<class Cmpt, int rank>
00045 class typeOfRank
00046 {};
00047 
00048 
00049 template<class Cmpt, int rank>
00050 class symmTypeOfRank
00051 {};
00052 
00053 
00054 template<class arg1, class arg2>
00055 class typeOfSum
00056 {
00057 public:
00058 
00059     typedef arg1 type;
00060 };
00061 
00062 
00063 template<class arg1, class arg2>
00064 class outerProduct
00065 {
00066 public:
00067 
00068     typedef typename typeOfRank
00069     <
00070         typename pTraits<arg1>::cmptType,
00071         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)
00072     >::type type;
00073 };
00074 
00075 
00076 template<class arg1, class arg2>
00077 class crossProduct
00078 {
00079 public:
00080 
00081     typedef typename typeOfRank
00082     <
00083         typename pTraits<arg2>::cmptType,
00084         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 1
00085     >::type type;
00086 };
00087 
00088 template<class arg1, class arg2>
00089 class innerProduct
00090 {
00091 public:
00092 
00093     typedef typename typeOfRank
00094     <
00095         typename pTraits<arg1>::cmptType,
00096         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 2
00097     >::type type;
00098 };
00099 
00100 template<class arg1, class arg2>
00101 class scalarProduct
00102 {
00103 public:
00104 
00105     typedef typename pTraits<arg1>::cmptType type;
00106 };
00107 
00108 
00109 template<class arg1, int arg2>
00110 class powProduct
00111 {
00112 public:
00113 
00114     typedef typename symmTypeOfRank
00115     <
00116         typename pTraits<arg1>::cmptType,
00117         arg2*int(pTraits<arg1>::rank)
00118     >::type type;
00119 };
00120 
00121 
00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00123 
00124 } // End namespace Foam
00125 
00126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00127 
00128 #endif
00129 
00130 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines