The open source CFD toolbox
Identity.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) 2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::Identity
28
29Description
30 Templated identity and dual space identity tensors derived from
31 SphericalTensor.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Identity_H
36#define Identity_H
37
38#include "SphericalTensor.H"
39
40// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42namespace Foam
43{
44
45/*---------------------------------------------------------------------------*\
46 Class Identity Declaration
47\*---------------------------------------------------------------------------*/
48
49template<class Cmpt>
50class Identity
51:
52 public SphericalTensor<Cmpt>
53{
54public:
55
56 //- Construct initializing the SphericalTensor to 1
57 Identity()
58 :
59 SphericalTensor<Cmpt>(1)
60 {}
61
62 //- The identity type in the dual space
63 class dual
64 :
65 public SphericalTensor<Cmpt>
66 {
67 //- Construct initializing the SphericalTensor to 1
68 dual()
69 :
71 {}
72 };
73
74 //- Return the identity in the dual space
76 {
77 return dual();
78 }
79
80 //- Return 1 for label
81 explicit operator label() const noexcept
82 {
83 return 1;
84 }
85
86 //- Return 1 for scalar
87 explicit operator scalar() const noexcept
88 {
89 return 1;
90 }
91};
92
93
94// Global Identity tensor
95static const Identity<scalar> I;
96
97
98// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99
100} // End namespace Foam
101
102// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103
104#endif
105
106// ************************************************************************* //
The identity type in the dual space.
Definition: Identity.H:65
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:52
Identity()
Construct initializing the SphericalTensor to 1.
Definition: Identity.H:56
dual operator*()
Return the identity in the dual space.
Definition: Identity.H:74
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element,...
Namespace for OpenFOAM.
static const Identity< scalar > I
Definition: Identity.H:94
const direction noexcept
Definition: Scalar.H:223