FreeFOAM The Cross-Platform CFD Toolkit
Vector2DI_.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>
42 :
43  VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(vs)
44 {}
45 
46 
47 // Construct given three Cmpts
48 template <class Cmpt>
49 inline Vector2D<Cmpt>::Vector2D(const Cmpt& vx, const Cmpt& vy)
50 {
51  this->v_[X] = vx;
52  this->v_[Y] = vy;
53 }
54 
55 
56 // Construct from Istream
57 template <class Cmpt>
59 :
60  VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(is)
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 
66 template <class Cmpt>
67 inline const Cmpt& Vector2D<Cmpt>::x() const
68 {
69  return this->v_[X];
70 }
71 
72 template <class Cmpt>
73 inline const Cmpt& Vector2D<Cmpt>::y() const
74 {
75  return this->v_[Y];
76 }
77 
78 
79 template <class Cmpt>
80 inline Cmpt& Vector2D<Cmpt>::x()
81 {
82  return this->v_[X];
83 }
84 
85 template <class Cmpt>
86 inline Cmpt& Vector2D<Cmpt>::y()
87 {
88  return this->v_[Y];
89 }
90 
91 
92 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
93 
94 template <class Cmpt>
97 {
98  return Cmpt(v1.x()*v2.x() + v1.y()*v2.y());
99 }
100 
101 
102 template <class Cmpt>
103 inline scalar Vector2D<Cmpt>::perp(const Vector2D<Cmpt>& b) const
104 {
105  return x()*b.y()-y()*b.x();
106 }
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // ************************ vim: set sw=4 sts=4 et: ************************ //