initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / Vector2D / Vector2D.H
blob392c5ba70bd147a9a0c5e132d5b1d304b56d3950
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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;
74         static const Vector2D max;
75         static const Vector2D min;
78     //- Component labeling enumeration
79     enum components { X, Y };
82     // Constructors
84         //- Construct null
85         inline Vector2D();
87         //- Construct given VectorSpace
88         inline Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>&);
90         //- Construct given two components
91         inline Vector2D(const Cmpt& vx, const Cmpt& vy);
93         //- Construct from Istream
94         inline Vector2D(Istream&);
97     // Member Functions
99         // Access
101             inline const Cmpt& x() const;
102             inline const Cmpt& y() const;
104             inline Cmpt& x();
105             inline Cmpt& y();
108         // Operators
110             //- perp dot product (dot product with perpendicular vector)
111             inline scalar perp(const Vector2D<Cmpt>& b) const;
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 } // End namespace Foam
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 // Include inline implementations
122 #include "Vector2DI.H"
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 #endif
128 // ************************************************************************* //