VectorI.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 | Copyright (C) 2011-2013 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27 
28 namespace Foam
29 {
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Cmpt>
35 {}
36 
37 
38 template<class Cmpt>
39 template<class Cmpt2>
40 inline Vector<Cmpt>::Vector(const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs)
41 :
42  VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs)
43 {}
44 
45 
46 template<class Cmpt>
47 inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz)
48 {
49  this->v_[X] = vx;
50  this->v_[Y] = vy;
51  this->v_[Z] = vz;
52 }
53 
54 
55 template<class Cmpt>
57 :
58  VectorSpace<Vector<Cmpt>, Cmpt, 3>(is)
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
64 template<class Cmpt>
65 inline const Cmpt& Vector<Cmpt>::x() const
66 {
67  return this->v_[X];
68 }
69 
70 template<class Cmpt>
71 inline const Cmpt& Vector<Cmpt>::y() const
72 {
73  return this->v_[Y];
74 }
75 
76 template<class Cmpt>
77 inline const Cmpt& Vector<Cmpt>::z() const
78 {
79  return this->v_[Z];
80 }
81 
82 
83 template<class Cmpt>
84 inline Cmpt& Vector<Cmpt>::x()
85 {
86  return this->v_[X];
87 }
88 
89 template<class Cmpt>
90 inline Cmpt& Vector<Cmpt>::y()
91 {
92  return this->v_[Y];
93 }
94 
95 template<class Cmpt>
96 inline Cmpt& Vector<Cmpt>::z()
97 {
98  return this->v_[Z];
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
104 template<class Cmpt>
106 (
107  const Foam::List<Vector<Cmpt> >&
108 )const
109 {
110  return *this;
111 }
112 
113 
114 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
115 
116 template<class Cmpt>
118 operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
119 {
120  return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
121 }
122 
123 
124 template<class Cmpt>
125 inline Vector<Cmpt> operator^(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
126 {
127  return Vector<Cmpt>
128  (
129  (v1.y()*v2.z() - v1.z()*v2.y()),
130  (v1.z()*v2.x() - v1.x()*v2.z()),
131  (v1.x()*v2.y() - v1.y()*v2.x())
132  );
133 }
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // ************************************************************************* //
Foam::innerProduct
Definition: products.H:89
Vector::x
C x() const
Definition: Test-Field.H:27
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:52
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Vector::Vector
Vector(const double x, const double y)
Definition: Test-Field.H:47
Foam::Vector::x
const Cmpt & x() const
Definition: VectorI.H:65
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Vector::z
const Cmpt & z() const
Definition: VectorI.H:77
Foam::operator&
innerProduct< Vector< Cmpt >, Vector< Cmpt > >::type operator&(const Vector< Cmpt > &v1, const Vector< Cmpt > &v2)
Definition: VectorI.H:118
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:57
Foam::List
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
Vector::y
C y() const
Definition: Test-Field.H:32
Foam::Vector::y
const Cmpt & y() const
Definition: VectorI.H:71
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Vector
Definition: Test-Field.H:4
Foam::Vector::Vector
Vector()
Construct null.
Definition: VectorI.H:34
Foam::operator^
Vector< Cmpt > operator^(const Vector< Cmpt > &v1, const Vector< Cmpt > &v2)
Definition: VectorI.H:125
Y
PtrList< volScalarField > & Y
Definition: createFields.H:36