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 -------------------------------------------------------------------------------
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  A templated (3 x 3) diagonal tensor of objects of <T>, effectively
32  containing 3 elements, derived from VectorSpace.
33 
34 See also
35  Test-DiagTensor.C
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 public:
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
124 template<class Cmpt>
125 struct is_contiguous<DiagTensor<Cmpt>> : is_contiguous<Cmpt> {};
126 
127 //- Data are contiguous label if component type is label
128 template<class Cmpt>
129 struct is_contiguous_label<DiagTensor<Cmpt>> : is_contiguous_label<Cmpt> {};
130 
131 //- Data are contiguous scalar if component type is scalar
132 template<class Cmpt>
133 struct is_contiguous_scalar<DiagTensor<Cmpt>> : is_contiguous_scalar<Cmpt> {};
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #include "DiagTensorI.H"
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
Foam::DiagTensor
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 3 elements,...
Definition: DiagTensor.H:56
Foam::DiagTensor::XX
Definition: DiagTensor.H:75
Foam::DiagTensor::ZZ
Definition: DiagTensor.H:75
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:75
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:75
Foam::DiagTensor::labelType
DiagTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: DiagTensor.H:65
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:88
Foam::DiagTensor::DiagTensor
DiagTensor()=default
Default construct.
DiagTensorI.H
Foam::DiagTensor::operator=
DiagTensor & operator=(const DiagTensor &)=default
Copy assignment.
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::DiagTensor::yy
const Cmpt & yy() const
Definition: DiagTensorI.H:82
Foam::DiagTensor::xx
const Cmpt & xx() const
Definition: DiagTensorI.H:76
Foam::DiagTensor::rank
static constexpr direction rank
Rank of DiagTensor is 2.
Definition: DiagTensor.H:71
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) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62