initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / SymmTensor / SymmTensor.H
blob61087c20d33536bf1798e169829784ef7b9f93ec
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::SymmTensor
28 Description
29     Templated 3D symmetric tensor derived from VectorSpace adding construction
30     from 6 components, element access using xx(), xy() etc. member functions
31     and the inner-product (dot-product) and outer-product of two Vectors
32     (tensor-product) operators.
34 SourceFiles
35     SymmTensorI.H
37 \*---------------------------------------------------------------------------*/
39 #ifndef SymmTensor_H
40 #define SymmTensor_H
42 #include "VectorSpace.H"
43 #include "SphericalTensor.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                            Class SymmTensor Declaration
52 \*---------------------------------------------------------------------------*/
54 template <class Cmpt>
55 class SymmTensor
57     public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
60 public:
62     //- Equivalent type of labels used for valid component indexing
63     typedef SymmTensor<label> labelType;
66     // Member constants
68         enum
69         {
70             rank = 2 // Rank of SymmTensor is 2
71         };
74     // Static data members
76         static const char* const typeName;
77         static const char* componentNames[];
79         static const SymmTensor zero;
80         static const SymmTensor one;
81         static const SymmTensor max;
82         static const SymmTensor min;
85     //- Component labeling enumeration
86     enum components { XX, XY, XZ, YY, YZ, ZZ };
89     // Constructors
91         //- Construct null
92         inline SymmTensor();
94         //- Construct given VectorSpace
95         inline SymmTensor(const VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>&);
97         //- Construct given SphericalTensor
98         inline SymmTensor(const SphericalTensor<Cmpt>&);
100         //- Construct given the six components
101         inline SymmTensor
102         (
103             const Cmpt txx, const Cmpt txy, const Cmpt txz,
104                             const Cmpt tyy, const Cmpt tyz,
105                                             const Cmpt tzz
106         );
108         //- Construct from Istream
109         SymmTensor(Istream&);
112     // Member Functions
114         // Access
116             inline const Cmpt& xx() const;
117             inline const Cmpt& xy() const;
118             inline const Cmpt& xz() const;
119             inline const Cmpt& yy() const;
120             inline const Cmpt& yz() const;
121             inline const Cmpt& zz() const;
123             inline Cmpt& xx();
124             inline Cmpt& xy();
125             inline Cmpt& xz();
126             inline Cmpt& yy();
127             inline Cmpt& yz();
128             inline Cmpt& zz();
130         //- Transpose
131         inline const SymmTensor<Cmpt>& T() const;
134     // Member Operators
136         //- Construct given SphericalTensor
137         inline void operator=(const SphericalTensor<Cmpt>&);
141 template<class Cmpt>
142 class symmTypeOfRank<Cmpt, 2>
144 public:
146     typedef SymmTensor<Cmpt> type;
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 } // End namespace Foam
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 // Include inline implementations
157 #include "SymmTensorI.H"
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 #endif
163 // ************************************************************************* //