initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / primitives / Vector / VectorI.H
bloba0a048f3c654d9afb9acbc785f5aa917d95e550d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 namespace Foam
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 // Construct null
35 template <class Cmpt>
36 inline Vector<Cmpt>::Vector()
40 // Construct given VectorSpace
41 template <class Cmpt>
42 inline Vector<Cmpt>::Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>& vs)
44     VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs)
48 // Construct given three Cmpts
49 template <class Cmpt>
50 inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz)
52     this->v_[X] = vx;
53     this->v_[Y] = vy;
54     this->v_[Z] = vz;
58 // Construct from Istream
59 template <class Cmpt>
60 inline Vector<Cmpt>::Vector(Istream& is)
62     VectorSpace<Vector<Cmpt>, Cmpt, 3>(is)
66 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
68 template <class Cmpt>
69 inline const Cmpt&  Vector<Cmpt>::x() const
71     return this->v_[X];
74 template <class Cmpt>
75 inline const Cmpt&  Vector<Cmpt>::y() const
77     return this->v_[Y];
80 template <class Cmpt>
81 inline const Cmpt&  Vector<Cmpt>::z() const
83     return this->v_[Z];
87 template <class Cmpt>
88 inline Cmpt& Vector<Cmpt>::x()
90     return this->v_[X];
93 template <class Cmpt>
94 inline Cmpt& Vector<Cmpt>::y()
96     return this->v_[Y];
99 template <class Cmpt>
100 inline Cmpt& Vector<Cmpt>::z()
102     return this->v_[Z];
106 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
108 template <class Cmpt>
109 inline const Vector<Cmpt>& Vector<Cmpt>::centre
111     const Foam::List<Vector<Cmpt> >&
112 )const
114     return *this;
118 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
120 template <class Cmpt>
121 inline typename innerProduct<Vector<Cmpt>, Vector<Cmpt> >::type
122 operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
124     return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
128 template <class Cmpt>
129 inline Vector<Cmpt> operator^(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
131     return Vector<Cmpt>
132     (
133         (v1.y()*v2.z() - v1.z()*v2.y()),
134         (v1.z()*v2.x() - v1.x()*v2.z()),
135         (v1.x()*v2.y() - v1.y()*v2.x())
136     );
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 } // End namespace Foam
144 // ************************************************************************* //