Loading...
Searching...
No Matches
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-2022 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 Foam_SpatialVector_H
52#define Foam_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 //- Default construct
95 SpatialVector() = default;
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
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 explicit SpatialVector(Istream&);
123
125 // Member Functions
126
127 // Component Access
128
129 const Cmpt& wx() const noexcept { return this->v_[WX]; }
130 const Cmpt& wy() const noexcept { return this->v_[WY]; }
131 const Cmpt& wz() const noexcept { return this->v_[WZ]; }
132
133 const Cmpt& lx() const noexcept { return this->v_[LX]; }
134 const Cmpt& ly() const noexcept { return this->v_[LY]; }
135 const Cmpt& lz() const noexcept { return this->v_[LZ]; }
136
137 Cmpt& wx() noexcept { return this->v_[WX]; }
138 Cmpt& wy() noexcept { return this->v_[WY]; }
139 Cmpt& wz() noexcept { return this->v_[WZ]; }
140
141 Cmpt& lx() noexcept { return this->v_[LX]; }
142 Cmpt& ly() noexcept { return this->v_[LY]; }
143 Cmpt& lz() noexcept { return this->v_[LZ]; }
146 // Sub-vector access
147
148 //- Return the angular part of the spatial vector as a vector
149 inline Vector<Cmpt> w() const;
151 //- Return the linear part of the spatial vector as a vector
152 inline Vector<Cmpt> l() const;
155 // Member Operators
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>
167
168//- Data are contiguous label if component type is label
169template<class Cmpt>
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
196// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
const SpatialVector & v() const
Return the parent SpatialVector.
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
dual operator*() const
Return the dual spatial vector.
Vector< scalar > w() const
Cmpt & wz() noexcept
const scalar & lz() const noexcept
SpatialVector(const Cmpt &wx, const Cmpt &wy, const Cmpt &wz, const Cmpt &lx, const Cmpt &ly, const Cmpt &lz)
Construct given 6 components.
SpatialVector(const Vector< Cmpt > &w, const Vector< Cmpt > &l)
Construct from the angular and linear vector components.
components
Component labeling enumeration.
const scalar & wz() const noexcept
SpatialVector(const typename SpatialVector::vsType &)
Construct given VectorSpace of the same rank.
SpatialVector(const Foam::zero)
Construct initialized to zero.
const scalar & ly() const noexcept
SpatialVector()=default
Default construct.
SpatialVector(Istream &)
Construct from Istream.
Vector< scalar > l() const
Cmpt & lx() noexcept
Cmpt & lz() noexcept
Cmpt & ly() noexcept
const scalar & wx() const noexcept
Cmpt & wy() noexcept
Cmpt & wx() noexcept
const scalar & wy() const noexcept
const scalar & lx() const noexcept
VectorSpace< SpatialVector< Cmpt >, Cmpt, Ncmpts > vsType
Definition VectorSpace.H:86
Cmpt v_[Ncmpts]
The components of this vector space.
Definition VectorSpace.H:81
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition Vector.H:61
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265
A template class to specify if a data type is composed solely of Foam::label elements.
Definition contiguous.H:82
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition contiguous.H:87
A template class to specify that a data type can be considered as being contiguous in memory.
Definition contiguous.H:70