Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / OpenFOAM / primitives / Vector / VectorI.H
blob1ed86bf2d7535b2b75c665439076e94c22892729
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
28 namespace Foam
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 // Construct null
34 template <class Cmpt>
35 inline Vector<Cmpt>::Vector()
39 // Construct given VectorSpace
40 template <class Cmpt>
41 inline Vector<Cmpt>::Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>& vs)
43     VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs)
47 // Construct given three Cmpts
48 template <class Cmpt>
49 inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz)
51     this->v_[X] = vx;
52     this->v_[Y] = vy;
53     this->v_[Z] = vz;
57 // Construct from Istream
58 template <class Cmpt>
59 inline Vector<Cmpt>::Vector(Istream& is)
61     VectorSpace<Vector<Cmpt>, Cmpt, 3>(is)
65 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
67 template <class Cmpt>
68 inline const Cmpt&  Vector<Cmpt>::x() const
70     return this->v_[X];
73 template <class Cmpt>
74 inline const Cmpt&  Vector<Cmpt>::y() const
76     return this->v_[Y];
79 template <class Cmpt>
80 inline const Cmpt&  Vector<Cmpt>::z() const
82     return this->v_[Z];
86 template <class Cmpt>
87 inline Cmpt& Vector<Cmpt>::x()
89     return this->v_[X];
92 template <class Cmpt>
93 inline Cmpt& Vector<Cmpt>::y()
95     return this->v_[Y];
98 template <class Cmpt>
99 inline Cmpt& Vector<Cmpt>::z()
101     return this->v_[Z];
105 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
107 template <class Cmpt>
108 inline const Vector<Cmpt>& Vector<Cmpt>::centre
110     const Foam::List<Vector<Cmpt> >&
111 )const
113     return *this;
117 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
119 template <class Cmpt>
120 inline typename innerProduct<Vector<Cmpt>, Vector<Cmpt> >::type
121 operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
123     return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
127 template <class Cmpt>
128 inline Vector<Cmpt> operator^(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
130     return Vector<Cmpt>
131     (
132         (v1.y()*v2.z() - v1.z()*v2.y()),
133         (v1.z()*v2.x() - v1.x()*v2.z()),
134         (v1.x()*v2.y() - v1.y()*v2.x())
135     );
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 } // End namespace Foam
143 // ************************************************************************* //