initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / Tensor2D / Tensor2D.H
blobf3c5d30e64447e31f588dd1aca56a008e4e96524
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::Tensor2D
28 Description
29     Templated 2D tensor derived from VectorSpace adding construction from
30     4 components, element access using xx(), xy(), yx() and yy() member
31     functions and the iner-product (dot-product) and outer-product of two
32     Vector2Ds (tensor-product) operators.
34 SourceFiles
35     Tensor2DI.H
37 \*---------------------------------------------------------------------------*/
39 #ifndef Tensor2D_H
40 #define Tensor2D_H
42 #include "Vector2D.H"
43 #include "SphericalTensor2D.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                            Class Tensor2D Declaration
52 \*---------------------------------------------------------------------------*/
54 template <class Cmpt>
55 class Tensor2D
57     public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
60 public:
62     // Member constants
64         enum
65         {
66             rank = 2 // Rank of Tensor2D is 2
67         };
70     // Static data members
72         static const char* const typeName;
73         static const char* componentNames[];
75         static const Tensor2D zero;
76         static const Tensor2D one;
77         static const Tensor2D max;
78         static const Tensor2D min;
81     //- Component labeling enumeration
82     enum components { XX, XY, YX, YY };
85     // Constructors
87         //- Construct null
88         inline Tensor2D();
90         //- Construct given VectorSpace
91         inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
93         //- Construct given SphericalTensor2D
94         inline Tensor2D(const SphericalTensor2D<Cmpt>&);
96         //- Construct given the nine components
97         inline Tensor2D
98         (
99             const Cmpt txx, const Cmpt txy,
100             const Cmpt tyx, const Cmpt tyy
101         );
103         //- Construct from Istream
104         Tensor2D(Istream&);
107     // Member Functions
109         // Access
111             inline const Vector2D<Cmpt>& x() const;
112             inline const Vector2D<Cmpt>& y() const;
114             inline Vector2D<Cmpt>& x();
115             inline Vector2D<Cmpt>& y();
117             inline const Cmpt& xx() const;
118             inline const Cmpt& xy() const;
119             inline const Cmpt& yx() const;
120             inline const Cmpt& yy() const;
122             inline Cmpt& xx();
123             inline Cmpt& xy();
124             inline Cmpt& yx();
125             inline Cmpt& yy();
127         //- Transpose
128         inline Tensor2D<Cmpt> T() const;
131     // Member Operators
133         //- Construct given SphericalTensor2D
134         inline void operator=(const SphericalTensor2D<Cmpt>&);
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 } // End namespace Foam
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 // Include inline implementations
145 #include "Tensor2DI.H"
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 #endif
151 // ************************************************************************* //