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 * * * * * * * * * * * * * * //
30
32:
33 Vector<vector>(triad::unset)
34{}
35
36
38:
39 Vector<vector>(vv)
40{}
41
42
43inline Foam::triad::triad(const vector& x, const vector& y, const vector& z)
44:
45 Vector<vector>(x, y, z)
46{}
47
48
49inline Foam::triad::triad(const tensor& t)
50:
51 Vector<vector>(t.x(), t.y(), t.z())
52{}
53
54
55inline 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
70inline bool Foam::triad::set(const direction d) const
71{
72 return operator[](d)[0] < GREAT;
73}
74
75
76inline 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)) (*this)[0].normalise();
123 if (set(1)) (*this)[1].normalise();
124 if (set(2)) (*this)[2].normalise();
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
160inline 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// ************************************************************************* //
scalar y
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Vector< Cmpt > z() const
Extract vector for row 2.
Definition: TensorI.H:293
Vector< Cmpt > y() const
Extract vector for row 1.
Definition: TensorI.H:286
Vector< Cmpt > x() const
Extract vector for row 0.
Definition: TensorI.H:279
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
Vector & operator=(const Vector &)=default
Copy assignment.
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
bool orthogonal() const
Return whether mesh is orthogonal or not.
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
Definition: triad.H:67
static const triad unset
Definition: triad.H:97
bool set() const
Are all the vector set.
Definition: triadI.H:76
vector cz() const
Extract vector for column 2.
Definition: triadI.H:140
void operator=(const Vector< vector > &vv)
Definition: triadI.H:154
static direction primaryDirection(const vector &v)
Return the primary direction of the vector v.
Definition: triadI.H:82
triad T() const
Return transpose.
Definition: triadI.H:146
triad()
Default construct.
Definition: triadI.H:31
vector cy() const
Extract vector for column 1.
Definition: triadI.H:134
vector cx() const
Extract vector for column 0.
Definition: triadI.H:128
void normalise()
Normalise each set axis vector to have a unit magnitude.
Definition: triadI.H:120
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
uint8_t direction
Definition: direction.H:56
Vector< scalar > vector
Definition: vector.H:61