OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

Vector.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Vector
00027 
00028 Description
00029     Templated 3D Vector derived from VectorSpace adding construction from
00030     3 components, element access using x(), y() and z() member functions and
00031     the inner-product (dot-product) and cross product operators.
00032 
00033     A centre() member function which returns the Vector for which it is called
00034     is defined so that point which is a typedef to Vector<scalar> behaves as
00035     other shapes in the shape hierachy.
00036 
00037 SourceFiles
00038     VectorI.H
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef Vector_H
00043 #define Vector_H
00044 
00045 #include "VectorSpace.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 template<class T> class List;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class Vector Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 template <class Cmpt>
00059 class Vector
00060 :
00061     public VectorSpace<Vector<Cmpt>, Cmpt, 3>
00062 {
00063 
00064 public:
00065 
00066     //- Equivalent type of labels used for valid component indexing
00067     typedef Vector<label> labelType;
00068 
00069 
00070     // Member constants
00071 
00072         enum
00073         {
00074             rank = 1 // Rank of Vector is 1
00075         };
00076 
00077 
00078     // Static data members
00079 
00080         static const char* const typeName;
00081         static const char* componentNames[];
00082         static const Vector zero;
00083         static const Vector one;
00084 
00085 
00086     //- Component labeling enumeration
00087     enum components { X, Y, Z };
00088 
00089 
00090     // Constructors
00091 
00092         //- Construct null
00093         inline Vector();
00094 
00095         //- Construct given VectorSpace
00096         inline Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>&);
00097 
00098         //- Construct given three components
00099         inline Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz);
00100 
00101         //- Construct from Istream
00102         inline Vector(Istream&);
00103 
00104 
00105     // Member Functions
00106 
00107         // Access
00108 
00109             inline const Cmpt& x() const;
00110             inline const Cmpt& y() const;
00111             inline const Cmpt& z() const;
00112 
00113             inline Cmpt& x();
00114             inline Cmpt& y();
00115             inline Cmpt& z();
00116 
00117         //- Return *this (used for point which is a typedef to Vector<scalar>.
00118         inline const Vector<Cmpt>& centre(const List<Vector<Cmpt> >&) const;
00119 };
00120 
00121 
00122 template<class Cmpt>
00123 class typeOfRank<Cmpt, 1>
00124 {
00125 public:
00126 
00127     typedef Vector<Cmpt> type;
00128 };
00129 
00130 
00131 template<class Cmpt>
00132 class symmTypeOfRank<Cmpt, 1>
00133 {
00134 public:
00135 
00136     typedef Vector<Cmpt> type;
00137 };
00138 
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 } // End namespace Foam
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 // Include inline implementations
00147 #include "VectorI.H"
00148 
00149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00150 
00151 #endif
00152 
00153 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd