SymmTensor2D.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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::SymmTensor2D
29
30Description
31 A templated (2 x 2) symmetric tensor of objects of <T>, effectively
32 containing 3 elements, derived from VectorSpace.
33
34See also
35 Test-SymmTensor2D.C
36
37SourceFiles
38 SymmTensor2DI.H
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef SymmTensor2D_H
43#define SymmTensor2D_H
44
45#include "contiguous.H"
46#include "Vector2D.H"
47#include "SphericalTensor2D.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54/*---------------------------------------------------------------------------*\
55 Class SymmTensor2D Declaration
56\*---------------------------------------------------------------------------*/
57
58template<class Cmpt>
59class SymmTensor2D
60:
61 public VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>
62{
63public:
64
65 // Typedefs
66
67 //- Equivalent type of labels used for valid component indexing
69
70
71 // Member Constants
72
73 //- Rank of SymmTensor2D is 2
74 static constexpr direction rank = 2;
75
76
77 // Static Data Members
79 static const SymmTensor2D I;
80
81
82 //- Component labeling enumeration
83 enum components { XX, XY, YY };
84
85
86 // Generated Methods
87
88 //- Default construct
89 SymmTensor2D() = default;
90
91 //- Copy construct
92 SymmTensor2D(const SymmTensor2D&) = default;
93
94 //- Copy assignment
95 SymmTensor2D& operator=(const SymmTensor2D&) = default;
96
97
98 // Constructors
99
100 //- Construct initialized to zero
101 inline SymmTensor2D(const Foam::zero);
102
103 //- Construct given VectorSpace
104 inline SymmTensor2D(const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>&);
105
106 //- Construct given SphericalTensor
108
109 //- Construct given the three components
110 inline SymmTensor2D
111 (
112 const Cmpt txx, const Cmpt txy,
113 const Cmpt tyy
114 );
115
116 //- Construct from Istream
117 inline explicit SymmTensor2D(Istream& is);
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
135 // Diagonal access and manipulation
136
137 //- Extract the diagonal as a vector
138 inline Vector2D<Cmpt> diag() const;
139
140 //- Set values of the diagonal
141 inline void diag(const Vector2D<Cmpt>& v);
142
143
144 //- Return non-Hermitian transpose
145 inline const SymmTensor2D<Cmpt>& T() const;
146
147
148 // Member Operators
149
150 //- Inherit VectorSpace assignment operators
152
153 //- Construct given SphericalTensor2D
154 inline void operator=(const SphericalTensor2D<Cmpt>&);
155};
156
157
158// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
159
160//- Data are contiguous if component type is contiguous
161template<class Cmpt>
162struct is_contiguous<SymmTensor2D<Cmpt>> : is_contiguous<Cmpt> {};
163
164//- Data are contiguous label if component type is label
165template<class Cmpt>
167
168//- Data are contiguous scalar if component type is scalar
169template<class Cmpt>
171
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175} // End namespace Foam
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#include "SymmTensor2DI.H"
180
181// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182
183#endif
184
185// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A templated (2 x 2) diagonal tensor of objects of <T>, effectively containing 1 element,...
A templated (2 x 2) symmetric tensor of objects of <T>, effectively containing 3 elements,...
Definition: SymmTensor2D.H:61
SymmTensor2D(const SymmTensor2D &)=default
Copy construct.
const Cmpt & xx() const
Definition: SymmTensor2DI.H:80
const Cmpt & yx() const
Definition: SymmTensor2DI.H:92
components
Component labeling enumeration.
Definition: SymmTensor2D.H:82
static const SymmTensor2D I
Definition: SymmTensor2D.H:78
const SymmTensor2D< Cmpt > & T() const
Return non-Hermitian transpose.
static constexpr direction rank
Rank of SymmTensor2D is 2.
Definition: SymmTensor2D.H:73
SymmTensor2D & operator=(const SymmTensor2D &)=default
Copy assignment.
const Cmpt & xy() const
Definition: SymmTensor2DI.H:86
const Cmpt & yy() const
Definition: SymmTensor2DI.H:98
SymmTensor2D< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: SymmTensor2D.H:67
Vector2D< Cmpt > diag() const
Extract the diagonal as a vector.
SymmTensor2D()=default
Default construct.
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:58
Templated vector space.
Definition: VectorSpace.H:79
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:56
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:86
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:94
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:78