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

VectorSpace.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::VectorSpace
00026 
00027 Description
00028     Templated vector space.
00029 
00030     Template arguments are the Form the vector space will be used to create,
00031     the type of the elements and the number of elements.
00032 
00033 SourceFiles
00034     VectorSpaceI.H
00035     VectorSpace.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef VectorSpace_H
00040 #define VectorSpace_H
00041 
00042 #include <OpenFOAM/direction.H>
00043 #include <OpenFOAM/scalar.H>
00044 #include <OpenFOAM/word.H>
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 // Forward declaration of friend functions and operators
00052 
00053 template<class Form, class Cmpt, int nCmpt> class VectorSpace;
00054 
00055 template<class Form, class Cmpt, int nCmpt>
00056 Istream& operator>>
00057 (
00058     Istream&,
00059     VectorSpace<Form, Cmpt, nCmpt>&
00060 );
00061 
00062 template<class Form, class Cmpt, int nCmpt>
00063 Ostream& operator<<
00064 (
00065     Ostream&,
00066     const VectorSpace<Form, Cmpt, nCmpt>&
00067 );
00068 
00069 
00070 /*---------------------------------------------------------------------------*\
00071                            Class VectorSpace Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 template<class Form, class Cmpt, int nCmpt>
00075 class VectorSpace
00076 {
00077 
00078 public:
00079 
00080     //- Component type
00081     typedef Cmpt cmptType;
00082 
00083 
00084     // Member constants
00085 
00086         enum
00087         {
00088             dim = 3,            // Dimensionality of space
00089             nComponents = nCmpt // Number of components in this vector space
00090         };
00091 
00092 
00093     // Static data members
00094 
00095         //- The components of this vector space
00096         Cmpt v_[nCmpt];
00097 
00098 
00099     // Constructors
00100 
00101         //- Construct null
00102         inline VectorSpace();
00103 
00104         //- Construct from Istream
00105         VectorSpace(Istream&);
00106 
00107         //- Construct as copy
00108         inline VectorSpace(const VectorSpace<Form, Cmpt, nCmpt>&);
00109 
00110 
00111     // Member Functions
00112 
00113         //- Return the number of elements in the VectorSpace = nCmpt.
00114         inline label size() const;
00115 
00116         inline const Cmpt& component(const direction) const;
00117         inline Cmpt& component(const direction);
00118 
00119         inline void component(Cmpt&, const direction) const;
00120         inline void replace(const direction, const Cmpt&);
00121 
00122 
00123     // Member Operators
00124 
00125         inline const Cmpt& operator[](const direction) const;
00126         inline Cmpt& operator[](const direction);
00127 
00128         inline void operator=(const VectorSpace<Form, Cmpt, nCmpt>&);
00129         inline void operator+=(const VectorSpace<Form, Cmpt, nCmpt>&);
00130         inline void operator-=(const VectorSpace<Form, Cmpt, nCmpt>&);
00131 
00132         inline void operator*=(const scalar);
00133         inline void operator/=(const scalar);
00134 
00135 
00136     // IOstream Operators
00137 
00138         friend Istream& operator>> <Form, Cmpt, nCmpt>
00139         (
00140             Istream&,
00141             VectorSpace<Form, Cmpt, nCmpt>&
00142         );
00143 
00144         friend Ostream& operator<< <Form, Cmpt, nCmpt>
00145         (
00146             Ostream&,
00147             const VectorSpace<Form, Cmpt, nCmpt>&
00148         );
00149 };
00150 
00151 
00152 // * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * * //
00153 
00154 //- Return a string representation of a VectorSpace
00155 template<class Form, class Cmpt, int nCmpt>
00156 word name(const VectorSpace<Form, Cmpt, nCmpt>&);
00157 
00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00159 
00160 } // End namespace Foam
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 #include <OpenFOAM/VectorSpaceI.H>
00165 
00166 #ifdef NoRepository
00167 #   include <OpenFOAM/VectorSpace.C>
00168 #endif
00169 
00170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00171 
00172 #endif
00173 
00174 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines