FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::Vector
00026 
00027 Description
00028     Templated 3D Vector derived from VectorSpace adding construction from
00029     3 components, element access using x(), y() and z() member functions and
00030     the inner-product (dot-product) and cross product operators.
00031 
00032     A centre() member function which returns the Vector for which it is called
00033     is defined so that point which is a typedef to Vector<scalar> behaves as
00034     other shapes in the shape hierachy.
00035 
00036 SourceFiles
00037     VectorI.H
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef Vector_H
00042 #define Vector_H
00043 
00044 #include <OpenFOAM/VectorSpace.H>
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 template<class T> class List;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                            Class Vector Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 template <class Cmpt>
00058 class Vector
00059 :
00060     public VectorSpace<Vector<Cmpt>, Cmpt, 3>
00061 {
00062 
00063 public:
00064 
00065     //- Equivalent type of labels used for valid component indexing
00066     typedef Vector<label> labelType;
00067 
00068 
00069     // Member constants
00070 
00071         enum
00072         {
00073             rank = 1 // Rank of Vector is 1
00074         };
00075 
00076 
00077     // Static data members
00078 
00079         static const char* const typeName;
00080         static const char* componentNames[];
00081         static const Vector zero;
00082         static const Vector one;
00083         static const Vector max;
00084         static const Vector min;
00085 
00086 
00087     //- Component labeling enumeration
00088     enum components { X, Y, Z };
00089 
00090 
00091     // Constructors
00092 
00093         //- Construct null
00094         inline Vector();
00095 
00096         //- Construct given VectorSpace
00097         inline Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>&);
00098 
00099         //- Construct given three components
00100         inline Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz);
00101 
00102         //- Construct from Istream
00103         inline Vector(Istream&);
00104 
00105 
00106     // Member Functions
00107 
00108         // Access
00109 
00110             inline const Cmpt& x() const;
00111             inline const Cmpt& y() const;
00112             inline const Cmpt& z() const;
00113 
00114             inline Cmpt& x();
00115             inline Cmpt& y();
00116             inline Cmpt& z();
00117 
00118         //- Return *this (used for point which is a typedef to Vector<scalar>.
00119         inline const Vector<Cmpt>& centre
00120         (
00121             const Foam::List<Vector<Cmpt> >&
00122         ) const;
00123 };
00124 
00125 
00126 template<class Cmpt>
00127 class typeOfRank<Cmpt, 1>
00128 {
00129 public:
00130 
00131     typedef Vector<Cmpt> type;
00132 };
00133 
00134 
00135 template<class Cmpt>
00136 class symmTypeOfRank<Cmpt, 1>
00137 {
00138 public:
00139 
00140     typedef Vector<Cmpt> type;
00141 };
00142 
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 } // End namespace Foam
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 #include "VectorI_.H"
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 #endif
00155 
00156 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines