initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / Tensor / Tensor.H
blob305829c16de4c91f3684158412b13df49891e26b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::Tensor
28 Description
29     Templated 3D tensor derived from VectorSpace adding construction from
30     9 components, element access using xx(), xy() etc. member functions and
31     the inner-product (dot-product) and outer-product of two Vectors
32     (tensor-product) operators.
34 SourceFiles
35     TensorI.H
37 \*---------------------------------------------------------------------------*/
39 #ifndef Tensor_H
40 #define Tensor_H
42 #include "Vector.H"
43 #include "SphericalTensor.H"
44 #include "SymmTensor.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 /*---------------------------------------------------------------------------*\
52                            Class Tensor Declaration
53 \*---------------------------------------------------------------------------*/
55 template <class Cmpt>
56 class Tensor
58     public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
61 public:
63     //- Equivalent type of labels used for valid component indexing
64     typedef Tensor<label> labelType;
67     // Member constants
69         enum
70         {
71             rank = 2 // Rank of Tensor is 2
72         };
75     // Static data members
77         static const char* const typeName;
78         static const char* componentNames[];
80         static const Tensor zero;
81         static const Tensor one;
82         static const Tensor max;
83         static const Tensor min;
86     //- Component labeling enumeration
87     enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
90     // Constructors
92         //- Construct null
93         inline Tensor();
95         //- Construct given VectorSpace
96         inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
98         //- Construct given SphericalTensor
99         inline Tensor(const SphericalTensor<Cmpt>&);
101         //- Construct given SymmTensor
102         inline Tensor(const SymmTensor<Cmpt>&);
104         //- Construct given the nine components
105         inline Tensor
106         (
107             const Cmpt txx, const Cmpt txy, const Cmpt txz,
108             const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
109             const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
110         );
112         //- Construct from Istream
113         Tensor(Istream&);
116     // Member Functions
118         // Access
120             inline const Vector<Cmpt>& x() const;
121             inline const Vector<Cmpt>& y() const;
122             inline const Vector<Cmpt>& z() const;
124             inline Vector<Cmpt>& x();
125             inline Vector<Cmpt>& y();
126             inline Vector<Cmpt>& z();
128             inline const Cmpt& xx() const;
129             inline const Cmpt& xy() const;
130             inline const Cmpt& xz() const;
131             inline const Cmpt& yx() const;
132             inline const Cmpt& yy() const;
133             inline const Cmpt& yz() const;
134             inline const Cmpt& zx() const;
135             inline const Cmpt& zy() const;
136             inline const Cmpt& zz() const;
138             inline Cmpt& xx();
139             inline Cmpt& xy();
140             inline Cmpt& xz();
141             inline Cmpt& yx();
142             inline Cmpt& yy();
143             inline Cmpt& yz();
144             inline Cmpt& zx();
145             inline Cmpt& zy();
146             inline Cmpt& zz();
148         //- Transpose
149         inline Tensor<Cmpt> T() const;
152     // Member Operators
154         //- Assign to a SphericalTensor
155         inline void operator=(const SphericalTensor<Cmpt>&);
157         //- Assign to a SymmTensor
158         inline void operator=(const SymmTensor<Cmpt>&);
162 template<class Cmpt>
163 class typeOfRank<Cmpt, 2>
165 public:
167     typedef Tensor<Cmpt> type;
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 } // End namespace Foam
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 // Include inline implementations
178 #include "TensorI.H"
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 #endif
184 // ************************************************************************* //