OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

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-2007 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 Cmpt, int rank>
00051 class symmTypeOfRank
00052 {};
00053 
00054 
00055 template<class arg1, class arg2>
00056 class typeOfSum
00057 {
00058 public:
00059 
00060     typedef arg1 type;
00061 };
00062 
00063 
00064 template<class arg1, class arg2>
00065 class outerProduct
00066 {
00067 public:
00068 
00069     typedef typename typeOfRank
00070     <
00071         typename pTraits<arg1>::cmptType,
00072         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)
00073     >::type type;
00074 };
00075 
00076 
00077 template<class arg1, class arg2>
00078 class crossProduct
00079 {
00080 public:
00081 
00082     typedef typename typeOfRank
00083     <
00084         typename pTraits<arg2>::cmptType,
00085         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 1
00086     >::type type;
00087 };
00088 
00089 
00090 template<class arg1, class arg2>
00091 class innerProduct
00092 {
00093 public:
00094 
00095     typedef typename typeOfRank
00096     <
00097         typename pTraits<arg1>::cmptType,
00098         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 2
00099     >::type type;
00100 };
00101 
00102 
00103 template<class arg1, class arg2>
00104 class scalarProduct
00105 {
00106 public:
00107 
00108     typedef typename pTraits<arg1>::cmptType type;
00109 };
00110 
00111 
00112 template<class arg1, int arg2>
00113 class powProduct
00114 {
00115 public:
00116 
00117     typedef typename symmTypeOfRank
00118     <
00119         typename pTraits<arg1>::cmptType,
00120         arg2*int(pTraits<arg1>::rank)
00121     >::type type;
00122 };
00123 
00124 
00125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00126 
00127 } // End namespace Foam
00128 
00129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00130 
00131 #endif
00132 
00133 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd