All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
triadI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
29 :
30  Vector<vector>(triad::unset)
31 {}
32 
33 
35 :
36  Vector<vector>(vv)
37 {}
38 
39 
40 inline Foam::triad::triad(const vector& x, const vector& y, const vector& z)
41 :
42  Vector<vector>(x, y, z)
43 {}
44 
45 
46 inline Foam::triad::triad(const vector& pa)
47 {
49  operator[](primaryDirection(pa)) = pa;
50 }
51 
52 
54 :
55  Vector<vector>(is)
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 
61 inline bool Foam::triad::set(const direction d) const
62 {
63  return operator[](d)[0] < great;
64 }
65 
66 
67 inline bool Foam::triad::set() const
68 {
69  return set(0) && set(1) && set(2);
70 }
71 
72 
74 {
75  if (mag(v.x()) > mag(v.y()) && mag(v.x()) > mag(v.z()))
76  {
77  return triad::X;
78  }
79  else if (mag(v.y()) > mag(v.z()))
80  {
81  return triad::Y;
82  }
83  else
84  {
85  return triad::Z;
86  }
87 }
88 
89 
91 (
92  const vector& v1,
93  const vector& v2
94 )
95 {
96  vector v3 = v1 ^ v2;
97 
98  scalar magV3 = mag(v3);
99 
100  if (magV3 > 0.5)
101  {
102  return v3/magV3;
103  }
104  else
105  {
106  return triad::unset[0];
107  }
108 }
109 
110 
112 {
113  if (set(0)) operator[](0) /= mag(operator[](0));
114  if (set(1)) operator[](1) /= mag(operator[](1));
115  if (set(2)) operator[](2) /= mag(operator[](2));
116 }
117 
118 
119 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
120 
122 {
124 }
125 
126 
127 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
128 
130 {
131  is >> static_cast<Vector<vector>&>(t);
132  return is;
133 }
134 
135 
137 {
138  os << static_cast<const Vector<vector>&>(t);
139  return os;
140 }
141 
142 
143 // ************************************************************************* //
void operator=(const Vector< vector > &)
Definition: triadI.H:121
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const vector & z() const
Definition: VectorI.H:87
triad()
Construct null.
Definition: triadI.H:28
const vector & y() const
Definition: VectorI.H:81
void normalize()
Normalize each set axis vector to have a unit magnitude.
Definition: triadI.H:111
static const triad unset
Definition: triad.H:99
Istream & operator>>(Istream &, directionInfo &)
const vector & x() const
Definition: VectorI.H:75
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static direction primaryDirection(const vector &v)
Return the primary direction of the vector v.
Definition: triadI.H:73
static vector orthogonal(const vector &v1, const vector &v2)
Return the vector orthogonal to the two provided.
Definition: triadI.H:91
Representation of a 3D Cartesian coordinate system as a Vector of vectors.
Definition: triad.H:65
Ostream & operator<<(Ostream &, const ensightPart &)
dimensioned< scalar > mag(const dimensioned< Type > &)
const vector & operator[](const direction) const
Definition: VectorSpaceI.H:190
bool set() const
Are all the vector set.
Definition: triadI.H:67