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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
31 template<class Cmpt>
33 {}
34 
35 
36 template<class Cmpt>
38 :
40 {}
41 
42 
43 template<class Cmpt>
44 template<class Cmpt2>
46 (
47  const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs
48 )
49 :
50  Vector::vsType(vs)
51 {}
52 
53 
54 template<class Cmpt>
56 (
57  const Cmpt& vx,
58  const Cmpt& vy,
59  const Cmpt& vz
60 )
61 {
62  this->v_[X] = vx;
63  this->v_[Y] = vy;
64  this->v_[Z] = vz;
65 }
66 
67 
68 template<class Cmpt>
70 :
71  Vector::vsType(is)
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
77 template<class Cmpt>
78 inline const Cmpt& Foam::Vector<Cmpt>::x() const
79 {
80  return this->v_[X];
81 }
82 
83 template<class Cmpt>
84 inline const Cmpt& Foam::Vector<Cmpt>::y() const
85 {
86  return this->v_[Y];
87 }
88 
89 template<class Cmpt>
90 inline const Cmpt& Foam::Vector<Cmpt>::z() const
91 {
92  return this->v_[Z];
93 }
94 
95 
96 template<class Cmpt>
97 inline Cmpt& Foam::Vector<Cmpt>::x()
98 {
99  return this->v_[X];
100 }
101 
102 template<class Cmpt>
103 inline Cmpt& Foam::Vector<Cmpt>::y()
104 {
105  return this->v_[Y];
106 }
107 
108 template<class Cmpt>
109 inline Cmpt& Foam::Vector<Cmpt>::z()
110 {
111  return this->v_[Z];
112 }
113 
114 
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 
117 template<class Cmpt>
119 (
120  const Foam::List<Vector<Cmpt>>&
121 ) const
122 {
123  return *this;
124 }
125 
126 
127 template<class Cmpt>
129 {
130  const scalar s(Foam::mag(*this));
131 
132  if (s < ROOTVSMALL)
133  {
134  *this = Zero;
135  }
136  else
137  {
138  *this /= s;
139  }
140 
141  return *this;
142 }
143 
144 
145 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
146 
147 namespace Foam
148 {
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 //- Dummy innerProduct for scalar to allow the construction of vtables for
153 // virtual member functions involving the inner-products of fields
154 // for which a "NotImplemented" specialization for scalar is provided.
155 template<class Cmpt>
156 class innerProduct<Vector<Cmpt>, scalar>
157 {
158 public:
159 
160  typedef scalar type;
161 };
162 
163 
164 template<class Cmpt>
166 operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
167 {
168  return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
169 }
170 
171 
172 template<class Cmpt>
173 inline Vector<Cmpt> operator^(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
174 {
175  return Vector<Cmpt>
176  (
177  (v1.y()*v2.z() - v1.z()*v2.y()),
178  (v1.z()*v2.x() - v1.x()*v2.z()),
179  (v1.x()*v2.y() - v1.y()*v2.x())
180  );
181 }
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace Foam
187 
188 // ************************************************************************* //
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:78
s
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))
Definition: gmvOutputSpray.H:25
Foam::operator&
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::innerProduct
Definition: products.H:141
Foam::Vector::normalise
Vector< Cmpt > & normalise()
Normalise the vector by its magnitude.
Definition: VectorI.H:128
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:90
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::Vector::centre
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
Definition: VectorI.H:119
Foam::innerProduct< Vector< Cmpt >, scalar >::type
scalar type
Definition: VectorI.H:160
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:84
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::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:590
Foam::operator^
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition: bitSetI.H:757
Foam::Vector::Vector
Vector()
Construct null.
Definition: VectorI.H:32
Foam::zero
A class representing the concept of 0 (zero), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61