SpatialVectorI.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-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29
30template<class Cmpt>
32{}
33
34
35template<class Cmpt>
37:
39{}
40
41
42template<class Cmpt>
44(
45 const typename SpatialVector::vsType& vs
46)
47:
49{}
50
51
52template<class Cmpt>
54(
55 const Vector<Cmpt>& w,
56 const Vector<Cmpt>& l
57)
58{
59 this->v_[0] = w.x();
60 this->v_[1] = w.y();
61 this->v_[2] = w.z();
62 this->v_[3] = l.x();
63 this->v_[4] = l.y();
64 this->v_[5] = l.z();
65}
66
67
68template<class Cmpt>
70(
71 const Cmpt& v0,
72 const Cmpt& v1,
73 const Cmpt& v2,
74 const Cmpt& v3,
75 const Cmpt& v4,
76 const Cmpt& v5
77)
78{
79 this->v_[0] = v0;
80 this->v_[1] = v1;
81 this->v_[2] = v2;
82 this->v_[3] = v3;
83 this->v_[4] = v4;
84 this->v_[5] = v5;
85}
86
88template<class Cmpt>
90:
92{}
93
95template<class Cmpt>
98 v_(v)
99{}
101
102// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104template<class Cmpt>
105inline const Cmpt& Foam::SpatialVector<Cmpt>::wx() const
106{
107 return this->v_[WX];
108}
109
111template<class Cmpt>
112inline const Cmpt& Foam::SpatialVector<Cmpt>::wy() const
113{
114 return this->v_[WY];
115}
116
117
118template<class Cmpt>
119inline const Cmpt& Foam::SpatialVector<Cmpt>::wz() const
120{
121 return this->v_[WZ];
122}
123
124
125template<class Cmpt>
126inline const Cmpt& Foam::SpatialVector<Cmpt>::lx() const
127{
128 return this->v_[LX];
131
132template<class Cmpt>
133inline const Cmpt& Foam::SpatialVector<Cmpt>::ly() const
135 return this->v_[LY];
139template<class Cmpt>
140inline const Cmpt& Foam::SpatialVector<Cmpt>::lz() const
142 return this->v_[LZ];
143}
144
145
146template<class Cmpt>
149 return this->v_[WX];
150}
152
153template<class Cmpt>
155{
156 return this->v_[WY];
158
159
160template<class Cmpt>
162{
163 return this->v_[WZ];
164}
165
166
167template<class Cmpt>
169{
170 return this->v_[LX];
171}
172
173
174template<class Cmpt>
176{
177 return this->v_[LY];
178}
179
180
181template<class Cmpt>
183{
184 return this->v_[LZ];
185}
186
187
188template<class Cmpt>
190{
191 return Vector<Cmpt>(this->v_[0], this->v_[1], this->v_[2]);
192}
193
194template<class Cmpt>
196{
197 return Vector<Cmpt>(this->v_[3], this->v_[4], this->v_[5]);
198}
199
200
201template<class Cmpt>
203{
204 return v_;
205}
206
207
208// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
209
210template<class Cmpt>
213{
214 return dual(*this);
215}
216
217
218// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219
220namespace Foam
221{
222
223// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
224
225//- Return the cross-product between two spatial vectors
226template<class Cmpt>
227inline SpatialVector<Cmpt> operator^
228(
229 const SpatialVector<Cmpt>& u,
230 const SpatialVector<Cmpt>& v
231)
232{
234 (
235 -u.wz()*v.wy() + u.wy()*v.wz(),
236 u.wz()*v.wx() - u.wx()*v.wz(),
237 -u.wy()*v.wx() + u.wx()*v.wy(),
238 -u.lz()*v.wy() + u.ly()*v.wz() - u.wz()*v.ly() + u.wy()*v.lz(),
239 u.lz()*v.wx() - u.lx()*v.wz() + u.wz()*v.lx() - u.wx()*v.lz(),
240 -u.ly()*v.wx() + u.lx()*v.wy() - u.wy()*v.lx() + u.wx()*v.ly()
241 );
242}
243
244
245//- Return the dual cross-product between two spatial vectors
246template<class Cmpt>
247inline SpatialVector<Cmpt> operator^
248(
249 const SpatialVector<Cmpt>& v,
250 const typename SpatialVector<Cmpt>::dual& df
251)
252{
253 const SpatialVector<Cmpt>& f = df.v();
254
256 (
257 -v.wz()*f.wy() + v.wy()*f.wz() - v.lz()*f.ly() + v.ly()*f.lz(),
258 v.wz()*f.wx() - v.wx()*f.wz() + v.lz()*f.lx() - v.lx()*f.lz(),
259 -v.wy()*f.wx() + v.wx()*f.wy() - v.ly()*f.lx() + v.lx()*f.ly(),
260 -v.wz()*f.ly() + v.wy()*f.lz(),
261 v.wz()*f.lx() - v.wx()*f.lz(),
262 -v.wy()*f.lx() + v.wx()*f.ly()
263 );
264}
265
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269} // End namespace Foam
270
271// ************************************************************************* //
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.
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
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Wrapper-class to provide dual functions and operators.
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.
labelList f(nPoints)