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 
55 public:
56 
57  //- Construct initializing the SphericalTensor to 1
58  Identity()
59  :
60  SphericalTensor<Cmpt>(1)
61  {}
62 
63  //- The identity type in the dual space
64  class dual
65  :
66  public SphericalTensor<Cmpt>
67  {
68  //- Construct initializing the SphericalTensor to 1
69  dual()
70  :
72  {}
73  };
74 
75  //- Return the identity in the dual space
76  inline dual operator*()
77  {
78  return dual();
79  }
80 
81  //- Return 1 for label
82  inline explicit operator label() const
83  {
84  return 1;
85  }
86 
87  //- Return 1 for scalar
88  inline explicit operator scalar() const
89  {
90  return 1;
91  }
92 };
93 
94 
95 // Global Identity tensor
96 static const Identity<scalar> I;
97 
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 } // End namespace Foam
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 #endif
106 
107 // ************************************************************************* //
Foam::Identity::dual
The identity type in the dual space.
Definition: Identity.H:63
Foam::Identity::Identity
Identity()
Construct initializing the SphericalTensor to 1.
Definition: Identity.H:57
SphericalTensor.H
Foam::Identity
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:49
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element,...
Definition: SphericalTensor.H:57
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95
Foam::Identity::operator*
dual operator*()
Return the identity in the dual space.
Definition: Identity.H:75