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-2016 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  //- Rank of SymmTensor is 2
68  static const direction rank = 2;
69 
70 
71  // Static data members
72 
73  static const SymmTensor I;
74 
75 
76  //- Component labeling enumeration
77  enum components { XX, XY, XZ, YY, YZ, ZZ };
78 
79 
80  // Constructors
81 
82  //- Construct null
83  inline SymmTensor();
84 
85  //- Construct initialized to zero
86  inline SymmTensor(const Foam::zero);
87 
88  //- Construct given VectorSpace of the same rank
89  template<class Cmpt2>
90  inline SymmTensor(const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>&);
91 
92  //- Construct given SphericalTensor
93  inline SymmTensor(const SphericalTensor<Cmpt>&);
94 
95  //- Construct given the six components
96  inline SymmTensor
97  (
98  const Cmpt txx, const Cmpt txy, const Cmpt txz,
99  const Cmpt tyy, const Cmpt tyz,
100  const Cmpt tzz
101  );
102 
103  //- Construct from Istream
105 
106 
107  // Member Functions
108 
109  // Access
110 
111  inline const Cmpt& xx() const;
112  inline const Cmpt& xy() const;
113  inline const Cmpt& xz() const;
114  inline const Cmpt& yy() const;
115  inline const Cmpt& yz() const;
116  inline const Cmpt& zz() const;
117 
118  inline Cmpt& xx();
119  inline Cmpt& xy();
120  inline Cmpt& xz();
121  inline Cmpt& yy();
122  inline Cmpt& yz();
123  inline Cmpt& zz();
124 
125  //- Transpose
126  inline const SymmTensor<Cmpt>& T() const;
127 
128 
129  // Member Operators
130 
131  //- Inherit VectorSpace assignment operators
133 
134  //- Assign to given SphericalTensor
135  inline void operator=(const SphericalTensor<Cmpt>&);
136 };
137 
138 
139 template<class Cmpt>
140 class symmTypeOfRank<Cmpt, 2>
141 {
142 public:
144  typedef SymmTensor<Cmpt> type;
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 // Include inline implementations
155 #include "SymmTensorI.H"
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
const Cmpt & yz() const
Definition: SymmTensorI.H:111
components
Component labeling enumeration.
Definition: SymmTensor.H:76
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
SymmTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: SymmTensor.H:61
static const direction rank
Rank of SymmTensor is 2.
Definition: SymmTensor.H:67
const Cmpt & xx() const
Definition: SymmTensorI.H:87
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
SymmTensor()
Construct null.
Definition: SymmTensorI.H:32
Templated vector space.
Definition: VectorSpace.H:53
void operator=(const SphericalTensor< Cmpt > &)
Assign to given SphericalTensor.
Definition: SymmTensorI.H:170
const Cmpt & yy() const
Definition: SymmTensorI.H:105
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.
const Cmpt & xz() const
Definition: SymmTensorI.H:99
const Cmpt & zz() const
Definition: SymmTensorI.H:117
static const SymmTensor I
Definition: SymmTensor.H:72
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:485
const SymmTensor< Cmpt > & T() const
Transpose.
Definition: SymmTensorI.H:161
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: SymmTensorI.H:93
Namespace for OpenFOAM.