OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-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 Class
00026     Foam::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         static const Tensor max;
00083         static const Tensor min;
00084 
00085 
00086     //- Component labeling enumeration
00087     enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
00088 
00089 
00090     // Constructors
00091 
00092         //- Construct null
00093         inline Tensor();
00094 
00095         //- Construct given VectorSpace
00096         inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
00097 
00098         //- Construct given SphericalTensor
00099         inline Tensor(const SphericalTensor<Cmpt>&);
00100 
00101         //- Construct given SymmTensor
00102         inline Tensor(const SymmTensor<Cmpt>&);
00103 
00104         //- Construct given the nine components
00105         inline Tensor
00106         (
00107             const Cmpt txx, const Cmpt txy, const Cmpt txz,
00108             const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
00109             const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
00110         );
00111 
00112         //- Construct from Istream
00113         Tensor(Istream&);
00114 
00115 
00116     // Member Functions
00117 
00118         // Access
00119 
00120             inline const Vector<Cmpt>& x() const;
00121             inline const Vector<Cmpt>& y() const;
00122             inline const Vector<Cmpt>& z() const;
00123 
00124             inline Vector<Cmpt>& x();
00125             inline Vector<Cmpt>& y();
00126             inline Vector<Cmpt>& z();
00127 
00128             inline const Cmpt& xx() const;
00129             inline const Cmpt& xy() const;
00130             inline const Cmpt& xz() const;
00131             inline const Cmpt& yx() const;
00132             inline const Cmpt& yy() const;
00133             inline const Cmpt& yz() const;
00134             inline const Cmpt& zx() const;
00135             inline const Cmpt& zy() const;
00136             inline const Cmpt& zz() const;
00137 
00138             inline Cmpt& xx();
00139             inline Cmpt& xy();
00140             inline Cmpt& xz();
00141             inline Cmpt& yx();
00142             inline Cmpt& yy();
00143             inline Cmpt& yz();
00144             inline Cmpt& zx();
00145             inline Cmpt& zy();
00146             inline Cmpt& zz();
00147 
00148         //- Transpose
00149         inline Tensor<Cmpt> T() const;
00150 
00151 
00152     // Member Operators
00153 
00154         //- Assign to a SphericalTensor
00155         inline void operator=(const SphericalTensor<Cmpt>&);
00156 
00157         //- Assign to a SymmTensor
00158         inline void operator=(const SymmTensor<Cmpt>&);
00159 };
00160 
00161 
00162 template<class Cmpt>
00163 class typeOfRank<Cmpt, 2>
00164 {
00165 public:
00166 
00167     typedef Tensor<Cmpt> type;
00168 };
00169 
00170 
00171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00172 
00173 } // End namespace Foam
00174 
00175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00176 
00177 // Include inline implementations
00178 #include "TensorI.H"
00179 
00180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00181 
00182 #endif
00183 
00184 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd