SymmTensor.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::SymmTensor
26 
27 Description
28  Templated 3D symmetric tensor derived from VectorSpace adding construction
29  from 6 components, element access using xx(), xy() etc. member functions
30  and the inner-product (dot-product) and outer-product of two Vectors
31  (tensor-product) operators.
32 
33 SourceFiles
34  SymmTensorI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef SymmTensor_H
39 #define SymmTensor_H
40 
41 #include "VectorSpace.H"
42 #include "SphericalTensor.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class SymmTensor Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Cmpt>
54 class SymmTensor
55 :
56  public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
57 {
58 
59 public:
60 
61  //- Equivalent type of labels used for valid component indexing
63 
64 
65  // Member constants
66 
67  enum
68  {
69  rank = 2 // Rank of SymmTensor is 2
70  };
71 
72 
73  // Static data members
74 
75  static const char* const typeName;
76  static const char* componentNames[];
77 
78  static const SymmTensor zero;
79  static const SymmTensor one;
80  static const SymmTensor max;
81  static const SymmTensor min;
82  static const SymmTensor I;
83 
84 
85  //- Component labeling enumeration
86  enum components { XX, XY, XZ, YY, YZ, ZZ };
87 
88 
89  // Constructors
90 
91  //- Construct null
92  inline SymmTensor();
93 
94  //- Construct given VectorSpace of the same rank
95  template<class Cmpt2>
96  inline SymmTensor(const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>&);
97 
98  //- Construct given SphericalTensor
99  inline SymmTensor(const SphericalTensor<Cmpt>&);
100 
101  //- Construct given the six components
102  inline SymmTensor
103  (
104  const Cmpt txx, const Cmpt txy, const Cmpt txz,
105  const Cmpt tyy, const Cmpt tyz,
106  const Cmpt tzz
107  );
108 
109  //- Construct from 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& xz() const;
120  inline const Cmpt& yy() const;
121  inline const Cmpt& yz() const;
122  inline const Cmpt& zz() const;
123 
124  inline Cmpt& xx();
125  inline Cmpt& xy();
126  inline Cmpt& xz();
127  inline Cmpt& yy();
128  inline Cmpt& yz();
129  inline Cmpt& zz();
130 
131  //- Transpose
132  inline const SymmTensor<Cmpt>& T() const;
133 
134 
135  // Member Operators
136 
137  //- Construct given SphericalTensor
138  inline void operator=(const SphericalTensor<Cmpt>&);
139 };
140 
141 
142 template<class Cmpt>
143 class symmTypeOfRank<Cmpt, 2>
144 {
145 public:
147  typedef SymmTensor<Cmpt> type;
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 // Include inline implementations
158 #include "SymmTensorI.H"
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
const SymmTensor< Cmpt > & T() const
Transpose.
Definition: SymmTensorI.H:159
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static const SymmTensor min
Definition: SymmTensor.H:80
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component, element access using th ii() member function and the inner-product (dot-product) and outer-product operators.
components
Component labeling enumeration.
Definition: SymmTensor.H:85
static const SymmTensor zero
Definition: SymmTensor.H:77
const Cmpt & xy() const
Definition: SymmTensorI.H:91
Namespace for OpenFOAM.
const Cmpt & xx() const
Definition: SymmTensorI.H:85
const Cmpt & xz() const
Definition: SymmTensorI.H:97
static const SymmTensor one
Definition: SymmTensor.H:78
SymmTensor()
Construct null.
Definition: SymmTensorI.H:37
static const SymmTensor I
Definition: SymmTensor.H:81
const Cmpt & yy() const
Definition: SymmTensorI.H:103
const Cmpt & yz() const
Definition: SymmTensorI.H:109
const Cmpt & zz() const
Definition: SymmTensorI.H:115
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
static const char *const typeName
Definition: SymmTensor.H:74
Templated vector space.
Definition: VectorSpace.H:52
SymmTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: SymmTensor.H:61
static const char * componentNames[]
Definition: SymmTensor.H:75
void operator=(const SphericalTensor< Cmpt > &)
Construct given SphericalTensor.
Definition: SymmTensorI.H:168
static const SymmTensor max
Definition: SymmTensor.H:79