Loading...
Searching...
No Matches
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-2023 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 Foam_SymmTensor2D_H
43#define Foam_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 };
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
98 // Constructors
99
100 //- Construct initialized to zero
101 inline SymmTensor2D(Foam::zero);
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
111 (
112 const Cmpt txx, const Cmpt txy,
113 const Cmpt tyy
114 );
116 //- Construct from Istream
117 inline explicit SymmTensor2D(Istream& is);
118
119
120 // Member Functions
121
122 // Component Access
123
124 const Cmpt& xx() const noexcept { return this->v_[XX]; }
125 const Cmpt& xy() const noexcept { return this->v_[XY]; }
126 const Cmpt& yx() const noexcept { return this->v_[XY]; }
127 const Cmpt& yy() const noexcept { return this->v_[YY]; }
128
129 Cmpt& xx() noexcept { return this->v_[XX]; }
130 Cmpt& xy() noexcept { return this->v_[XY]; }
131 Cmpt& yx() noexcept { return this->v_[XY]; }
132 Cmpt& yy() noexcept { return this->v_[YY]; }
133
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);
143 //- The L2-norm squared of the diagonal
144 inline scalar diagSqr() const;
145
147 // Tensor Operations
149 //- Return non-Hermitian transpose
150 const SymmTensor2D<Cmpt>& T() const noexcept { return *this; }
151
152 //- The determinate
153 inline Cmpt det() const;
154
155 //- Return adjunct matrix (transpose of cofactor matrix)
156 inline SymmTensor2D<Cmpt> adjunct() const;
158 //- Return cofactor matrix (transpose of adjunct matrix)
159 inline SymmTensor2D<Cmpt> cof() const;
160
161 //- Return inverse
162 inline SymmTensor2D<Cmpt> inv() const;
163
164
165 // Member Operators
166
167 //- Inherit VectorSpace assignment operators
169
170 //- Construct given SphericalTensor2D
171 inline void operator=(const SphericalTensor2D<Cmpt>&);
172};
173
174
175// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
176
177//- Data are contiguous if component type is contiguous
178template<class Cmpt>
179struct is_contiguous<SymmTensor2D<Cmpt>> : is_contiguous<Cmpt> {};
181//- Data are contiguous label if component type is label
182template<class Cmpt>
184
185//- Data are contiguous scalar if component type is scalar
186template<class Cmpt>
188
189
190// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191
192} // End namespace Foam
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196#include "SymmTensor2DI.H"
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200#endif
201
202// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
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,...
SymmTensor2D< Cmpt > cof() const
Return cofactor matrix (transpose of adjunct matrix).
Cmpt & xy() noexcept
scalar diagSqr() const
The L2-norm squared of the diagonal.
SymmTensor2D(const SymmTensor2D &)=default
Copy construct.
const Cmpt & yy() const noexcept
SymmTensor2D< Cmpt > adjunct() const
Return adjunct matrix (transpose of cofactor matrix).
components
Component labeling enumeration.
SymmTensor2D(const SphericalTensor2D< Cmpt > &)
Construct given SphericalTensor.
SymmTensor2D(const Cmpt txx, const Cmpt txy, const Cmpt tyy)
Construct given the three components.
const SymmTensor2D< Cmpt > & T() const noexcept
Return non-Hermitian transpose.
static constexpr direction rank
SymmTensor2D(Istream &is)
Construct from Istream.
const Cmpt & yx() const noexcept
Cmpt & xx() noexcept
static const SymmTensor2D I
SymmTensor2D & operator=(const SymmTensor2D &)=default
Copy assignment.
Cmpt det() const
The determinate.
SymmTensor2D(Foam::zero)
Construct initialized to zero.
void diag(const Vector2D< Cmpt > &v)
Set values of the diagonal.
Cmpt & yx() noexcept
SymmTensor2D< Cmpt > inv() const
Return inverse.
const Cmpt & xx() const noexcept
void operator=(const SphericalTensor2D< Cmpt > &)
Construct given SphericalTensor2D.
SymmTensor2D< label > labelType
Vector2D< Cmpt > diag() const
Extract the diagonal as a vector.
SymmTensor2D(const VectorSpace< SymmTensor2D< Cmpt >, Cmpt, 3 > &)
Construct given VectorSpace.
const Cmpt & xy() const noexcept
Cmpt & yy() noexcept
SymmTensor2D()=default
Default construct.
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition Vector2D.H:54
Cmpt v_[Ncmpts]
The components of this vector space.
Definition VectorSpace.H:81
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:58
Namespace for OpenFOAM.
uint8_t direction
Definition direction.H:49
const direction noexcept
Definition scalarImpl.H:265
A template class to specify if a data type is composed solely of Foam::label elements.
Definition contiguous.H:82
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition contiguous.H:87
A template class to specify that a data type can be considered as being contiguous in memory.
Definition contiguous.H:70