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 :
34 {}
35 
36 
37 template<class Cmpt>
39 (
40  const typename SpatialVector::vsType& vs
41 )
42 :
44 {}
45 
46 
47 template<class Cmpt>
49 (
50  const Vector<Cmpt>& w,
51  const Vector<Cmpt>& l
52 )
53 {
54  this->v_[WX] = w.x();
55  this->v_[WY] = w.y();
56  this->v_[WZ] = w.z();
57  this->v_[LX] = l.x();
58  this->v_[LY] = l.y();
59  this->v_[LZ] = l.z();
60 }
61 
62 
63 template<class Cmpt>
65 (
66  const Cmpt& v0,
67  const Cmpt& v1,
68  const Cmpt& v2,
69  const Cmpt& v3,
70  const Cmpt& v4,
71  const Cmpt& v5
72 )
73 {
74  this->v_[WX] = v0;
75  this->v_[WY] = v1;
76  this->v_[WZ] = v2;
77  this->v_[LX] = v3;
78  this->v_[LY] = v4;
79  this->v_[LZ] = v5;
80 }
81 
82 
83 template<class Cmpt>
85 :
87 {}
88 
89 
90 template<class Cmpt>
92 :
93  v_(v)
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 template<class Cmpt>
101 {
102  return Vector<Cmpt>(this->v_[WX], this->v_[WY], this->v_[WZ]);
103 }
104 
105 template<class Cmpt>
107 {
108  return Vector<Cmpt>(this->v_[LX], this->v_[LY], this->v_[LZ]);
109 }
110 
111 
112 template<class Cmpt>
114 {
115  return v_;
116 }
117 
118 
119 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
120 
121 template<class Cmpt>
122 inline typename Foam::SpatialVector<Cmpt>::dual
124 {
125  return dual(*this);
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 namespace Foam
132 {
133 
134 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
135 
136 //- Return the cross-product between two spatial vectors
137 template<class Cmpt>
138 inline SpatialVector<Cmpt> operator^
139 (
140  const SpatialVector<Cmpt>& u,
141  const SpatialVector<Cmpt>& v
142 )
143 {
144  return SpatialVector<Cmpt>
145  (
146  -u.wz()*v.wy() + u.wy()*v.wz(),
147  u.wz()*v.wx() - u.wx()*v.wz(),
148  -u.wy()*v.wx() + u.wx()*v.wy(),
149  -u.lz()*v.wy() + u.ly()*v.wz() - u.wz()*v.ly() + u.wy()*v.lz(),
150  u.lz()*v.wx() - u.lx()*v.wz() + u.wz()*v.lx() - u.wx()*v.lz(),
151  -u.ly()*v.wx() + u.lx()*v.wy() - u.wy()*v.lx() + u.wx()*v.ly()
152  );
153 }
154 
155 
156 //- Return the dual cross-product between two spatial vectors
157 template<class Cmpt>
158 inline SpatialVector<Cmpt> operator^
159 (
160  const SpatialVector<Cmpt>& v,
161  const typename SpatialVector<Cmpt>::dual& df
162 )
163 {
164  const SpatialVector<Cmpt>& f = df.v();
165 
166  return SpatialVector<Cmpt>
167  (
168  -v.wz()*f.wy() + v.wy()*f.wz() - v.lz()*f.ly() + v.ly()*f.lz(),
169  v.wz()*f.wx() - v.wx()*f.wz() + v.lz()*f.lx() - v.lx()*f.lz(),
170  -v.wy()*f.wx() + v.wx()*f.wy() - v.ly()*f.lx() + v.lx()*f.ly(),
171  -v.wz()*f.ly() + v.wy()*f.lz(),
172  v.wz()*f.lx() - v.wx()*f.lz(),
173  -v.wy()*f.lx() + v.wx()*f.ly()
174  );
175 }
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // ************************************************************************* //
const Cmpt & wx() const noexcept
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const Cmpt & wy() const noexcept
Templated vector space.
Definition: VectorSpace.H:52
const Cmpt & y() const noexcept
Access to the vector y component.
Definition: Vector.H:140
const Cmpt & wz() const noexcept
dual operator*() const
Return the dual spatial vector.
Class to represent the dual spatial vector.
Definition: SpatialVector.H:77
const Cmpt & lz() const noexcept
const Cmpt & lx() const noexcept
const SpatialVector & v() const
Return the parent SpatialVector.
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
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:58
SpatialVector()=default
Default construct.
const Cmpt & x() const noexcept
Access to the vector x component.
Definition: Vector.H:135
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
Definition: SpatialVector.H:61
labelList f(nPoints)
Vector< Cmpt > w() const
Return the angular part of the spatial vector as a vector.
const Cmpt & z() const noexcept
Access to the vector z component.
Definition: Vector.H:145
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
const Cmpt & ly() const noexcept
Cmpt v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:81
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127