Tensor2D.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  //- Equivalent type of labels used for valid component indexing
65  typedef Tensor2D<label> labelType;
66 
67 
68  // Member constants
69 
70  //- Rank of Tensor2D is 2
71  static const direction rank = 2;
72 
73 
74  // Static data members
75 
76  static const Tensor2D I;
77 
78 
79  //- Component labeling enumeration
80  enum components { XX, XY, YX, YY };
81 
82 
83  // Constructors
84 
85  //- Construct null
86  inline Tensor2D();
87 
88  //- Construct initialized to zero
89  inline Tensor2D(const Foam::zero);
90 
91  //- Construct given VectorSpace
92  inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
93 
94  //- Construct given SymmTensor2D
95  inline Tensor2D(const SymmTensor2D<Cmpt>&);
96 
97  //- Construct given SphericalTensor2D
98  inline Tensor2D(const SphericalTensor2D<Cmpt>&);
99 
100  //- Construct given the two vectors
101  inline Tensor2D
102  (
103  const Vector2D<Cmpt>& x,
104  const Vector2D<Cmpt>& y
105  );
106 
107  //- Construct given the four components
108  inline Tensor2D
109  (
110  const Cmpt txx, const Cmpt txy,
111  const Cmpt tyx, const Cmpt tyy
112  );
113 
114  //- Construct from Istream
115  Tensor2D(Istream&);
116 
117 
118  // Member Functions
119 
120  // Access
121 
122  inline const Cmpt& xx() const;
123  inline const Cmpt& xy() const;
124  inline const Cmpt& yx() const;
125  inline const Cmpt& yy() const;
126 
127  inline Cmpt& xx();
128  inline Cmpt& xy();
129  inline Cmpt& yx();
130  inline Cmpt& yy();
131 
132  // Access vector components.
133 
134  inline Vector2D<Cmpt> x() const;
135  inline Vector2D<Cmpt> y() const;
136 
137  //- Transpose
138  inline Tensor2D<Cmpt> T() const;
139 
140 
141  // Member Operators
142 
143  //- Copy SymmTensor2D
144  inline void operator=(const SymmTensor2D<Cmpt>&);
145 
146  //- Copy SphericalTensor2D
147  inline void operator=(const SphericalTensor2D<Cmpt>&);
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 // Include inline implementations
158 #include "Tensor2DI.H"
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
components
Component labeling enumeration.
Definition: Tensor2D.H:79
Tensor2D< Cmpt > T() const
Transpose.
Definition: Tensor2DI.H:163
Vector2D< Cmpt > x() const
Definition: Tensor2DI.H:100
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const Cmpt & xx() const
Definition: Tensor2DI.H:113
Tensor2D()
Construct null.
Definition: Tensor2DI.H:29
Templated vector space.
Definition: VectorSpace.H:53
static const direction rank
Rank of Tensor2D is 2.
Definition: Tensor2D.H:70
void operator=(const SymmTensor2D< Cmpt > &)
Copy SymmTensor2D.
Definition: Tensor2DI.H:176
Vector2D< Cmpt > y() const
Definition: Tensor2DI.H:106
Templated 2D tensor derived from VectorSpace adding construction from 4 components, element access using xx(), xy(), yx() and yy() member functions and the iner-product (dot-product) and outer-product of two Vector2Ds (tensor-product) operators.
Definition: Tensor2D.H:56
const Cmpt & yx() const
Definition: Tensor2DI.H:125
static const Tensor2D I
Definition: Tensor2D.H:75
const Cmpt & yy() const
Definition: Tensor2DI.H:131
Templated 2D sphericalTensor derived from VectorSpace adding construction from 1 component, element access using ii() member function and the inner-product (dot-product) and outer-product operators.
Templated 2D symmetric tensor derived from VectorSpace adding construction from 4 components...
Definition: SymmTensor2D.H:53
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
const Cmpt & xy() const
Definition: Tensor2DI.H:119
Templated 2D Vector derived from VectorSpace adding construction from 2 components, element access using x() and y() member functions and the inner-product (dot-product).
Definition: Vector2D.H:51
Tensor2D< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: Tensor2D.H:64
Namespace for OpenFOAM.