DiagTensor.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::DiagTensor
29 
30 Description
31  Templated 3D DiagTensor derived from VectorSpace.
32 
33  Adding construction from 3 components, element access using xx(), yy()
34  and zz() member functions and the inner-product (dot-product) and
35  outer-product operators.
36 
37 SourceFiles
38  DiagTensorI.H
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef DiagTensor_H
43 #define DiagTensor_H
44 
45 #include "Tensor.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class DiagTensor Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Cmpt>
57 class DiagTensor
58 :
59  public VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>
60 {
61 
62 public:
63 
64  //- Equivalent type of labels used for valid component indexing
66 
67 
68  // Member constants
69 
70  //- Rank of DiagTensor is 2
71  static constexpr direction rank = 2;
72 
73 
74  //- Component labeling enumeration
75  enum components { XX, YY, ZZ };
76 
77 
78  // Constructors
79 
80  //- Construct null
81  inline DiagTensor();
82 
83  //- Construct initialized to zero
84  inline DiagTensor(const Foam::zero);
85 
86  //- Construct given VectorSpace
87  template<class Cmpt2>
88  inline DiagTensor(const VectorSpace<DiagTensor<Cmpt2>, Cmpt2, 3>&);
89 
90  //- Construct given three components
91  inline DiagTensor(const Cmpt& txx, const Cmpt& tyy, const Cmpt& tzz);
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 
110 
111 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
112 
113 //- Data are contiguous if component type is contiguous
114 template<class Cmpt>
115 struct is_contiguous<DiagTensor<Cmpt>> : is_contiguous<Cmpt> {};
116 
117 //- Data are contiguous label if component type is label
118 template<class Cmpt>
119 struct is_contiguous_label<DiagTensor<Cmpt>> : is_contiguous_label<Cmpt> {};
120 
121 //- Data are contiguous scalar if component type is scalar
122 template<class Cmpt>
123 struct is_contiguous_scalar<DiagTensor<Cmpt>> : is_contiguous_scalar<Cmpt> {};
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #include "DiagTensorI.H"
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #endif
137 
138 // ************************************************************************* //
Foam::DiagTensor
Templated 3D DiagTensor derived from VectorSpace.
Definition: DiagTensor.H:56
Foam::DiagTensor::DiagTensor
DiagTensor()
Construct null.
Definition: DiagTensorI.H:34
Foam::DiagTensor::XX
Definition: DiagTensor.H:74
Foam::DiagTensor::ZZ
Definition: DiagTensor.H:74
Foam::is_contiguous_label
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:83
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::DiagTensor::YY
Definition: DiagTensor.H:74
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::DiagTensor< scalar >::components
components
Component labeling enumeration.
Definition: DiagTensor.H:74
Foam::DiagTensor::labelType
DiagTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: DiagTensor.H:64
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::is_contiguous_scalar
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:91
Tensor.H
Foam::DiagTensor::zz
const Cmpt & zz() const
Definition: DiagTensorI.H:92
DiagTensorI.H
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::DiagTensor::yy
const Cmpt & yy() const
Definition: DiagTensorI.H:86
Foam::DiagTensor::xx
const Cmpt & xx() const
Definition: DiagTensorI.H:80
Foam::DiagTensor::rank
static constexpr direction rank
Rank of DiagTensor is 2.
Definition: DiagTensor.H:70
Foam::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75
Foam::zero
A class representing the concept of 0 (zero), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61