initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / VectorSpace / VectorSpace.H
blob31e5b84f4aab19d6e507dcddf174501325937898
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::VectorSpace
28 Description
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.
34 SourceFiles
35     VectorSpaceI.H
36     VectorSpace.C
38 \*---------------------------------------------------------------------------*/
40 #ifndef VectorSpace_H
41 #define VectorSpace_H
43 #include "direction.H"
44 #include "scalar.H"
45 #include "word.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
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>
57 Istream& operator>>
59     Istream&,
60     VectorSpace<Form, Cmpt, nCmpt>&
63 template<class Form, class Cmpt, int nCmpt>
64 Ostream& operator<<
66     Ostream&,
67     const VectorSpace<Form, Cmpt, nCmpt>&
71 /*---------------------------------------------------------------------------*\
72                            Class VectorSpace Declaration
73 \*---------------------------------------------------------------------------*/
75 template<class Form, class Cmpt, int nCmpt>
76 class VectorSpace
79 public:
81     //- Component type
82     typedef Cmpt cmptType;
85     // Member constants
87         enum
88         {
89             dim = 3,            // Dimensionality of space
90             nComponents = nCmpt // Number of components in this vector space
91         };
94     // Static data members
96         //- The components of this vector space
97         Cmpt v_[nCmpt];
100     // Constructors
102         //- Construct null
103         inline VectorSpace();
105         //- Construct from Istream
106         VectorSpace(Istream&);
108         //- Construct as copy
109         inline VectorSpace(const VectorSpace<Form, Cmpt, nCmpt>&);
112     // Member Functions
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&);
124     // Member Operators
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>
140         (
141             Istream&,
142             VectorSpace<Form, Cmpt, nCmpt>&
143         );
145         friend Ostream& operator<< <Form, Cmpt, nCmpt>
146         (
147             Ostream&,
148             const VectorSpace<Form, Cmpt, nCmpt>&
149         );
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"
167 #ifdef NoRepository
168 #   include "VectorSpace.C"
169 #endif
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 #endif
175 // ************************************************************************* //