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

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-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     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 inner-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 #include "SphericalTensor.H"
00044 #include "SymmTensor.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 /*---------------------------------------------------------------------------*\
00052                            Class Tensor Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 template <class Cmpt>
00056 class Tensor
00057 :
00058     public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
00059 {
00060 
00061 public:
00062 
00063     //- Equivalent type of labels used for valid component indexing
00064     typedef Tensor<label> labelType;
00065 
00066 
00067     // Member constants
00068 
00069         enum
00070         {
00071             rank = 2 // Rank of Tensor is 2
00072         };
00073 
00074 
00075     // Static data members
00076 
00077         static const char* const typeName;
00078         static const char* componentNames[];
00079 
00080         static const Tensor zero;
00081         static const Tensor one;
00082 
00083 
00084     //- Component labeling enumeration
00085     enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
00086 
00087 
00088     // Constructors
00089 
00090         //- Construct null
00091         inline Tensor();
00092 
00093         //- Construct given VectorSpace
00094         inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
00095 
00096         //- Construct given SphericalTensor
00097         inline Tensor(const SphericalTensor<Cmpt>&);
00098 
00099         //- Construct given SymmTensor
00100         inline Tensor(const SymmTensor<Cmpt>&);
00101 
00102         //- Construct given the nine components
00103         inline Tensor
00104         (
00105             const Cmpt txx, const Cmpt txy, const Cmpt txz,
00106             const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
00107             const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
00108         );
00109 
00110         //- Construct from Istream
00111         Tensor(Istream&);
00112 
00113 
00114     // Member Functions
00115 
00116         // Access
00117 
00118             inline const Vector<Cmpt>& x() const;
00119             inline const Vector<Cmpt>& y() const;
00120             inline const Vector<Cmpt>& z() const;
00121 
00122             inline Vector<Cmpt>& x();
00123             inline Vector<Cmpt>& y();
00124             inline Vector<Cmpt>& z();
00125 
00126             inline const Cmpt& xx() const;
00127             inline const Cmpt& xy() const;
00128             inline const Cmpt& xz() const;
00129             inline const Cmpt& yx() const;
00130             inline const Cmpt& yy() const;
00131             inline const Cmpt& yz() const;
00132             inline const Cmpt& zx() const;
00133             inline const Cmpt& zy() const;
00134             inline const Cmpt& zz() const;
00135 
00136             inline Cmpt& xx();
00137             inline Cmpt& xy();
00138             inline Cmpt& xz();
00139             inline Cmpt& yx();
00140             inline Cmpt& yy();
00141             inline Cmpt& yz();
00142             inline Cmpt& zx();
00143             inline Cmpt& zy();
00144             inline Cmpt& zz();
00145 
00146         //- Transpose
00147         inline Tensor<Cmpt> T() const;
00148 
00149 
00150     // Member Operators
00151 
00152         //- Assign to a SphericalTensor
00153         inline void operator=(const SphericalTensor<Cmpt>&);
00154 
00155         //- Assign to a SymmTensor
00156         inline void operator=(const SymmTensor<Cmpt>&);
00157 };
00158 
00159 
00160 template<class Cmpt>
00161 class typeOfRank<Cmpt, 2>
00162 {
00163 public:
00164 
00165     typedef Tensor<Cmpt> type;
00166 };
00167 
00168 
00169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00170 
00171 } // End namespace Foam
00172 
00173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00174 
00175 // Include inline implementations
00176 #include "TensorI.H"
00177 
00178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00179 
00180 #endif
00181 
00182 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd