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 -------------------------------------------------------------------------------
10 License
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 
30 template<class Cmpt>
32 {}
33 
34 
35 template<class Cmpt>
37 :
39 {}
40 
41 
42 template<class Cmpt>
44 (
45  const typename SpatialVector::vsType& vs
46 )
47 :
49 {}
50 
51 
52 template<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 
68 template<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 
87 
88 template<class Cmpt>
90 :
92 {}
93 
94 
95 template<class Cmpt>
97 :
98  v_(v)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
104 template<class Cmpt>
105 inline const Cmpt& Foam::SpatialVector<Cmpt>::wx() const
106 {
107  return this->v_[WX];
108 }
109 
110 
111 template<class Cmpt>
112 inline const Cmpt& Foam::SpatialVector<Cmpt>::wy() const
113 {
114  return this->v_[WY];
115 }
116 
117 
118 template<class Cmpt>
119 inline const Cmpt& Foam::SpatialVector<Cmpt>::wz() const
120 {
121  return this->v_[WZ];
122 }
123 
124 
125 template<class Cmpt>
126 inline const Cmpt& Foam::SpatialVector<Cmpt>::lx() const
127 {
128  return this->v_[LX];
129 }
130 
131 
132 template<class Cmpt>
133 inline const Cmpt& Foam::SpatialVector<Cmpt>::ly() const
134 {
135  return this->v_[LY];
136 }
137 
138 
139 template<class Cmpt>
140 inline const Cmpt& Foam::SpatialVector<Cmpt>::lz() const
141 {
142  return this->v_[LZ];
143 }
144 
145 
146 template<class Cmpt>
148 {
149  return this->v_[WX];
150 }
151 
152 
153 template<class Cmpt>
155 {
156  return this->v_[WY];
157 }
158 
159 
160 template<class Cmpt>
162 {
163  return this->v_[WZ];
164 }
165 
166 
167 template<class Cmpt>
169 {
170  return this->v_[LX];
171 }
172 
173 
174 template<class Cmpt>
176 {
177  return this->v_[LY];
178 }
179 
180 
181 template<class Cmpt>
183 {
184  return this->v_[LZ];
185 }
186 
187 
188 template<class Cmpt>
190 {
191  return Vector<Cmpt>(this->v_[0], this->v_[1], this->v_[2]);
192 }
193 
194 template<class Cmpt>
196 {
197  return Vector<Cmpt>(this->v_[3], this->v_[4], this->v_[5]);
198 }
199 
200 
201 template<class Cmpt>
203 {
204  return v_;
205 }
206 
207 
208 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
209 
210 template<class Cmpt>
211 inline typename Foam::SpatialVector<Cmpt>::dual
213 {
214  return dual(*this);
215 }
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 namespace Foam
221 {
222 
223 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
224 
225 //- Return the cross-product between two spatial vectors
226 template<class Cmpt>
227 inline SpatialVector<Cmpt> operator^
228 (
229  const SpatialVector<Cmpt>& u,
230  const SpatialVector<Cmpt>& v
231 )
232 {
233  return SpatialVector<Cmpt>
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
246 template<class Cmpt>
247 inline 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 
255  return SpatialVector<Cmpt>
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 // ************************************************************************* //
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Foam::SpatialVector::LY
Definition: SpatialVector.H:73
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::SpatialVector::WZ
Definition: SpatialVector.H:73
Foam::SpatialVector::SpatialVector
SpatialVector()
Construct null.
Definition: SpatialVectorI.H:31
Foam::SpatialVector::lx
const Cmpt & lx() const
Definition: SpatialVectorI.H:126
Foam::VectorSpace< SpatialVector< Cmpt >, Cmpt, 6 >::v_
Cmpt v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:83
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
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::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
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SpatialVector::dual::v
const SpatialVector & v() const
Return the parent SpatialVector.
Definition: SpatialVectorI.H:202
Foam::SpatialVector::dual::dual
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
Definition: SpatialVectorI.H:96
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
f
labelList f(nPoints)
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::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