OpenFOAM logo
Open Source CFD Toolkit

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