Vector2DI.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-2013 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 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27 
28 namespace Foam
29 {
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 // Construct null
34 template<class Cmpt>
36 {}
37 
38 
39 // Construct given VectorSpace
40 template<class Cmpt>
42 :
43  VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(vs)
44 {}
45 
46 
47 // Construct given three Cmpts
48 template<class Cmpt>
49 inline Vector2D<Cmpt>::Vector2D(const Cmpt& vx, const Cmpt& vy)
50 {
51  this->v_[X] = vx;
52  this->v_[Y] = vy;
53 }
54 
55 
56 // Construct from Istream
57 template<class Cmpt>
59 :
60  VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(is)
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 
66 template<class Cmpt>
67 inline const Cmpt& Vector2D<Cmpt>::x() const
68 {
69  return this->v_[X];
70 }
71 
72 template<class Cmpt>
73 inline const Cmpt& Vector2D<Cmpt>::y() const
74 {
75  return this->v_[Y];
76 }
77 
78 
79 template<class Cmpt>
80 inline Cmpt& Vector2D<Cmpt>::x()
81 {
82  return this->v_[X];
83 }
84 
85 template<class Cmpt>
86 inline Cmpt& Vector2D<Cmpt>::y()
87 {
88  return this->v_[Y];
89 }
90 
91 
92 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
93 
94 template<class Cmpt>
95 inline typename innerProduct<Vector2D<Cmpt>, Vector2D<Cmpt> >::type
97 {
98  return Cmpt(v1.x()*v2.x() + v1.y()*v2.y());
99 }
100 
101 
102 template<class Cmpt>
103 inline scalar Vector2D<Cmpt>::perp(const Vector2D<Cmpt>& b) const
104 {
105  return x()*b.y()-y()*b.x();
106 }
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // ************************************************************************* //
Foam::Vector2D::Vector2D
Vector2D()
Construct null.
Definition: Vector2DI.H:35
Foam::Vector2D
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:51
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:52
Foam::Vector2D::y
const Cmpt & y() const
Definition: Vector2DI.H:73
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::operator&
innerProduct< Vector2D< Cmpt >, Vector2D< Cmpt > >::type operator&(const Vector2D< Cmpt > &v1, const Vector2D< Cmpt > &v2)
Definition: Vector2DI.H:96
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Y
PtrList< volScalarField > & Y
Definition: createFields.H:36
y
scalar y
Definition: LISASMDCalcMethod1.H:14