FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 // Construct null
34 template <class Cmpt>
36 {}
37 
38 
39 // Construct given VectorSpace
40 template <class Cmpt>
41 inline Vector<Cmpt>::Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>& vs)
42 :
43  VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs)
44 {}
45 
46 
47 // Construct given three Cmpts
48 template <class Cmpt>
49 inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz)
50 {
51  this->v_[X] = vx;
52  this->v_[Y] = vy;
53  this->v_[Z] = vz;
54 }
55 
56 
57 // Construct from Istream
58 template <class Cmpt>
60 :
61  VectorSpace<Vector<Cmpt>, Cmpt, 3>(is)
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
67 template <class Cmpt>
68 inline const Cmpt& Vector<Cmpt>::x() const
69 {
70  return this->v_[X];
71 }
72 
73 template <class Cmpt>
74 inline const Cmpt& Vector<Cmpt>::y() const
75 {
76  return this->v_[Y];
77 }
78 
79 template <class Cmpt>
80 inline const Cmpt& Vector<Cmpt>::z() const
81 {
82  return this->v_[Z];
83 }
84 
85 
86 template <class Cmpt>
87 inline Cmpt& Vector<Cmpt>::x()
88 {
89  return this->v_[X];
90 }
91 
92 template <class Cmpt>
93 inline Cmpt& Vector<Cmpt>::y()
94 {
95  return this->v_[Y];
96 }
97 
98 template <class Cmpt>
99 inline Cmpt& Vector<Cmpt>::z()
100 {
101  return this->v_[Z];
102 }
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 template <class Cmpt>
109 (
110  const Foam::List<Vector<Cmpt> >&
111 )const
112 {
113  return *this;
114 }
115 
116 
117 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
118 
119 template <class Cmpt>
122 {
123  return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
124 }
125 
126 
127 template <class Cmpt>
129 {
130  return Vector<Cmpt>
131  (
132  (v1.y()*v2.z() - v1.z()*v2.y()),
133  (v1.z()*v2.x() - v1.x()*v2.z()),
134  (v1.x()*v2.y() - v1.y()*v2.x())
135  );
136 }
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 } // End namespace Foam
142 
143 // ************************ vim: set sw=4 sts=4 et: ************************ //