1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Templated vector space.
30 Template arguments are the Form the vector space will be used to create,
31 the type of the elements and the number of elements.
37 \*---------------------------------------------------------------------------*/
42 #include "direction.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // Forward declaration of friend functions and operators
53 template<class Form, class Cmpt, int nCmpt> class VectorSpace;
55 template<class Form, class Cmpt, int nCmpt>
59 VectorSpace<Form, Cmpt, nCmpt>&
62 template<class Form, class Cmpt, int nCmpt>
66 const VectorSpace<Form, Cmpt, nCmpt>&
70 /*---------------------------------------------------------------------------*\
71 Class VectorSpace Declaration
72 \*---------------------------------------------------------------------------*/
74 template<class Form, class Cmpt, int nCmpt>
81 typedef Cmpt cmptType;
88 dim = 3, // Dimensionality of space
89 nComponents = nCmpt // Number of components in this vector space
93 // Static data members
95 //- The components of this vector space
102 inline VectorSpace();
104 //- Construct from Istream
105 VectorSpace(Istream&);
107 //- Construct as copy
108 inline VectorSpace(const VectorSpace<Form, Cmpt, nCmpt>&);
113 //- Return the number of elements in the VectorSpace = nCmpt.
114 inline label size() const;
116 inline const Cmpt& component(const direction) const;
117 inline Cmpt& component(const direction);
119 inline void component(Cmpt&, const direction) const;
120 inline void replace(const direction, const Cmpt&);
125 inline const Cmpt& operator[](const direction) const;
126 inline Cmpt& operator[](const direction);
128 inline void operator=(const VectorSpace<Form, Cmpt, nCmpt>&);
129 inline void operator+=(const VectorSpace<Form, Cmpt, nCmpt>&);
130 inline void operator-=(const VectorSpace<Form, Cmpt, nCmpt>&);
132 inline void operator*=(const scalar);
133 inline void operator/=(const scalar);
136 // 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>&
154 // * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * * //
156 //- Return a string representation of a VectorSpace
157 template<class Form, class Cmpt, int nCmpt>
158 word name(const VectorSpace<Form, Cmpt, nCmpt>&);
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 } // End namespace Foam
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 #include "VectorSpaceI.H"
169 # include "VectorSpace.C"
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 // ************************************************************************* //