1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Templated vector space.
31 Template arguments are the Form the vector space will be used to create,
32 the type of the elements and the number of elements.
38 \*---------------------------------------------------------------------------*/
43 #include "direction.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of friend functions and operators
54 template<class Form, class Cmpt, int nCmpt> class VectorSpace;
56 template<class Form, class Cmpt, int nCmpt>
60 VectorSpace<Form, Cmpt, nCmpt>&
63 template<class Form, class Cmpt, int nCmpt>
67 const VectorSpace<Form, Cmpt, nCmpt>&
71 /*---------------------------------------------------------------------------*\
72 Class VectorSpace Declaration
73 \*---------------------------------------------------------------------------*/
75 template<class Form, class Cmpt, int nCmpt>
82 typedef Cmpt cmptType;
89 dim = 3, // Dimensionality of space
90 nComponents = nCmpt // Number of components in this vector space
94 // Static data members
96 //- The components of this vector space
103 inline VectorSpace();
105 //- Construct from Istream
106 VectorSpace(Istream&);
108 //- Construct as copy
109 inline VectorSpace(const VectorSpace<Form, Cmpt, nCmpt>&);
114 //- Return the number of elements in the VectorSpace = nCmpt.
115 inline label size() const;
117 inline const Cmpt& component(const direction) const;
118 inline Cmpt& component(const direction);
120 inline void component(Cmpt&, const direction) const;
121 inline void replace(const direction, const Cmpt&);
126 inline const Cmpt& operator[](const direction) const;
127 inline Cmpt& operator[](const direction);
129 inline void operator=(const VectorSpace<Form, Cmpt, nCmpt>&);
130 inline void operator+=(const VectorSpace<Form, Cmpt, nCmpt>&);
131 inline void operator-=(const VectorSpace<Form, Cmpt, nCmpt>&);
133 inline void operator*=(const scalar);
134 inline void operator/=(const scalar);
137 // IOstream Operators
139 friend Istream& operator>> <Form, Cmpt, nCmpt>
142 VectorSpace<Form, Cmpt, nCmpt>&
145 friend Ostream& operator<< <Form, Cmpt, nCmpt>
148 const VectorSpace<Form, Cmpt, nCmpt>&
153 // * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * * //
155 //- Return a string representation of a VectorSpace
156 template<class Form, class Cmpt, int nCmpt>
157 word name(const VectorSpace<Form, Cmpt, nCmpt>&);
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace Foam
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 #include "VectorSpaceI.H"
168 # include "VectorSpace.C"
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 // ************************************************************************* //