Loading...
Searching...
No Matches
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:
34{}
35
36
37template<class Cmpt>
39(
40 const typename SpatialVector::vsType& vs
42:
44{}
45
46
47template<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
63template<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
83template<class Cmpt>
88
89
90template<class Cmpt>
92:
93 v_(v)
94{}
95
96
97// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98
99template<class Cmpt>
101{
102 return Vector<Cmpt>(this->v_[WX], this->v_[WY], this->v_[WZ]);
103}
104
105template<class Cmpt>
107{
108 return Vector<Cmpt>(this->v_[LX], this->v_[LY], this->v_[LZ]);
109}
110
111
112template<class Cmpt>
114{
115 return v_;
117
118
119// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
120
121template<class Cmpt>
124{
125 return dual(*this);
126}
127
128
129// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130
131namespace Foam
132{
134// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
135
136//- Return the cross-product between two spatial vectors
137template<class Cmpt>
138inline SpatialVector<Cmpt> operator^
139(
140 const SpatialVector<Cmpt>& u,
141 const SpatialVector<Cmpt>& v
142)
143{
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
156//- Return the dual cross-product between two spatial vectors
157template<class Cmpt>
158inline 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
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// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Class to represent the dual spatial vector.
const SpatialVector & v() const
Return the parent SpatialVector.
dual(const SpatialVector &v)
Construct the dual of the given SpatialVector.
Templated 3D spatial vector derived from VectorSpace used to represent the anglular and linear compon...
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 & lz() const noexcept
const Cmpt & wz() const noexcept
const Cmpt & ly() const noexcept
SpatialVector()=default
Default construct.
Vector< Cmpt > l() const
Return the linear part of the spatial vector as a vector.
const Cmpt & wx() const noexcept
const Cmpt & wy() const noexcept
const Cmpt & lx() const noexcept
VectorSpace< SpatialVector< Cmpt >, Cmpt, Ncmpts > vsType
Definition VectorSpace.H:86
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition Vector.H:61
const Cmpt & x() const noexcept
Access to the vector x component.
Definition Vector.H:135
const Cmpt & z() const noexcept
Access to the vector z component.
Definition Vector.H:145
const Cmpt & y() const noexcept
Access to the vector y component.
Definition Vector.H:140
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
labelList f(nPoints)