OpenFOAM logo
Open Source CFD Toolkit

Tensor.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     Tensor
00027 
00028 Description
00029     Templated 3D Tensor derived from VectorSpace adding construction from
00030     9 components, element access using xx(), xy() etc. member functions and
00031     the iner-product (dot-product) and outer-product of two Vectors
00032     (tensor-product) operators.
00033 
00034 SourceFiles
00035     TensorI.H
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef Tensor_H
00040 #define Tensor_H
00041 
00042 #include "Vector.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class Tensor Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 template <class Cmpt>
00054 class Tensor
00055 :
00056     public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
00057 {
00058 
00059 public:
00060 
00061     // Member constants
00062 
00063         enum
00064         {
00065             rank = 2 // Rank of Tensor is 2
00066         };
00067 
00068 
00069     // Static data members
00070 
00071         static const char* const typeName;
00072         static const char* componentNames[];
00073 
00074         static const Tensor zero;
00075         static const Tensor one;
00076         static const Tensor I;
00077 
00078     //- Component labeling enumeration
00079     enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
00080 
00081 
00082     // Constructors
00083 
00084         //- Construct null
00085         inline Tensor();
00086 
00087         //- Construct given VectorSpace
00088         inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
00089 
00090         //- Construct given the nine components
00091         inline Tensor
00092         (
00093             const Cmpt txx, const Cmpt txy, const Cmpt txz,
00094             const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
00095             const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
00096         );
00097 
00098         //- Construct from Istream
00099         Tensor(Istream&);
00100 
00101 
00102     // Member Functions
00103 
00104         // Access
00105 
00106             inline const Vector<Cmpt>& x() const;
00107             inline const Vector<Cmpt>& y() const;
00108             inline const Vector<Cmpt>& z() const;
00109 
00110             inline Vector<Cmpt>& x();
00111             inline Vector<Cmpt>& y();
00112             inline Vector<Cmpt>& z();
00113 
00114             inline const Cmpt& xx() const;
00115             inline const Cmpt& xy() const;
00116             inline const Cmpt& xz() const;
00117             inline const Cmpt& yx() const;
00118             inline const Cmpt& yy() const;
00119             inline const Cmpt& yz() const;
00120             inline const Cmpt& zx() const;
00121             inline const Cmpt& zy() const;
00122             inline const Cmpt& zz() const;
00123 
00124             inline Cmpt& xx();
00125             inline Cmpt& xy();
00126             inline Cmpt& xz();
00127             inline Cmpt& yx();
00128             inline Cmpt& yy();
00129             inline Cmpt& yz();
00130             inline Cmpt& zx();
00131             inline Cmpt& zy();
00132             inline Cmpt& zz();
00133 
00134         //- Transpose
00135         inline Tensor<Cmpt> T() const;
00136 };
00137 
00138 
00139 template<class Cmpt>
00140 class typeOfRank<Cmpt, 2>
00141 {
00142 public:
00143 
00144     typedef Tensor<Cmpt> type;
00145 };
00146 
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 } // End namespace Foam
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 // Include inline implementations
00155 #include "TensorI.H"
00156 
00157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00158 
00159 #endif
00160 
00161 // ************************************************************************* //
For further information go to www.openfoam.org