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) 2011-2013 OpenFOAM Foundation
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 "Vector2D.H"
42 #include "SphericalTensor2D.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 template<class Cmpt>
50 class SymmTensor2D;
51 
52 /*---------------------------------------------------------------------------*\
53  Class Tensor2D Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Cmpt>
57 class Tensor2D
58 :
59  public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
60 {
61 
62 public:
63 
64  // Member constants
65 
66  enum
67  {
68  rank = 2 // Rank of Tensor2D is 2
69  };
70 
71 
72  // Static data members
73 
74  static const char* const typeName;
75  static const char* componentNames[];
76 
77  static const Tensor2D zero;
78  static const Tensor2D one;
79  static const Tensor2D max;
80  static const Tensor2D min;
81  static const Tensor2D I;
82 
83 
84  //- Component labeling enumeration
85  enum components { XX, XY, YX, YY };
86 
87 
88  // Constructors
89 
90  //- Construct null
91  inline Tensor2D();
92 
93  //- Construct given VectorSpace
94  inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
95 
96  //- Construct given SymmTensor2D
97  inline Tensor2D(const SymmTensor2D<Cmpt>&);
98 
99  //- Construct given SphericalTensor2D
100  inline Tensor2D(const SphericalTensor2D<Cmpt>&);
101 
102  //- Construct given the two vectors
103  inline Tensor2D
104  (
105  const Vector2D<Cmpt>& x,
106  const Vector2D<Cmpt>& y
107  );
108 
109  //- Construct given the four components
110  inline Tensor2D
111  (
112  const Cmpt txx, const Cmpt txy,
113  const Cmpt tyx, const Cmpt tyy
114  );
115 
116  //- Construct from Istream
117  Tensor2D(Istream&);
118 
119 
120  // Member Functions
121 
122  // Access
123 
124  inline const Cmpt& xx() const;
125  inline const Cmpt& xy() const;
126  inline const Cmpt& yx() const;
127  inline const Cmpt& yy() const;
128 
129  inline Cmpt& xx();
130  inline Cmpt& xy();
131  inline Cmpt& yx();
132  inline Cmpt& yy();
133 
134  // Access vector components.
135 
136  inline Vector2D<Cmpt> x() const;
137  inline Vector2D<Cmpt> y() const;
138 
139  //- Transpose
140  inline Tensor2D<Cmpt> T() const;
141 
142 
143  // Member Operators
144 
145  //- Copy SymmTensor2D
146  inline void operator=(const SymmTensor2D<Cmpt>&);
147 
148  //- Copy SphericalTensor2D
149  inline void operator=(const SphericalTensor2D<Cmpt>&);
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 // Include inline implementations
160 #include "Tensor2DI.H"
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
Foam::Tensor2D::YX
@ YX
Definition: Tensor2D.H:84
Foam::Tensor2D::zero
static const Tensor2D zero
Definition: Tensor2D.H:76
Foam::Tensor2D::T
Tensor2D< Cmpt > T() const
Transpose.
Definition: Tensor2DI.H:158
Foam::Tensor2D::xx
const Cmpt & xx() const
Definition: Tensor2DI.H:108
Foam::SymmTensor2D
Templated 2D symmetric tensor derived from VectorSpace adding construction from 4 components,...
Definition: SymmTensor2D.H:53
Foam::Tensor2D::one
static const Tensor2D one
Definition: Tensor2D.H:77
Foam::Tensor2D::XX
@ XX
Definition: Tensor2D.H:84
Foam::Vector2D
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:51
Foam::Tensor2D
Templated 2D tensor derived from VectorSpace adding construction from 4 components,...
Definition: Tensor2D.H:56
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:52
Foam::Tensor2D::yy
const Cmpt & yy() const
Definition: Tensor2DI.H:126
Foam::Tensor2D::YY
@ YY
Definition: Tensor2D.H:84
Foam::Tensor2D::yx
const Cmpt & yx() const
Definition: Tensor2DI.H:120
Vector2D.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::Tensor2D::max
static const Tensor2D max
Definition: Tensor2D.H:78
Foam::Tensor2D::x
Vector2D< Cmpt > x() const
Definition: Tensor2DI.H:95
Foam::Tensor2D::XY
@ XY
Definition: Tensor2D.H:84
Foam::Tensor2D::y
Vector2D< Cmpt > y() const
Definition: Tensor2DI.H:101
Foam::Tensor2D::rank
@ rank
Definition: Tensor2D.H:67
Foam::Tensor2D::components
components
Component labeling enumeration.
Definition: Tensor2D.H:84
Foam::Tensor2D::Tensor2D
Tensor2D()
Construct null.
Definition: Tensor2DI.H:34
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Tensor2D::min
static const Tensor2D min
Definition: Tensor2D.H:79
Foam::Tensor2D::operator=
void operator=(const SymmTensor2D< Cmpt > &)
Copy SymmTensor2D.
Definition: Tensor2DI.H:171
Foam::Tensor2D::typeName
static const char *const typeName
Definition: Tensor2D.H:73
SphericalTensor2D.H
Foam::Tensor2D::xy
const Cmpt & xy() const
Definition: Tensor2DI.H:114
Foam::SphericalTensor2D
Templated 2D sphericalTensor derived from VectorSpace adding construction from 1 component,...
Definition: SphericalTensor2D.H:51
Foam::Tensor2D::componentNames
static const char * componentNames[]
Definition: Tensor2D.H:74
Tensor2DI.H
Foam::Tensor2D::I
static const Tensor2D I
Definition: Tensor2D.H:80