FreeFOAM The Cross-Platform CFD Toolkit
Vector2D_.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 Class
25  Foam::Vector2D
26 
27 Description
28  Templated 2D Vector derived from VectorSpace adding construction from
29  2 components, element access using x() and y() member functions and
30  the inner-product (dot-product).
31 
32 SourceFiles
33  Vector2DI.H
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Vector2D_H
38 #define Vector2D_H
39 
40 #include <OpenFOAM/VectorSpace.H>
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class Vector2D Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 template <class Cmpt>
52 class Vector2D
53 :
54  public VectorSpace<Vector2D<Cmpt>, Cmpt, 2>
55 {
56 
57 public:
58 
59  // Member constants
60 
61  enum
62  {
63  rank = 1 // Rank of Vector2D is 1
64  };
65 
66 
67  // Static data members
68 
69  static const char* const typeName;
70  static const char* componentNames[];
71  static const Vector2D zero;
72  static const Vector2D one;
73  static const Vector2D max;
74  static const Vector2D min;
75 
76 
77  //- Component labeling enumeration
78  enum components { X, Y };
79 
80 
81  // Constructors
82 
83  //- Construct null
84  inline Vector2D();
85 
86  //- Construct given VectorSpace
87  inline Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>&);
88 
89  //- Construct given two components
90  inline Vector2D(const Cmpt& vx, const Cmpt& vy);
91 
92  //- Construct from Istream
93  inline Vector2D(Istream&);
94 
95 
96  // Member Functions
97 
98  // Access
99 
100  inline const Cmpt& x() const;
101  inline const Cmpt& y() const;
102 
103  inline Cmpt& x();
104  inline Cmpt& y();
105 
106 
107  // Operators
108 
109  //- perp dot product (dot product with perpendicular vector)
110  inline scalar perp(const Vector2D<Cmpt>& b) const;
111 };
112 
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 } // End namespace Foam
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 // Include inline implementations
121 #include "Vector2DI_.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 #endif
126 
127 // ************************ vim: set sw=4 sts=4 et: ************************ //