VectorI.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31template<class Cmpt>
33:
34 Vector::vsType(Zero)
35{}
36
37
38template<class Cmpt>
39template<class Cmpt2>
41(
42 const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs
43)
44:
45 Vector::vsType(vs)
46{}
47
48
49template<class Cmpt>
51(
52 const Cmpt& vx,
53 const Cmpt& vy,
54 const Cmpt& vz
55)
56{
57 this->v_[X] = vx;
58 this->v_[Y] = vy;
59 this->v_[Z] = vz;
60}
61
62
63template<class Cmpt>
65:
66 Vector::vsType(is)
67{}
68
69
70// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71
72template<class Cmpt>
73inline const Cmpt& Foam::Vector<Cmpt>::x() const
74{
75 return this->v_[X];
76}
77
78template<class Cmpt>
79inline const Cmpt& Foam::Vector<Cmpt>::y() const
80{
81 return this->v_[Y];
82}
83
84template<class Cmpt>
85inline const Cmpt& Foam::Vector<Cmpt>::z() const
86{
87 return this->v_[Z];
88}
89
90
91template<class Cmpt>
93{
94 return this->v_[X];
95}
96
97template<class Cmpt>
100 return this->v_[Y];
101}
102
103template<class Cmpt>
105{
106 return this->v_[Z];
107}
108
110// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111
112template<class Cmpt>
114(
116) const
117{
118 return *this;
119}
120
122template<class Cmpt>
125 const scalar s(Foam::mag(*this));
126
127 if (s < tol)
128 {
129 *this = Zero;
131 else
132 {
133 *this /= s;
134 }
136 return *this;
137}
138
140template<class Cmpt>
141inline Foam::Vector<Cmpt>&
144 *this -= (*this & unitVec) * unitVec;
145 return *this;
146}
147
148
149// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
150
151namespace Foam
152{
153
154// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156//- Dummy innerProduct for scalar to allow the construction of vtables for
157// virtual member functions involving the inner-products of fields
158// for which a "NotImplemented" specialization for scalar is provided.
159template<class Cmpt>
160class innerProduct<Vector<Cmpt>, scalar>
161{
162public:
163
164 typedef scalar type;
165};
166
167
168template<class Cmpt>
171{
172 return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
173}
174
175
176template<class Cmpt>
178{
179 return Vector<Cmpt>
180 (
181 (v1.y()*v2.z() - v1.z()*v2.y()),
182 (v1.z()*v2.x() - v1.x()*v2.z()),
183 (v1.x()*v2.y() - v1.y()*v2.x())
184 );
185}
186
187
188template<class Cmpt>
189inline Vector<Cmpt> operator*(const Cmpt& s, const Vector<Cmpt>& v)
190{
191 return Vector<Cmpt>(s*v.x(), s*v.y(), s*v.z());
192}
193
194
195template<class Cmpt>
196inline Vector<Cmpt> operator*(const Vector<Cmpt>& v, const Cmpt& s)
197{
198 return s*v;
199}
200
201
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204} // End namespace Foam
205
206// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
scalar centre() const
Mid-point location, zero for an empty list.
Definition: PDRblockI.H:67
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
Templated vector space.
Definition: VectorSpace.H:79
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:65
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Vector()=default
Default construct.
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
Definition: VectorI.H:142
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
PtrList< volScalarField > & Y
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition: bitSetI.H:790
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131