SpatialVector.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::SpatialVector
26 
27 Description
28  Templated 3D spatial vector derived from VectorSpace used to represent the
29  anglular and linear components of position, velocity and acceleration of
30  rigid bodies.
31 
32  Reference:
33  \verbatim
34  Featherstone, R. (2008).
35  Rigid body dynamics algorithms.
36  Springer.
37  \endverbatim
38 
39 SourceFiles
40  SpatialVectorI.H
41 
42 See also
43  Foam::VectorSpace
44  Foam::Vector
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef SpatialVector_H
49 #define SpatialVector_H
50 
51 #include "Vector.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class SpatialVector Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class Cmpt>
63 class SpatialVector
64 :
65  public VectorSpace<SpatialVector<Cmpt>, Cmpt, 6>
66 {
67 
68 public:
69 
70  //- Component labeling enumeration
71  enum components { WX, WY, WZ, LX, LY, LZ };
72 
73 
74  //- Class to represent the dual spatial vector
75  class dual
76  {
77  const SpatialVector& v_;
78 
79  public:
80 
81  //- Construct the dual of the given SpatialVector
82  inline dual(const SpatialVector& v);
83 
84  //- Return the parent SpatialVector
85  inline const SpatialVector& v() const;
86  };
87 
88 
89  // Constructors
90 
91  //- Construct null
92  inline SpatialVector();
93 
94  //- Construct initialized to zero
95  inline SpatialVector(const Foam::zero);
96 
97  //- Construct given VectorSpace of the same rank
98  inline SpatialVector(const typename SpatialVector::vsType&);
99 
100  //- Construct from the angular and linear vector components
101  inline SpatialVector
102  (
103  const Vector<Cmpt>& w,
104  const Vector<Cmpt>& l
105  );
106 
107  //- Construct given 6 components
108  inline SpatialVector
109  (
110  const Cmpt& wx,
111  const Cmpt& wy,
112  const Cmpt& wz,
113  const Cmpt& lx,
114  const Cmpt& ly,
115  const Cmpt& lz
116  );
117 
118  //- Construct from Istream
119  inline SpatialVector(Istream&);
120 
121 
122  // Member Functions
123 
124  // Component access
125 
126  inline const Cmpt& wx() const;
127  inline const Cmpt& wy() const;
128  inline const Cmpt& wz() const;
129 
130  inline const Cmpt& lx() const;
131  inline const Cmpt& ly() const;
132  inline const Cmpt& lz() const;
133 
134  inline Cmpt& wx();
135  inline Cmpt& wy();
136  inline Cmpt& wz();
137 
138  inline Cmpt& lx();
139  inline Cmpt& ly();
140  inline Cmpt& lz();
141 
142 
143  // Sub-vector access.
144 
145  //- Return the angular part of the spatial vector as a vector
146  inline Vector<Cmpt> w() const;
147 
148  //- Return the linear part of the spatial vector as a vector
149  inline Vector<Cmpt> l() const;
150 
151 
152  // Member Operators
153 
154  //- Return the dual spatial vector
155  inline dual operator*() const;
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 // Include inline implementations
166 #include "SpatialVectorI.H"
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
components
Component labeling enumeration.
Definition: SpatialVector.H:70
const Cmpt & wy() const
const Cmpt & lz() const
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Templated vector space.
Definition: VectorSpace.H:53
dual operator*() const
Return the dual spatial vector.
const Cmpt & lx() const
Class to represent the dual spatial vector.
Definition: SpatialVector.H:74
const Cmpt & wz() const
const SpatialVector & v() const
Return the parent SpatialVector.
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
SpatialVector()
Construct null.
Vector< Cmpt > l() const
Return the linear part of the spatial vector as a vector.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
Definition: SpatialVector.H:62
Vector< Cmpt > w() const
Return the angular part of the spatial vector as a vector.
const Cmpt & ly() const
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
Namespace for OpenFOAM.
const Cmpt & wx() const