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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
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 
26 Class
27  Foam::Identity
28 
29 Description
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 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class Identity Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class Cmpt>
50 class Identity
51 :
52  public SphericalTensor<Cmpt>
53 {
54 public:
55 
56  //- Construct initializing the SphericalTensor to 1
57  Identity()
58  :
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  :
70  SphericalTensor<Cmpt>(1)
71  {}
72  };
73 
74  //- Return the identity in the dual space
75  dual operator*()
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
95 static const Identity<scalar> I;
96 
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 #endif
105 
106 // ************************************************************************* //
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element, derived from VectorSpace.
Identity()
Construct initializing the SphericalTensor to 1.
Definition: Identity.H:52
static const Identity< scalar > I
Definition: Identity.H:100
const direction noexcept
Definition: Scalar.H:258
The identity type in the dual space.
Definition: Identity.H:60
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:43
dual operator*()
Return the identity in the dual space.
Definition: Identity.H:76
Namespace for OpenFOAM.