OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-2009 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     Foam::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         static const Vector max;
00085         static const Vector min;
00086 
00087 
00088     //- Component labeling enumeration
00089     enum components { X, Y, Z };
00090 
00091 
00092     // Constructors
00093 
00094         //- Construct null
00095         inline Vector();
00096 
00097         //- Construct given VectorSpace
00098         inline Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>&);
00099 
00100         //- Construct given three components
00101         inline Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz);
00102 
00103         //- Construct from Istream
00104         inline Vector(Istream&);
00105 
00106 
00107     // Member Functions
00108 
00109         // Access
00110 
00111             inline const Cmpt& x() const;
00112             inline const Cmpt& y() const;
00113             inline const Cmpt& z() const;
00114 
00115             inline Cmpt& x();
00116             inline Cmpt& y();
00117             inline Cmpt& z();
00118 
00119         //- Return *this (used for point which is a typedef to Vector<scalar>.
00120         inline const Vector<Cmpt>& centre
00121         (
00122             const Foam::List<Vector<Cmpt> >&
00123         ) const;
00124 };
00125 
00126 
00127 template<class Cmpt>
00128 class typeOfRank<Cmpt, 1>
00129 {
00130 public:
00131 
00132     typedef Vector<Cmpt> type;
00133 };
00134 
00135 
00136 template<class Cmpt>
00137 class symmTypeOfRank<Cmpt, 1>
00138 {
00139 public:
00140 
00141     typedef Vector<Cmpt> type;
00142 };
00143 
00144 
00145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00146 
00147 } // End namespace Foam
00148 
00149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00150 
00151 #include "VectorI.H"
00152 
00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00154 
00155 #endif
00156 
00157 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd