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