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) 2011-2015 OpenFOAM Foundation
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 "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 // ************************************************************************* //
VectorSpace.H
Foam::Vector2D::min
static const Vector2D min
Definition: Vector2D.H:73
Foam::Vector2D::Y
@ Y
Definition: Vector2D.H:77
Foam::Vector2D::Vector2D
Vector2D()
Construct null.
Definition: Vector2DI.H:35
Foam::Vector2D< scalar >::components
components
Component labeling enumeration.
Definition: Vector2D.H:77
Foam::Vector2D
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:51
Foam::Vector2D::zero
static const Vector2D zero
Definition: Vector2D.H:70
Foam::Vector2D::rank
@ rank
Definition: Vector2D.H:62
Foam::Vector2D::componentNames
static const char * componentNames[]
Definition: Vector2D.H:69
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:52
Foam::Vector2D::y
const Cmpt & y() const
Definition: Vector2DI.H:73
Foam::Vector2D::X
@ X
Definition: Vector2D.H:77
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::Vector2D::x
const Cmpt & x() const
Definition: Vector2DI.H:67
Foam::Vector2D::one
static const Vector2D one
Definition: Vector2D.H:71
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Vector2D::max
static const Vector2D max
Definition: Vector2D.H:72
Foam::Vector2D::typeName
static const char *const typeName
Definition: Vector2D.H:68
Vector2DI.H
Foam::Vector2D::perp
scalar perp(const Vector2D< Cmpt > &b) const
Perp dot product (dot product with perpendicular vector)
Definition: Vector2DI.H:103