Vector2D.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  //- Equivalent type of labels used for valid component indexing
60  typedef Vector2D<label> labelType;
61 
62 
63  // Member constants
64 
65  //- Rank of Vector2D is 1
66  static const direction rank = 1;
67 
68 
69  //- Component labeling enumeration
70  enum components { X, Y };
71 
72 
73  // Constructors
74 
75  //- Construct null
76  inline Vector2D();
77 
78  //- Construct initialized to zero
79  inline Vector2D(const Foam::zero);
80 
81  //- Construct given VectorSpace
82  inline Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>&);
83 
84  //- Construct given two components
85  inline Vector2D(const Cmpt& vx, const Cmpt& vy);
86 
87  //- Construct from Istream
88  inline Vector2D(Istream&);
89 
90 
91  // Member Functions
92 
93  // Access
94 
95  inline const Cmpt& x() const;
96  inline const Cmpt& y() const;
97 
98  inline Cmpt& x();
99  inline Cmpt& y();
100 
101 
102  // Operators
103 
104  //- Perp dot product (dot product with perpendicular vector)
105  inline scalar perp(const Vector2D<Cmpt>& b) const;
106 };
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 // Include inline implementations
116 #include "Vector2DI.H"
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 #endif
121 
122 // ************************************************************************* //
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Templated vector space.
Definition: VectorSpace.H:53
scalar perp(const Vector2D< Cmpt > &b) const
Perp dot product (dot product with perpendicular vector)
Definition: Vector2DI.H:109
const Cmpt & x() const
Definition: Vector2DI.H:68
static const direction rank
Rank of Vector2D is 1.
Definition: Vector2D.H:65
const Cmpt & y() const
Definition: Vector2DI.H:74
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
components
Component labeling enumeration.
Definition: Vector2D.H:69
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
Vector2D()
Construct null.
Definition: Vector2DI.H:29
Templated 2D Vector derived from VectorSpace adding construction from 2 components, element access using x() and y() member functions and the inner-product (dot-product).
Definition: Vector2D.H:51
Vector2D< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: Vector2D.H:59
Namespace for OpenFOAM.