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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::SymmTensor
29 
30 Description
31  A templated (3 x 3) symmetric tensor of objects of <T>, effectively
32  containing 6 elements, derived from VectorSpace.
33 
34 See also
35  Test-SymmTensor.C
36 
37 SourceFiles
38  SymmTensorI.H
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef SymmTensor_H
43 #define SymmTensor_H
44 
45 #include "contiguous.H"
46 #include "Vector.H"
47 #include "SphericalTensor.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class SymmTensor Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Cmpt>
59 class SymmTensor
60 :
61  public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
62 {
63 public:
64 
65  // Typedefs
66 
67  //- Equivalent type of labels used for valid component indexing
69 
70 
71  // Member Constants
72 
73  //- Rank of SymmTensor is 2
74  static constexpr direction rank = 2;
75 
76 
77  // Static Data Members
78 
79  static const SymmTensor I;
80 
81 
82  //- Component labeling enumeration
83  enum components { XX, XY, XZ, YY, YZ, ZZ };
84 
85 
86  // Generated Methods
87 
88  //- Default construct
89  SymmTensor() = default;
90 
91  //- Copy construct
92  SymmTensor(const SymmTensor&) = default;
93 
94  //- Copy assignment
95  SymmTensor& operator=(const SymmTensor&) = default;
96 
97 
98  // Constructors
99 
100  //- Construct initialized to zero
101  inline SymmTensor(const Foam::zero);
102 
103  //- Construct given VectorSpace of the same rank
104  template<class Cmpt2>
105  inline SymmTensor(const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>&);
106 
107  //- Construct given SphericalTensor
108  inline SymmTensor(const SphericalTensor<Cmpt>&);
109 
110  //- Construct given the six components
111  inline SymmTensor
112  (
113  const Cmpt txx, const Cmpt txy, const Cmpt txz,
114  const Cmpt tyy, const Cmpt tyz,
115  const Cmpt tzz
116  );
117 
118  //- Construct from Istream
119  inline explicit SymmTensor(Istream& is);
120 
121 
122  // Member Functions
123 
124  // Component access
125 
126  inline const Cmpt& xx() const;
127  inline const Cmpt& xy() const;
128  inline const Cmpt& xz() const;
129  inline const Cmpt& yx() const;
130  inline const Cmpt& yy() const;
131  inline const Cmpt& yz() const;
132  inline const Cmpt& zx() const;
133  inline const Cmpt& zy() const;
134  inline const Cmpt& zz() const;
135 
136  inline Cmpt& xx();
137  inline Cmpt& xy();
138  inline Cmpt& xz();
139  inline Cmpt& yx();
140  inline Cmpt& yy();
141  inline Cmpt& yz();
142  inline Cmpt& zx();
143  inline Cmpt& zy();
144  inline Cmpt& zz();
145 
146 
147  // Diagonal access and manipulation
148 
149  //- Extract the diagonal as a vector
150  inline Vector<Cmpt> diag() const;
151 
152  //- Set values of the diagonal
153  inline void diag(const Vector<Cmpt>& v);
154 
155 
156  // Tensor Operations
157 
158  //- Return non-Hermitian transpose
159  inline const SymmTensor<Cmpt>& T() const;
160 
161 
162  // Member Operators
163 
164  //- Inherit VectorSpace assignment operators
166 
167  //- Assign to given SphericalTensor
168  inline void operator=(const SphericalTensor<Cmpt>&);
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
173 
174 //- Data are contiguous if component type is contiguous
175 template<class Cmpt>
176 struct is_contiguous<SymmTensor<Cmpt>> : is_contiguous<Cmpt> {};
177 
178 //- Data are contiguous label if component type is label
179 template<class Cmpt>
180 struct is_contiguous_label<SymmTensor<Cmpt>> : is_contiguous_label<Cmpt> {};
181 
182 //- Data are contiguous scalar if component type is scalar
183 template<class Cmpt>
184 struct is_contiguous_scalar<SymmTensor<Cmpt>> : is_contiguous_scalar<Cmpt> {};
185 
186 
187 template<class Cmpt>
188 class symmTypeOfRank<Cmpt, 2>
189 {
190 public:
191 
192  typedef SymmTensor<Cmpt> type;
193 };
194 
195 
196 template<class Cmpt>
197 class typeOfSolve<SymmTensor<Cmpt>>
198 {
199 public:
200 
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #include "SymmTensorI.H"
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
Foam::SymmTensor< scalar >::components
components
Component labeling enumeration.
Definition: SymmTensor.H:82
Foam::SymmTensor
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements,...
Definition: SymmTensor.H:58
Foam::SymmTensor::yz
const Cmpt & yz() const
Definition: SymmTensorI.H:114
Foam::SymmTensor::T
const SymmTensor< Cmpt > & T() const
Return non-Hermitian transpose.
Definition: SymmTensorI.H:208
Foam::SymmTensor::xz
const Cmpt & xz() const
Definition: SymmTensorI.H:96
Vector.H
Foam::typeOfSolve
The extended precision type (solveScalar for float)
Definition: products.H:78
Foam::SymmTensor::XX
Definition: SymmTensor.H:82
Foam::SymmTensor::zy
const Cmpt & zy() const
Definition: SymmTensorI.H:126
Foam::SymmTensor::SymmTensor
SymmTensor()=default
Default construct.
Foam::SymmTensor::rank
static constexpr direction rank
Rank of SymmTensor is 2.
Definition: SymmTensor.H:73
Foam::is_contiguous_label
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:83
SphericalTensor.H
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::SymmTensor::YY
Definition: SymmTensor.H:82
Foam::SymmTensor::xx
const Cmpt & xx() const
Definition: SymmTensorI.H:84
Foam::SymmTensor::xy
const Cmpt & xy() const
Definition: SymmTensorI.H:90
Foam::SymmTensor::yx
const Cmpt & yx() const
Definition: SymmTensorI.H:102
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::SymmTensor::I
static const SymmTensor I
Definition: SymmTensor.H:78
Foam::SymmTensor::YZ
Definition: SymmTensor.H:82
Foam::SymmTensor::ZZ
Definition: SymmTensor.H:82
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element,...
Definition: SphericalTensor.H:57
Foam::is_contiguous_scalar
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:91
Foam::symmTypeOfRank
Definition: products.H:72
Foam::SymmTensor::XY
Definition: SymmTensor.H:82
Foam::SymmTensor::labelType
SymmTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: SymmTensor.H:67
Foam::symmTypeOfRank< Cmpt, 2 >::type
SymmTensor< Cmpt > type
Definition: SymmTensor.H:191
Foam::SymmTensor::diag
Vector< Cmpt > diag() const
Extract the diagonal as a vector.
Definition: SymmTensorI.H:194
Foam::SymmTensor::yy
const Cmpt & yy() const
Definition: SymmTensorI.H:108
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
contiguous.H
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::SymmTensor::operator=
SymmTensor & operator=(const SymmTensor &)=default
Copy assignment.
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::SymmTensor::zz
const Cmpt & zz() const
Definition: SymmTensorI.H:132
Foam::typeOfSolve::type
Type type
Definition: products.H:82
Foam::SymmTensor::XZ
Definition: SymmTensor.H:82
Foam::SymmTensor::zx
const Cmpt & zx() const
Definition: SymmTensorI.H:120
Foam::typeOfSolve< SymmTensor< Cmpt > >::type
SymmTensor< solveScalar > type
Definition: SymmTensor.H:200
Foam::VectorSpace::operator
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
Foam::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
SymmTensorI.H