triadI.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) 2012-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 
32 :
34 {}
35 
36 
38 :
39  Vector<vector>(vv)
40 {}
41 
42 
43 inline Foam::triad::triad(const vector& x, const vector& y, const vector& z)
44 :
45  Vector<vector>(x, y, z)
46 {}
47 
48 
49 inline Foam::triad::triad(const tensor& t)
50 :
51  Vector<vector>(t.x(), t.y(), t.z())
52 {}
53 
54 
55 inline Foam::triad::triad(const vector& pa)
56 {
57  operator=(triad::unset);
58  operator[](primaryDirection(pa)) = pa;
59 }
60 
61 
63 :
64  Vector<vector>(is)
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
70 inline bool Foam::triad::set(const direction d) const
71 {
72  return operator[](d)[0] < GREAT;
73 }
74 
75 
76 inline bool Foam::triad::set() const
77 {
78  return set(0) && set(1) && set(2);
79 }
80 
81 
83 {
84  if (mag(v.x()) > mag(v.y()) && mag(v.x()) > mag(v.z()))
85  {
86  return triad::X;
87  }
88  else if (mag(v.y()) > mag(v.z()))
89  {
90  return triad::Y;
91  }
92  else
93  {
94  return triad::Z;
95  }
96 }
97 
98 
100 (
101  const vector& v1,
102  const vector& v2
103 )
104 {
105  vector v3 = v1 ^ v2;
106 
107  scalar magV3 = mag(v3);
108 
109  if (magV3 > 0.5)
110  {
111  return v3/magV3;
112  }
113  else
114  {
115  return triad::unset[0];
116  }
117 }
118 
119 
121 {
122  if (set(0)) operator[](0) /= mag(operator[](0));
123  if (set(1)) operator[](1) /= mag(operator[](1));
124  if (set(2)) operator[](2) /= mag(operator[](2));
125 }
126 
127 
129 {
130  return vector(x().x(), y().x(), z().x());
131 }
132 
133 
135 {
136  return vector(x().y(), y().y(), z().y());
137 }
138 
139 
141 {
142  return vector(x().z(), y().z(), z().z());
143 }
144 
145 
147 {
148  return triad(cx(), cy(), cz());
149 }
150 
151 
152 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
153 
155 {
157 }
158 
159 
160 inline void Foam::triad::operator=(const tensor& t)
161 {
162  x() = t.x();
163  y() = t.y();
164  z() = t.z();
165 }
166 
167 
168 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
169 
171 {
172  is >> static_cast<Vector<vector>&>(t);
173  return is;
174 }
175 
176 
178 {
179  os << static_cast<const Vector<vector>&>(t);
180  return os;
181 }
182 
183 
184 // ************************************************************************* //
Foam::Vector::operator=
Vector & operator=(const Vector &)=default
Copy assignment.
Foam::Tensor< scalar >
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::Vector< vector >::Z
Definition: Vector.H:81
Foam::Vector< vector >::Y
Definition: Vector.H:81
Foam::Tensor::z
Vector< Cmpt > z() const
Extract vector for row 2.
Definition: TensorI.H:292
Foam::triad::T
triad T() const
Return transpose.
Definition: triadI.H:146
Foam::triad::normalize
void normalize()
Normalize each set axis vector to have a unit magnitude.
Definition: triadI.H:120
Foam::triad::orthogonal
static vector orthogonal(const vector &v1, const vector &v2)
Return the vector orthogonal to the two provided.
Definition: triadI.H:100
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::BitOps::unset
void unset(List< bool > &bools, const labelRange &range)
Unset the specified range 'on' in a boolList.
Definition: BitOps.C:96
Foam::triad::cx
vector cx() const
Extract vector for column 0.
Definition: triadI.H:128
Foam::triad::cz
vector cz() const
Extract vector for column 2.
Definition: triadI.H:140
Foam::triad::primaryDirection
static direction primaryDirection(const vector &v)
Return the primary direction of the vector v.
Definition: triadI.H:82
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
Foam::triad::operator=
void operator=(const Vector< vector > &vv)
Definition: triadI.H:154
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::triad::unset
static const triad unset
Definition: triad.H:97
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::Tensor::x
Vector< Cmpt > x() const
Extract vector for row 0.
Definition: TensorI.H:278
Foam::Vector< vector >::X
Definition: Vector.H:81
Foam::triad::cy
vector cy() const
Extract vector for column 1.
Definition: triadI.H:134
os
OBJstream os(runTime.globalPath()/outputName)
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::triad
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
Definition: triad.H:64
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
Foam::Tensor::y
Vector< Cmpt > y() const
Extract vector for row 1.
Definition: TensorI.H:285
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::triad::set
bool set() const
Are all the vector set.
Definition: triadI.H:76
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::direction
uint8_t direction
Definition: direction.H:52
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::triad::triad
triad()
Construct null.
Definition: triadI.H:31
y
scalar y
Definition: LISASMDCalcMethod1.H:14