DiagTensor.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) 2011-2022 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::DiagTensor
26 
27 Description
28  Templated 3D DiagTensor derived from VectorSpace.
29 
30  Adding construction from 3 components, element access using xx(), yy()
31  and zz() member functions and the inner-product (dot-product) and
32  outer-product operators.
33 
34 SourceFiles
35  DiagTensorI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef DiagTensor_H
40 #define DiagTensor_H
41 
42 #include "Tensor.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class DiagTensor Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Cmpt>
54 class DiagTensor
55 :
56  public VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>
57 {
58 
59 public:
60 
61  //- Equivalent type of labels used for valid component indexing
63 
64 
65  // Member constants
66 
67  //- Rank of DiagTensor is 2
68  static const direction rank = 2;
69 
70 
71  //- Component labeling enumeration
72  enum components { XX, YY, ZZ };
73 
74 
75  // Constructors
76 
77  //- Construct null
78  inline DiagTensor();
79 
80  //- Construct initialised to zero
81  inline DiagTensor(const Foam::zero);
82 
83  //- Construct given VectorSpace
84  template<class Cmpt2>
85  inline DiagTensor(const VectorSpace<DiagTensor<Cmpt2>, Cmpt2, 3>&);
86 
87  //- Construct given three components
88  inline DiagTensor(const Cmpt& txx, const Cmpt& tyy, const Cmpt& tzz);
89 
90  //- Construct from Vector
91  inline explicit DiagTensor(const Vector<Cmpt>& v);
92 
93  //- Construct from Istream
94  inline DiagTensor(Istream&);
95 
96 
97  // Member Functions
98 
99  // Access
100 
101  inline const Cmpt& xx() const;
102  inline const Cmpt& yy() const;
103  inline const Cmpt& zz() const;
104 
105  inline Cmpt& xx();
106  inline Cmpt& yy();
107  inline Cmpt& zz();
108 
109  //- Explicit conversion to Vector
110  explicit inline operator Vector<Cmpt>() const;
111 };
112 
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 } // End namespace Foam
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 // Include inline implementations
121 #include "DiagTensorI.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 #endif
126 
127 // ************************************************************************* //
Templated 3D DiagTensor derived from VectorSpace.
Definition: DiagTensor.H:56
const Cmpt & xx() const
Definition: DiagTensorI.H:85
DiagTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: DiagTensor.H:61
DiagTensor()
Construct null.
Definition: DiagTensorI.H:32
static const direction rank
Rank of DiagTensor is 2.
Definition: DiagTensor.H:67
components
Component labeling enumeration.
Definition: DiagTensor.H:71
const Cmpt & zz() const
Definition: DiagTensorI.H:97
const Cmpt & yy() const
Definition: DiagTensorI.H:91
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Templated vector space.
Definition: VectorSpace.H:85
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:60
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:45