SpatialVector.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-------------------------------------------------------------------------------
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::SpatialVector
29
30Description
31 Templated 3D spatial vector derived from VectorSpace used to represent the
32 anglular and linear components of position, velocity and acceleration of
33 rigid bodies.
34
35 Reference:
36 \verbatim
37 Featherstone, R. (2008).
38 Rigid body dynamics algorithms.
39 Springer.
40 \endverbatim
41
42SourceFiles
43 SpatialVectorI.H
44
45See also
46 Foam::VectorSpace
47 Foam::Vector
48
49\*---------------------------------------------------------------------------*/
50
51#ifndef SpatialVector_H
52#define SpatialVector_H
53
54#include "Vector.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61/*---------------------------------------------------------------------------*\
62 Class SpatialVector Declaration
63\*---------------------------------------------------------------------------*/
64
65template<class Cmpt>
66class SpatialVector
67:
68 public VectorSpace<SpatialVector<Cmpt>, Cmpt, 6>
69{
70
71public:
72
73 //- Component labeling enumeration
74 enum components { WX, WY, WZ, LX, LY, LZ };
75
76
77 //- Class to represent the dual spatial vector
78 class dual
79 {
80 const SpatialVector& v_;
81
82 public:
83
84 //- Construct the dual of the given SpatialVector
85 inline dual(const SpatialVector& v);
86
87 //- Return the parent SpatialVector
88 inline const SpatialVector& v() const;
89 };
90
91
92 // Constructors
93
94 //- Construct null
95 inline SpatialVector();
96
97 //- Construct initialized to zero
98 inline SpatialVector(const Foam::zero);
99
100 //- Construct given VectorSpace of the same rank
101 inline SpatialVector(const typename SpatialVector::vsType&);
102
103 //- Construct from the angular and linear vector components
104 inline SpatialVector
105 (
106 const Vector<Cmpt>& w,
107 const Vector<Cmpt>& l
108 );
109
110 //- Construct given 6 components
111 inline SpatialVector
112 (
113 const Cmpt& wx,
114 const Cmpt& wy,
115 const Cmpt& wz,
116 const Cmpt& lx,
117 const Cmpt& ly,
118 const Cmpt& lz
119 );
120
121 //- Construct from Istream
122 inline SpatialVector(Istream&);
123
124
125 // Member Functions
126
127 // Component access
128
129 inline const Cmpt& wx() const;
130 inline const Cmpt& wy() const;
131 inline const Cmpt& wz() const;
132
133 inline const Cmpt& lx() const;
134 inline const Cmpt& ly() const;
135 inline const Cmpt& lz() const;
136
137 inline Cmpt& wx();
138 inline Cmpt& wy();
139 inline Cmpt& wz();
140
141 inline Cmpt& lx();
142 inline Cmpt& ly();
143 inline Cmpt& lz();
144
145
146 // Sub-vector access.
147
148 //- Return the angular part of the spatial vector as a vector
149 inline Vector<Cmpt> w() const;
150
151 //- Return the linear part of the spatial vector as a vector
152 inline Vector<Cmpt> l() const;
153
154
155 // Member Operators
156
157 //- Return the dual spatial vector
158 inline dual operator*() const;
159};
160
161
162// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
163
164//- Data are contiguous if component type is contiguous
165template<class Cmpt>
166struct is_contiguous<SpatialVector<Cmpt>> : is_contiguous<Cmpt> {};
167
168//- Data are contiguous label if component type is label
169template<class Cmpt>
171:
173{};
174
175//- Data are contiguous scalar if component type is scalar
176template<class Cmpt>
178:
180{};
181
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185} // End namespace Foam
186
187// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188
189// Include inline implementations
190#include "SpatialVectorI.H"
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194#endif
195
196// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Class to represent the dual spatial vector.
Definition: SpatialVector.H:78
const SpatialVector & v() const
Return the parent SpatialVector.
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
Definition: SpatialVector.H:68
dual operator*() const
Return the dual spatial vector.
Vector< Cmpt > w() const
Return the angular part of the spatial vector as a vector.
components
Component labeling enumeration.
Definition: SpatialVector.H:73
const Cmpt & wy() const
const Cmpt & lx() const
Vector< Cmpt > l() const
Return the linear part of the spatial vector as a vector.
SpatialVector()
Construct null.
const Cmpt & wx() const
const Cmpt & lz() const
const Cmpt & ly() const
const Cmpt & wz() const
Templated vector space.
Definition: VectorSpace.H:79
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:65
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.
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