SpatialVectorI.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 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 template<class Cmpt>
30 {}
31 
32 
33 template<class Cmpt>
35 :
37 {}
38 
39 
40 template<class Cmpt>
42 (
43  const typename SpatialVector::vsType& vs
44 )
45 :
47 {}
48 
49 
50 template<class Cmpt>
52 (
53  const Vector<Cmpt>& w,
54  const Vector<Cmpt>& l
55 )
56 {
57  this->v_[0] = w.x();
58  this->v_[1] = w.y();
59  this->v_[2] = w.z();
60  this->v_[3] = l.x();
61  this->v_[4] = l.y();
62  this->v_[5] = l.z();
63 }
64 
65 
66 template<class Cmpt>
68 (
69  const Cmpt& v0,
70  const Cmpt& v1,
71  const Cmpt& v2,
72  const Cmpt& v3,
73  const Cmpt& v4,
74  const Cmpt& v5
75 )
76 {
77  this->v_[0] = v0;
78  this->v_[1] = v1;
79  this->v_[2] = v2;
80  this->v_[3] = v3;
81  this->v_[4] = v4;
82  this->v_[5] = v5;
83 }
84 
85 
86 template<class Cmpt>
88 :
90 {}
91 
92 
93 template<class Cmpt>
95 :
96  v_(v)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 template<class Cmpt>
103 inline const Cmpt& Foam::SpatialVector<Cmpt>::wx() const
104 {
105  return this->v_[WX];
106 }
107 
108 
109 template<class Cmpt>
110 inline const Cmpt& Foam::SpatialVector<Cmpt>::wy() const
111 {
112  return this->v_[WY];
113 }
114 
115 
116 template<class Cmpt>
117 inline const Cmpt& Foam::SpatialVector<Cmpt>::wz() const
118 {
119  return this->v_[WZ];
120 }
121 
122 
123 template<class Cmpt>
124 inline const Cmpt& Foam::SpatialVector<Cmpt>::lx() const
125 {
126  return this->v_[LX];
127 }
128 
129 
130 template<class Cmpt>
131 inline const Cmpt& Foam::SpatialVector<Cmpt>::ly() const
132 {
133  return this->v_[LY];
134 }
135 
136 
137 template<class Cmpt>
138 inline const Cmpt& Foam::SpatialVector<Cmpt>::lz() const
139 {
140  return this->v_[LZ];
141 }
142 
143 
144 template<class Cmpt>
146 {
147  return this->v_[WX];
148 }
149 
150 
151 template<class Cmpt>
153 {
154  return this->v_[WY];
155 }
156 
157 
158 template<class Cmpt>
160 {
161  return this->v_[WZ];
162 }
163 
164 
165 template<class Cmpt>
167 {
168  return this->v_[LX];
169 }
170 
171 
172 template<class Cmpt>
174 {
175  return this->v_[LY];
176 }
177 
178 
179 template<class Cmpt>
181 {
182  return this->v_[LZ];
183 }
184 
185 
186 template<class Cmpt>
188 {
189  return Vector<Cmpt>(this->v_[0], this->v_[1], this->v_[2]);
190 }
191 
192 template<class Cmpt>
194 {
195  return Vector<Cmpt>(this->v_[3], this->v_[4], this->v_[5]);
196 }
197 
198 
199 template<class Cmpt>
201 {
202  return v_;
203 }
204 
205 
206 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
207 
208 template<class Cmpt>
209 inline typename Foam::SpatialVector<Cmpt>::dual
211 {
212  return dual(*this);
213 }
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 namespace Foam
219 {
220 
221 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
222 
223 //- Return the cross-product between two spatial vectors
224 template<class Cmpt>
225 inline SpatialVector<Cmpt> operator^
226 (
227  const SpatialVector<Cmpt>& u,
228  const SpatialVector<Cmpt>& v
229 )
230 {
231  return SpatialVector<Cmpt>
232  (
233  -u.wz()*v.wy() + u.wy()*v.wz(),
234  u.wz()*v.wx() - u.wx()*v.wz(),
235  -u.wy()*v.wx() + u.wx()*v.wy(),
236  -u.lz()*v.wy() + u.ly()*v.wz() - u.wz()*v.ly() + u.wy()*v.lz(),
237  u.lz()*v.wx() - u.lx()*v.wz() + u.wz()*v.lx() - u.wx()*v.lz(),
238  -u.ly()*v.wx() + u.lx()*v.wy() - u.wy()*v.lx() + u.wx()*v.ly()
239  );
240 }
241 
242 
243 //- Return the dual cross-product between two spatial vectors
244 template<class Cmpt>
245 inline SpatialVector<Cmpt> operator^
246 (
247  const SpatialVector<Cmpt>& v,
248  const typename SpatialVector<Cmpt>::dual& df
249 )
250 {
251  const SpatialVector<Cmpt>& f = df.v();
252 
253  return SpatialVector<Cmpt>
254  (
255  -v.wz()*f.wy() + v.wy()*f.wz() - v.lz()*f.ly() + v.ly()*f.lz(),
256  v.wz()*f.wx() - v.wx()*f.wz() + v.lz()*f.lx() - v.lx()*f.lz(),
257  -v.wy()*f.wx() + v.wx()*f.wy() - v.ly()*f.lx() + v.lx()*f.ly(),
258  -v.wz()*f.ly() + v.wy()*f.lz(),
259  v.wz()*f.lx() - v.wx()*f.lz(),
260  -v.wy()*f.lx() + v.wx()*f.ly()
261  );
262 }
263 
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 } // End namespace Foam
268 
269 // ************************************************************************* //
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
const Cmpt & z() const
Definition: VectorI.H:87
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 & y() const
Definition: VectorI.H:81
const Cmpt & wz() const
const SpatialVector & v() const
Return the parent SpatialVector.
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
static const zero Zero
Definition: zero.H:97
SpatialVector()
Construct null.
const Cmpt & x() const
Definition: VectorI.H:75
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
labelList f(nPoints)
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