FreeFOAM The Cross-Platform CFD Toolkit
Tensor_.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::Tensor
26 
27 Description
28  Templated 3D tensor derived from VectorSpace adding construction from
29  9 components, element access using xx(), xy() etc. member functions and
30  the inner-product (dot-product) and outer-product of two Vectors
31  (tensor-product) operators.
32 
33 SourceFiles
34  TensorI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Tensor_H
39 #define Tensor_H
40 
41 #include <OpenFOAM/Vector_.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 template<class Cmpt>
50 class SymmTensor;
51 
52 /*---------------------------------------------------------------------------*\
53  Class Tensor Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template <class Cmpt>
57 class Tensor
58 :
59  public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
60 {
61 
62 public:
63 
64  //- Equivalent type of labels used for valid component indexing
66 
67 
68  // Member constants
69 
70  enum
71  {
72  rank = 2 // Rank of Tensor is 2
73  };
74 
75 
76  // Static data members
77 
78  static const char* const typeName;
79  static const char* componentNames[];
80 
81  static const Tensor zero;
82  static const Tensor one;
83  static const Tensor max;
84  static const Tensor min;
85 
86 
87  //- Component labeling enumeration
88  enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
89 
90 
91  // Constructors
92 
93  //- Construct null
94  inline Tensor();
95 
96  //- Construct given VectorSpace
97  inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
98 
99  //- Construct given SphericalTensor
100  inline Tensor(const SphericalTensor<Cmpt>&);
101 
102  //- Construct given SymmTensor
103  inline Tensor(const SymmTensor<Cmpt>&);
104 
105  //- Construct given the three vectors
106  inline Tensor
107  (
108  const Vector<Cmpt>& x,
109  const Vector<Cmpt>& y,
110  const Vector<Cmpt>& z
111  );
112 
113  //- Construct given the nine components
114  inline Tensor
115  (
116  const Cmpt txx, const Cmpt txy, const Cmpt txz,
117  const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
118  const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
119  );
120 
121  //- Construct from Istream
122  Tensor(Istream&);
123 
124 
125  // Member Functions
126 
127  // Access
128 
129  inline const Cmpt& xx() const;
130  inline const Cmpt& xy() const;
131  inline const Cmpt& xz() const;
132  inline const Cmpt& yx() const;
133  inline const Cmpt& yy() const;
134  inline const Cmpt& yz() const;
135  inline const Cmpt& zx() const;
136  inline const Cmpt& zy() const;
137  inline const Cmpt& zz() const;
138 
139  inline Cmpt& xx();
140  inline Cmpt& xy();
141  inline Cmpt& xz();
142  inline Cmpt& yx();
143  inline Cmpt& yy();
144  inline Cmpt& yz();
145  inline Cmpt& zx();
146  inline Cmpt& zy();
147  inline Cmpt& zz();
148 
149  // Access vector components.
150  // Note: returning const only to find out lhs usage
151 
152  inline const Vector<Cmpt> x() const;
153  inline const Vector<Cmpt> y() const;
154  inline const Vector<Cmpt> z() const;
155 
156  //- Transpose
157  inline Tensor<Cmpt> T() const;
158 
159 
160  // Member Operators
161 
162  //- Assign to a SphericalTensor
163  inline void operator=(const SphericalTensor<Cmpt>&);
164 
165  //- Assign to a SymmTensor
166  inline void operator=(const SymmTensor<Cmpt>&);
167 };
168 
169 
170 template<class Cmpt>
171 class typeOfRank<Cmpt, 2>
172 {
173 public:
174 
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 // Include inline implementations
186 #include "TensorI_.H"
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************ vim: set sw=4 sts=4 et: ************************ //