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

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-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 Class
00025     Foam::Tensor
00026 
00027 Description
00028     Templated 3D tensor derived from VectorSpace adding construction from
00029     9 components, element access using xx(), xy() etc. member functions and
00030     the inner-product (dot-product) and outer-product of two Vectors
00031     (tensor-product) operators.
00032 
00033 SourceFiles
00034     TensorI.H
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef Tensor_H
00039 #define Tensor_H
00040 
00041 #include <OpenFOAM/Vector_.H>
00042 #include <OpenFOAM/SphericalTensor_.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 template<class Cmpt>
00050 class SymmTensor;
00051 
00052 /*---------------------------------------------------------------------------*\
00053                            Class Tensor Declaration
00054 \*---------------------------------------------------------------------------*/
00055 
00056 template <class Cmpt>
00057 class Tensor
00058 :
00059     public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
00060 {
00061 
00062 public:
00063 
00064     //- Equivalent type of labels used for valid component indexing
00065     typedef Tensor<label> labelType;
00066 
00067 
00068     // Member constants
00069 
00070         enum
00071         {
00072             rank = 2 // Rank of Tensor is 2
00073         };
00074 
00075 
00076     // Static data members
00077 
00078         static const char* const typeName;
00079         static const char* componentNames[];
00080 
00081         static const Tensor zero;
00082         static const Tensor one;
00083         static const Tensor max;
00084         static const Tensor min;
00085 
00086 
00087     //- Component labeling enumeration
00088     enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
00089 
00090 
00091     // Constructors
00092 
00093         //- Construct null
00094         inline Tensor();
00095 
00096         //- Construct given VectorSpace
00097         inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
00098 
00099         //- Construct given SphericalTensor
00100         inline Tensor(const SphericalTensor<Cmpt>&);
00101 
00102         //- Construct given SymmTensor
00103         inline Tensor(const SymmTensor<Cmpt>&);
00104 
00105         //- Construct given the three vectors
00106         inline Tensor
00107         (
00108             const Vector<Cmpt>& x,
00109             const Vector<Cmpt>& y,
00110             const Vector<Cmpt>& z
00111         );
00112 
00113         //- Construct given the nine components
00114         inline Tensor
00115         (
00116             const Cmpt txx, const Cmpt txy, const Cmpt txz,
00117             const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
00118             const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
00119         );
00120 
00121         //- Construct from Istream
00122         Tensor(Istream&);
00123 
00124 
00125     // Member Functions
00126 
00127         // Access
00128 
00129             inline const Cmpt& xx() const;
00130             inline const Cmpt& xy() const;
00131             inline const Cmpt& xz() const;
00132             inline const Cmpt& yx() const;
00133             inline const Cmpt& yy() const;
00134             inline const Cmpt& yz() const;
00135             inline const Cmpt& zx() const;
00136             inline const Cmpt& zy() const;
00137             inline const Cmpt& zz() const;
00138 
00139             inline Cmpt& xx();
00140             inline Cmpt& xy();
00141             inline Cmpt& xz();
00142             inline Cmpt& yx();
00143             inline Cmpt& yy();
00144             inline Cmpt& yz();
00145             inline Cmpt& zx();
00146             inline Cmpt& zy();
00147             inline Cmpt& zz();
00148 
00149             // Access vector components.
00150             // Note: returning const only to find out lhs usage
00151 
00152             inline const Vector<Cmpt> x() const;
00153             inline const Vector<Cmpt> y() const;
00154             inline const Vector<Cmpt> z() const;
00155 
00156         //- Transpose
00157         inline Tensor<Cmpt> T() const;
00158 
00159 
00160     // Member Operators
00161 
00162         //- Assign to a SphericalTensor
00163         inline void operator=(const SphericalTensor<Cmpt>&);
00164 
00165         //- Assign to a SymmTensor
00166         inline void operator=(const SymmTensor<Cmpt>&);
00167 };
00168 
00169 
00170 template<class Cmpt>
00171 class typeOfRank<Cmpt, 2>
00172 {
00173 public:
00174 
00175     typedef Tensor<Cmpt> type;
00176 };
00177 
00178 
00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00180 
00181 } // End namespace Foam
00182 
00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00184 
00185 // Include inline implementations
00186 #include "TensorI_.H"
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 #endif
00191 
00192 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines