OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-2009 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 InNamespace
00026     Foam
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 template<class arg1, class arg2>
00090 class innerProduct
00091 {
00092 public:
00093 
00094     typedef typename typeOfRank
00095     <
00096         typename pTraits<arg1>::cmptType,
00097         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 2
00098     >::type type;
00099 };
00100 
00101 template<class arg1, class arg2>
00102 class scalarProduct
00103 {
00104 public:
00105 
00106     typedef typename pTraits<arg1>::cmptType type;
00107 };
00108 
00109 
00110 template<class arg1, int arg2>
00111 class powProduct
00112 {
00113 public:
00114 
00115     typedef typename symmTypeOfRank
00116     <
00117         typename pTraits<arg1>::cmptType,
00118         arg2*int(pTraits<arg1>::rank)
00119     >::type type;
00120 };
00121 
00122 
00123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00124 
00125 } // End namespace Foam
00126 
00127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00128 
00129 #endif
00130 
00131 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd