Identity.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::Identity
26 
27 Description
28  Templated identity and dual space identity tensors derived from
29  SphericalTensor.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef Identity_H
34 #define Identity_H
35 
36 #include "SphericalTensor.H"
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 /*---------------------------------------------------------------------------*\
44  Class Identity Declaration
45 \*---------------------------------------------------------------------------*/
46 
47 template<class Cmpt>
48 class Identity
49 :
50  public SphericalTensor<Cmpt>
51 {
52 
53 public:
54 
55  //- Construct initialising the SphericalTensor to 1
56  Identity()
57  :
58  SphericalTensor<Cmpt>(1)
59  {}
60 
61  //- The identity type in the dual space
62  class dual
63  :
64  public SphericalTensor<Cmpt>
65  {
66  //- Construct initialising the SphericalTensor to 1
67  dual()
68  :
70  {}
71  };
72 
73  //- Return the identity in the dual space
74  inline dual operator*()
75  {
76  return dual();
77  }
78 
79  //- Return 1 for label
80  inline explicit operator label() const
81  {
82  return 1;
83  }
84 
85  //- Return 1 for scalar
86  inline explicit operator scalar() const
87  {
88  return 1;
89  }
90 };
91 
92 
93 // Global Identity tensor
94 static const Identity<scalar> I;
95 
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 } // End namespace Foam
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 #endif
104 
105 // ************************************************************************* //
The identity type in the dual space.
Definition: Identity.H:64
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:50
Identity()
Construct initialising the SphericalTensor to 1.
Definition: Identity.H:55
dual operator*()
Return the identity in the dual space.
Definition: Identity.H:73
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static const Identity< scalar > I
Definition: Identity.H:93