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 -------------------------------------------------------------------------------
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::SymmTensor2D
29 
30 Description
31  A templated (2 x 2) symmetric tensor of objects of <T>, effectively
32  containing 3 elements, derived from VectorSpace.
33 
34 See also
35  Test-SymmTensor2D.C
36 
37 SourceFiles
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 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class SymmTensor2D Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Cmpt>
59 class SymmTensor2D
60 :
61  public VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>
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 SymmTensor2D is 2
74  static constexpr direction rank = 2;
75 
76 
77  // Static Data Members
78 
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
107  inline SymmTensor2D(const SphericalTensor2D<Cmpt>&);
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
161 template<class Cmpt>
162 struct is_contiguous<SymmTensor2D<Cmpt>> : is_contiguous<Cmpt> {};
163 
164 //- Data are contiguous label if component type is label
165 template<class Cmpt>
166 struct is_contiguous_label<SymmTensor2D<Cmpt>> : is_contiguous_label<Cmpt> {};
167 
168 //- Data are contiguous scalar if component type is scalar
169 template<class Cmpt>
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #include "SymmTensor2DI.H"
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************************************************************* //
Foam::SymmTensor2D::XY
Definition: SymmTensor2D.H:82
Foam::SymmTensor2D::rank
static constexpr direction rank
Rank of SymmTensor2D is 2.
Definition: SymmTensor2D.H:73
Foam::SymmTensor2D
A templated (2 x 2) symmetric tensor of objects of <T>, effectively containing 3 elements,...
Definition: SymmTensor2D.H:58
Foam::Vector2D
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:55
Foam::SymmTensor2D::SymmTensor2D
SymmTensor2D()=default
Default construct.
Foam::is_contiguous_label
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:83
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Vector2D.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::SymmTensor2D::I
static const SymmTensor2D I
Definition: SymmTensor2D.H:78
Foam::SymmTensor2D::diag
Vector2D< Cmpt > diag() const
Extract the diagonal as a vector.
Definition: SymmTensor2DI.H:130
Foam::SymmTensor2D::operator=
SymmTensor2D & operator=(const SymmTensor2D &)=default
Copy assignment.
SymmTensor2DI.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SymmTensor2D::labelType
SymmTensor2D< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: SymmTensor2D.H:67
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::SymmTensor2D::T
const SymmTensor2D< Cmpt > & T() const
Return non-Hermitian transpose.
Definition: SymmTensor2DI.H:144
Foam::SymmTensor2D::YY
Definition: SymmTensor2D.H:82
Foam::SymmTensor2D::XX
Definition: SymmTensor2D.H:82
contiguous.H
Foam::SymmTensor2D::yx
const Cmpt & yx() const
Definition: SymmTensor2DI.H:92
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::SymmTensor2D::xx
const Cmpt & xx() const
Definition: SymmTensor2DI.H:80
Foam::SymmTensor2D::yy
const Cmpt & yy() const
Definition: SymmTensor2DI.H:98
Foam::SymmTensor2D::components
components
Component labeling enumeration.
Definition: SymmTensor2D.H:82
Foam::VectorSpace::operator
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
SphericalTensor2D.H
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::SphericalTensor2D
A templated (2 x 2) diagonal tensor of objects of <T>, effectively containing 1 element,...
Definition: SphericalTensor2D.H:57
Foam::SymmTensor2D::xy
const Cmpt & xy() const
Definition: SymmTensor2DI.H:86
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62