All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Vector.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::Vector
26 
27 Description
28  Templated 3D Vector derived from VectorSpace adding construction from
29  3 components, element access using x(), y() and z() member functions and
30  the inner-product (dot-product) and cross product operators.
31 
32  A centre() member function which returns the Vector for which it is called
33  is defined so that point which is a typedef to Vector<scalar> behaves as
34  other shapes in the shape hierarchy.
35 
36 SourceFiles
37  VectorI.H
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Vector_H
42 #define Vector_H
43 
44 #include "VectorSpace.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 template<class T> class List;
52 
53 /*---------------------------------------------------------------------------*\
54  Class Vector Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class Cmpt>
58 class Vector
59 :
60  public VectorSpace<Vector<Cmpt>, Cmpt, 3>
61 {
62 
63 public:
64 
65  //- Equivalent type of labels used for valid component indexing
66  typedef Vector<label> labelType;
67 
68 
69  // Member constants
70 
71  //- Rank of Vector is 1
72  static const direction rank = 1;
73 
74 
75  //- Component labeling enumeration
76  enum components { X, Y, Z };
77 
78 
79  // Constructors
80 
81  //- Construct null
82  inline Vector();
83 
84  //- Construct initialized to zero
85  inline Vector(const Foam::zero);
86 
87  //- Construct given VectorSpace of the same rank
88  template<class Cmpt2>
89  inline Vector(const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>&);
90 
91  //- Construct given three components
92  inline Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz);
93 
94  //- Construct from Istream
95  inline Vector(Istream&);
96 
97 
98  // Member Functions
99 
100  // Access
101 
102  inline const Cmpt& x() const;
103  inline const Cmpt& y() const;
104  inline const Cmpt& z() const;
105 
106  inline Cmpt& x();
107  inline Cmpt& y();
108  inline Cmpt& z();
109 
110  //- Return *this (used for point which is a typedef to Vector<scalar>.
111  inline const Vector<Cmpt>& centre
112  (
113  const Foam::List<Vector<Cmpt>>&
114  ) const;
115 };
116 
117 
118 template<class Cmpt>
119 class typeOfRank<Cmpt, 1>
120 {
121 public:
123  typedef Vector<Cmpt> type;
124 };
125 
126 
127 template<class Cmpt>
128 class symmTypeOfRank<Cmpt, 1>
129 {
130 public:
132  typedef Vector<Cmpt> type;
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #include "VectorI.H"
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
Vector< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: Vector.H:65
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
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
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & y() const
Definition: VectorI.H:81
Vector()
Construct null.
Definition: VectorI.H:29
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
Definition: VectorI.H:116
const Cmpt & x() const
Definition: VectorI.H:75
static const direction rank
Rank of Vector is 1.
Definition: Vector.H:71
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
components
Component labeling enumeration.
Definition: Vector.H:75
Namespace for OpenFOAM.