![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 // Member constants 00067 00068 enum 00069 { 00070 rank = 1 // Rank of Vector is 1 00071 }; 00072 00073 00074 // Static data members 00075 00076 static const char* const typeName; 00077 static const char* componentNames[]; 00078 static const Vector zero; 00079 static const Vector one; 00080 00081 00082 //- Component labeling enumeration 00083 enum components { X, Y, Z }; 00084 00085 00086 // Constructors 00087 00088 //- Construct null 00089 inline Vector(); 00090 00091 //- Construct given VectorSpace 00092 inline Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>&); 00093 00094 //- Construct given three components 00095 inline Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz); 00096 00097 //- Construct from Istream 00098 inline Vector(Istream&); 00099 00100 00101 // Member Functions 00102 00103 // Access 00104 00105 inline const Cmpt& x() const; 00106 inline const Cmpt& y() const; 00107 inline const Cmpt& z() const; 00108 00109 inline Cmpt& x(); 00110 inline Cmpt& y(); 00111 inline Cmpt& z(); 00112 00113 //- Return *this (used for point which is a typedef to Vector<scalar>. 00114 inline const Vector<Cmpt>& centre(const List<Vector<Cmpt> >&) const; 00115 }; 00116 00117 00118 template<class Cmpt> 00119 class typeOfRank<Cmpt, 1> 00120 { 00121 public: 00122 00123 typedef Vector<Cmpt> type; 00124 }; 00125 00126 00127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00128 00129 } // End namespace Foam 00130 00131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00132 00133 // Include inline implementations 00134 #include "VectorI.H" 00135 00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00137 00138 #endif 00139 00140 // ************************************************************************* //