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 -------------------------------------------------------------------------------
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::SpatialVector
29 
30 Description
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 
42 SourceFiles
43  SpatialVectorI.H
44 
45 See 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 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class SpatialVector Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class Cmpt>
66 class SpatialVector
67 :
68  public VectorSpace<SpatialVector<Cmpt>, Cmpt, 6>
69 {
70 
71 public:
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
165 template<class Cmpt>
166 struct is_contiguous<SpatialVector<Cmpt>> : is_contiguous<Cmpt> {};
167 
168 //- Data are contiguous label if component type is label
169 template<class Cmpt>
171 :
172  is_contiguous_label<Cmpt>
173 {};
174 
175 //- Data are contiguous scalar if component type is scalar
176 template<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 // ************************************************************************* //
Foam::SpatialVector::LY
Definition: SpatialVector.H:73
Foam::SpatialVector::WZ
Definition: SpatialVector.H:73
Vector.H
SpatialVectorI.H
Foam::SpatialVector::SpatialVector
SpatialVector()
Construct null.
Definition: SpatialVectorI.H:31
Foam::SpatialVector::lx
const Cmpt & lx() const
Definition: SpatialVectorI.H:126
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::SpatialVector::WY
Definition: SpatialVector.H:73
Foam::SpatialVector::lz
const Cmpt & lz() const
Definition: SpatialVectorI.H:140
Foam::SpatialVector::LZ
Definition: SpatialVector.H:73
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::SpatialVector::dual
Class to represent the dual spatial vector.
Definition: SpatialVector.H:77
Foam::SpatialVector::ly
const Cmpt & ly() const
Definition: SpatialVectorI.H:133
Foam::SpatialVector< scalar >::components
components
Component labeling enumeration.
Definition: SpatialVector.H:73
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::SpatialVector::l
Vector< Cmpt > l() const
Return the linear part of the spatial vector as a vector.
Definition: SpatialVectorI.H:195
Foam::SpatialVector
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
Definition: SpatialVector.H:65
Foam::SpatialVector::wy
const Cmpt & wy() const
Definition: SpatialVectorI.H:112
Foam::SpatialVector::wz
const Cmpt & wz() const
Definition: SpatialVectorI.H:119
Foam::SpatialVector::wx
const Cmpt & wx() const
Definition: SpatialVectorI.H:105
Foam::VectorSpace< SpatialVector< Cmpt >, Cmpt, 6 >::vsType
VectorSpace< SpatialVector< Cmpt >, Cmpt, Ncmpts > vsType
VectorSpace type.
Definition: VectorSpace.H:86
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SpatialVector::dual::v
const SpatialVector & v() const
Return the parent SpatialVector.
Definition: SpatialVectorI.H:202
Foam::is_contiguous_scalar
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:91
Foam::SpatialVector::dual::dual
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
Definition: SpatialVectorI.H:96
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::SpatialVector::LX
Definition: SpatialVector.H:73
Foam::SpatialVector::w
Vector< Cmpt > w() const
Return the angular part of the spatial vector as a vector.
Definition: SpatialVectorI.H:189
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::SpatialVector::operator*
dual operator*() const
Return the dual spatial vector.
Definition: SpatialVectorI.H:212
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
Foam::SpatialVector::WX
Definition: SpatialVector.H:73