SpatialTensor.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  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::SpatialTensor
29 
30 Description
31  Templated 3D spatial tensor derived from MatrixSpace used to represent
32  transformations of spatial vectors and the angular and linear inertia of
33  rigid bodies.
34 
35  Reference:
36  \verbatim
37  Featherstone, R. (2008).
38  Rigid body dynamics algorithms.
39  Springer.
40  \endverbatim
41 
42 SourceFiles
43  SpatialTensorI.H
44 
45 See also
46  Foam::MatrixSpace
47  Foam::Tensor
48  Foam::SpatialVector
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef SpatialTensor_H
53 #define SpatialTensor_H
54 
55 #include "Tensor.H"
56 #include "SpatialVector.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class SpatialTensor Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class Cmpt>
68 class SpatialTensor
69 :
70  public MatrixSpace<SpatialTensor<Cmpt>, Cmpt, 6, 6>
71 {
72 
73 public:
74 
75  // Member constants
76 
77  //- Rank of Tensor is 2
78  static constexpr direction rank = 2;
79 
80 
81  // Static data members
82 
83  //- Identity matrix for square matrices
84  static const SpatialTensor I;
85 
86 
87  // Constructors
88 
89  //- Construct null
90  inline SpatialTensor();
91 
92  //- Construct initialized to zero
93  inline SpatialTensor(const Foam::zero);
94 
95  //- Construct given MatrixSpace of the same rank
96  inline SpatialTensor(const typename SpatialTensor::msType&);
97 
98  //- Construct given 4 tensor blocks
99  inline SpatialTensor
100  (
101  const Tensor<Cmpt>& t00, const Tensor<Cmpt>& t01,
102  const Tensor<Cmpt>& t10, const Tensor<Cmpt>& t11
103  );
104 
105  //- Construct given 36 components
106  inline SpatialTensor
107  (
108  const Cmpt& t00, const Cmpt& t01, const Cmpt& t02,
109  const Cmpt& t03, const Cmpt& t04, const Cmpt& t05,
110 
111  const Cmpt& t10, const Cmpt& t11, const Cmpt& t12,
112  const Cmpt& t13, const Cmpt& t14, const Cmpt& t15,
113 
114  const Cmpt& t20, const Cmpt& t21, const Cmpt& t22,
115  const Cmpt& t23, const Cmpt& t24, const Cmpt& t25,
116 
117  const Cmpt& t30, const Cmpt& t31, const Cmpt& t32,
118  const Cmpt& t33, const Cmpt& t34, const Cmpt& t35,
119 
120  const Cmpt& t40, const Cmpt& t41, const Cmpt& t42,
121  const Cmpt& t43, const Cmpt& t44, const Cmpt& t45,
122 
123  const Cmpt& t50, const Cmpt& t51, const Cmpt& t52,
124  const Cmpt& t53, const Cmpt& t54, const Cmpt& t55
125  );
126 
127  //- Construct from Istream
128  inline SpatialTensor(Istream&);
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
133 
134 //- Data are contiguous if component type is contiguous
135 template<class Cmpt>
136 struct is_contiguous<SpatialTensor<Cmpt>> : is_contiguous<Cmpt> {};
137 
138 //- Data are contiguous label if component type is label
139 template<class Cmpt>
141 :
142  is_contiguous_label<Cmpt>
143 {};
144 
145 //- Data are contiguous scalar if component type is scalar
146 template<class Cmpt>
148 :
150 {};
151 
152 
153 template<class Cmpt>
154 class typeOfTranspose<Cmpt, SpatialTensor<Cmpt>>
155 {
156 public:
157 
158  typedef SpatialTensor<Cmpt> type;
159 };
160 
161 
162 template<class Cmpt>
163 class typeOfOuterProduct<Cmpt, SpatialVector<Cmpt>, SpatialVector<Cmpt>>
164 {
165 public:
166 
167  typedef SpatialTensor<Cmpt> type;
168 };
169 
170 
171 template<class Cmpt>
172 class typeOfInnerProduct<Cmpt, SpatialTensor<Cmpt>, SpatialVector<Cmpt>>
173 {
174 public:
175 
176  typedef SpatialVector<Cmpt> type;
177 };
178 
179 
180 template<class Cmpt>
181 class typeOfInnerProduct<Cmpt, SpatialTensor<Cmpt>, SpatialTensor<Cmpt>>
182 {
183 public:
184 
185  typedef SpatialTensor<Cmpt> type;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #include "SpatialTensorI.H"
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
Foam::typeOfInnerProduct< Cmpt, SpatialTensor< Cmpt >, SpatialVector< Cmpt > >::type
SpatialVector< Cmpt > type
Definition: SpatialTensor.H:175
Foam::Tensor
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition: complexI.H:275
Foam::typeOfOuterProduct< Cmpt, SpatialVector< Cmpt >, SpatialVector< Cmpt > >::type
SpatialTensor< Cmpt > type
Definition: SpatialTensor.H:166
Foam::typeOfTranspose< Cmpt, SpatialTensor< Cmpt > >::type
SpatialTensor< Cmpt > type
Definition: SpatialTensor.H:157
Foam::typeOfTranspose
Abstract template class to provide the transpose form of a form.
Definition: products.H:62
Foam::SpatialTensor
Templated 3D spatial tensor derived from MatrixSpace used to represent transformations of spatial vec...
Definition: SpatialTensor.H:67
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::MatrixSpace
Templated matrix space.
Definition: MatrixSpace.H:58
Foam::typeOfInnerProduct< Cmpt, SpatialTensor< Cmpt >, SpatialTensor< Cmpt > >::type
SpatialTensor< Cmpt > type
Definition: SpatialTensor.H:184
Foam::SpatialTensor::SpatialTensor
SpatialTensor()
Construct null.
Definition: SpatialTensorI.H:33
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
SpatialTensorI.H
SpatialVector.H
Foam::SpatialVector
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
Definition: SpatialVector.H:65
Foam::MatrixSpace< SpatialTensor< Cmpt >, Cmpt, 6, 6 >::msType
MatrixSpace< SpatialTensor< Cmpt >, Cmpt, Mrows, Ncols > msType
MatrixSpace type.
Definition: MatrixSpace.H:67
Foam::SpatialTensor::rank
static constexpr direction rank
Rank of Tensor is 2.
Definition: SpatialTensor.H:77
Foam::SpatialTensor::I
static const SpatialTensor I
Identity matrix for square matrices.
Definition: SpatialTensor.H:83
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::typeOfOuterProduct
Definition: products.H:57
Foam::typeOfInnerProduct
Definition: products.H:51
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::direction
uint8_t direction
Definition: direction.H:52
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