FreeFOAM The Cross-Platform CFD Toolkit
Tensor2D_.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::Tensor2D
26 
27 Description
28  Templated 2D tensor derived from VectorSpace adding construction from
29  4 components, element access using xx(), xy(), yx() and yy() member
30  functions and the iner-product (dot-product) and outer-product of two
31  Vector2Ds (tensor-product) operators.
32 
33 SourceFiles
34  Tensor2DI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Tensor2D_H
39 #define Tensor2D_H
40 
41 #include <OpenFOAM/Vector2D_.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class Tensor2D Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template <class Cmpt>
54 class Tensor2D
55 :
56  public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
57 {
58 
59 public:
60 
61  // Member constants
62 
63  enum
64  {
65  rank = 2 // Rank of Tensor2D is 2
66  };
67 
68 
69  // Static data members
70 
71  static const char* const typeName;
72  static const char* componentNames[];
73 
74  static const Tensor2D zero;
75  static const Tensor2D one;
76  static const Tensor2D max;
77  static const Tensor2D min;
78 
79 
80  //- Component labeling enumeration
81  enum components { XX, XY, YX, YY };
82 
83 
84  // Constructors
85 
86  //- Construct null
87  inline Tensor2D();
88 
89  //- Construct given VectorSpace
90  inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
91 
92  //- Construct given SphericalTensor2D
93  inline Tensor2D(const SphericalTensor2D<Cmpt>&);
94 
95  //- Construct given the two vectors
96  inline Tensor2D
97  (
98  const Vector2D<Cmpt>& x,
99  const Vector2D<Cmpt>& y
100  );
101 
102  //- Construct given the four components
103  inline Tensor2D
104  (
105  const Cmpt txx, const Cmpt txy,
106  const Cmpt tyx, const Cmpt tyy
107  );
108 
109  //- Construct from Istream
110  Tensor2D(Istream&);
111 
112 
113  // Member Functions
114 
115  // Access
116 
117  inline const Cmpt& xx() const;
118  inline const Cmpt& xy() const;
119  inline const Cmpt& yx() const;
120  inline const Cmpt& yy() const;
121 
122  inline Cmpt& xx();
123  inline Cmpt& xy();
124  inline Cmpt& yx();
125  inline Cmpt& yy();
126 
127  // Access vector components.
128  // Note: returning const only to find out lhs usage
129 
130  inline const Vector2D<Cmpt> x() const;
131  inline const Vector2D<Cmpt> y() const;
132 
133  //- Transpose
134  inline Tensor2D<Cmpt> T() const;
135 
136 
137  // Member Operators
138 
139  //- Copy SphericalTensor2D
140  inline void operator=(const SphericalTensor2D<Cmpt>&);
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 // Include inline implementations
151 #include "Tensor2DI_.H"
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #endif
156 
157 // ************************ vim: set sw=4 sts=4 et: ************************ //