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-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::DiagTensor
29
30Description
31 A templated (3 x 3) diagonal tensor of objects of <T>, effectively
32 containing 3 elements, derived from VectorSpace.
33
34See also
35 Test-DiagTensor.C
36
37SourceFiles
38 DiagTensorI.H
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef Foam_DiagTensor_H
43#define Foam_DiagTensor_H
44
45#include "Tensor.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class DiagTensor Declaration
54\*---------------------------------------------------------------------------*/
55
56template<class Cmpt>
57class DiagTensor
58:
59 public VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>
60{
61public:
62
63 // Typedefs
64
65 //- Equivalent type of labels used for valid component indexing
67
68
69 // Member Constants
70
71 //- Rank of DiagTensor is 2
72 static constexpr direction rank = 2;
73
74
75 //- Component labeling enumeration
76 enum components { XX, YY, ZZ };
77
78
79 // Generated Methods
80
81 //- Default construct
82 DiagTensor() = default;
83
84 //- Copy construct
85 DiagTensor(const DiagTensor&) = default;
86
87 //- Copy assignment
88 DiagTensor& operator=(const DiagTensor&) = default;
89
90
91 // Constructors
92
93 //- Construct initialized to zero
94 inline DiagTensor(const Foam::zero);
95
96 //- Construct given VectorSpace
97 template<class Cmpt2>
98 inline DiagTensor(const VectorSpace<DiagTensor<Cmpt2>, Cmpt2, 3>&);
99
100 //- Construct given three components
101 inline DiagTensor(const Cmpt& txx, const Cmpt& tyy, const Cmpt& tzz);
102
103 //- Construct from Istream
104 inline explicit DiagTensor(Istream& is);
105
106
107 // Member Functions
108
109 // Access
110
111 inline const Cmpt& xx() const;
112 inline const Cmpt& yy() const;
113 inline const Cmpt& zz() const;
114
115 inline Cmpt& xx();
116 inline Cmpt& yy();
117 inline Cmpt& zz();
118};
119
120
121// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
122
123//- Data are contiguous if component type is contiguous
124template<class Cmpt>
125struct is_contiguous<DiagTensor<Cmpt>> : is_contiguous<Cmpt> {};
126
127//- Data are contiguous label if component type is label
128template<class Cmpt>
129struct is_contiguous_label<DiagTensor<Cmpt>> : is_contiguous_label<Cmpt> {};
130
131//- Data are contiguous scalar if component type is scalar
132template<class Cmpt>
134
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138} // End namespace Foam
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142#include "DiagTensorI.H"
143
144// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145
146#endif
147
148// ************************************************************************* //
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 3 elements,...
Definition: DiagTensor.H:59
DiagTensor & operator=(const DiagTensor &)=default
Copy assignment.
const Cmpt & xx() const
Definition: DiagTensorI.H:76
DiagTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: DiagTensor.H:65
components
Component labeling enumeration.
Definition: DiagTensor.H:75
DiagTensor()=default
Default construct.
static constexpr direction rank
Rank of DiagTensor is 2.
Definition: DiagTensor.H:71
const Cmpt & zz() const
Definition: DiagTensorI.H:88
const Cmpt & yy() const
Definition: DiagTensorI.H:82
DiagTensor(const DiagTensor &)=default
Copy construct.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Templated vector space.
Definition: VectorSpace.H:79
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:56
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:86
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:94
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:78