VectorI.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) 2011-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>
41 template<class Cmpt2>
43 (
44  const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs
45 )
46 :
47  Vector::vsType(vs)
48 {}
49 
50 
51 template<class Cmpt>
53 (
54  const Cmpt& vx,
55  const Cmpt& vy,
56  const Cmpt& vz
57 )
58 {
59  this->v_[X] = vx;
60  this->v_[Y] = vy;
61  this->v_[Z] = vz;
62 }
63 
64 
65 template<class Cmpt>
67 :
68  Vector::vsType(is)
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
74 template<class Cmpt>
75 inline const Cmpt& Foam::Vector<Cmpt>::x() const
76 {
77  return this->v_[X];
78 }
79 
80 template<class Cmpt>
81 inline const Cmpt& Foam::Vector<Cmpt>::y() const
82 {
83  return this->v_[Y];
84 }
85 
86 template<class Cmpt>
87 inline const Cmpt& Foam::Vector<Cmpt>::z() const
88 {
89  return this->v_[Z];
90 }
91 
92 
93 template<class Cmpt>
94 inline Cmpt& Foam::Vector<Cmpt>::x()
95 {
96  return this->v_[X];
97 }
98 
99 template<class Cmpt>
100 inline Cmpt& Foam::Vector<Cmpt>::y()
101 {
102  return this->v_[Y];
103 }
104 
105 template<class Cmpt>
106 inline Cmpt& Foam::Vector<Cmpt>::z()
107 {
108  return this->v_[Z];
109 }
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
114 template<class Cmpt>
116 (
117  const Foam::List<Vector<Cmpt>>&
118 )const
119 {
120  return *this;
121 }
122 
123 
124 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
125 
126 namespace Foam
127 {
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 //- Dummy innerProduct for scalar to allow the construction of vtables for
132 // virtual member functions involving the inner-products of fields
133 // for which a "NotImplemented" specialization for scalar is provided.
134 template<class Cmpt>
135 class innerProduct<Vector<Cmpt>, scalar>
136 {
137 public:
138 
139  typedef scalar type;
140 };
141 
142 
143 template<class Cmpt>
145 operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
146 {
147  return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
148 }
149 
150 
151 template<class Cmpt>
152 inline Vector<Cmpt> operator^(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
153 {
154  return Vector<Cmpt>
155  (
156  (v1.y()*v2.z() - v1.z()*v2.y()),
157  (v1.z()*v2.x() - v1.x()*v2.z()),
158  (v1.x()*v2.y() - v1.y()*v2.x())
159  );
160 }
161 
162 
163 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
164 
165 template<class Cmpt>
167 {
168  Vector<Cmpt> u(Zero);
169  u[findMin(cmptMag(v))] = 1;
170  return u ^ v;
171 }
172 
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace Foam
177 
178 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
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
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & y() const
Definition: VectorI.H:81
Vector()
Construct null.
Definition: VectorI.H:29
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
Definition: VectorI.H:116
Vector< Cmpt > operator^(const Vector< Cmpt > &v1, const Vector< Cmpt > &v2)
Definition: VectorI.H:152
static const zero Zero
Definition: zero.H:97
const Cmpt & x() const
Definition: VectorI.H:75
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
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Vector< Cmpt > perpendicular(const Vector< Cmpt > &v)
Definition: VectorI.H:166
PtrList< volScalarField > & Y
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
innerProduct< Vector< Cmpt >, Vector< Cmpt > >::type operator &(const Vector< Cmpt > &v1, const Vector< Cmpt > &v2)
Definition: VectorI.H:145
Namespace for OpenFOAM.