initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / primitives / Vector2D / Vector2D.H
blob60d668028eca1d00cc59610ce67be3cd4dd4580a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::Vector2D
28 Description
29     Templated 2D Vector derived from VectorSpace adding construction from
30     2 components, element access using x() and y() member functions and
31     the inner-product (dot-product).
33 SourceFiles
34     Vector2DI.H
36 \*---------------------------------------------------------------------------*/
38 #ifndef Vector2D_H
39 #define Vector2D_H
41 #include "VectorSpace.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                            Class Vector2D Declaration
50 \*---------------------------------------------------------------------------*/
52 template <class Cmpt>
53 class Vector2D
55     public VectorSpace<Vector2D<Cmpt>, Cmpt, 2>
58 public:
60     // Member constants
62         enum
63         {
64             rank = 1 // Rank of Vector2D is 1
65         };
68     // Static data members
70         static const char* const typeName;
71         static const char* componentNames[];
72         static const Vector2D zero;
73         static const Vector2D one;
76     //- Component labeling enumeration
77     enum components { X, Y };
80     // Constructors
82         //- Construct null
83         inline Vector2D();
85         //- Construct given VectorSpace
86         inline Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>&);
88         //- Construct given two components
89         inline Vector2D(const Cmpt& vx, const Cmpt& vy);
91         //- Construct from Istream
92         inline Vector2D(Istream&);
95     // Member Functions
97         // Access
99             inline const Cmpt& x() const;
100             inline const Cmpt& y() const;
102             inline Cmpt& x();
103             inline Cmpt& y();
106         // Operators
108             //- perp dot product (dot product with perpendicular vector)
109             inline scalar perp(const Vector2D<Cmpt>& b) const;
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 } // End namespace Foam
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 // Include inline implementations
120 #include "Vector2DI.H"
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 #endif
126 // ************************************************************************* //