triad.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
27Class
28 Foam::triad
29
30Description
31 Representation of a 3D Cartesian coordinate system as a Vector of
32 row vectors.
33
34See also
35 Foam::quaternion
36
37SourceFiles
38 triadI.H
39 triad.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_triad_H
44#define Foam_triad_H
45
46#include "vector.H"
47#include "tensor.H"
48#include "contiguous.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class triad;
57class quaternion;
58inline Istream& operator>>(Istream&, triad&);
59inline Ostream& operator<<(Ostream&, const triad&);
60
61/*---------------------------------------------------------------------------*\
62 Class triad Declaration
63\*---------------------------------------------------------------------------*/
65class triad
66:
67 public Vector<vector>
68{
69public:
70
71 // Constructors
72
73 //- Default construct
74 inline triad();
75
76 //- Construct from components
77 inline triad(const Vector<vector>& vv);
78
79 //- Construct from coordinate axes (row vectors)
80 inline triad(const vector& x, const vector& y, const vector& z);
81
82 //- Construct from a tensor
83 inline triad(const tensor& t);
84
85 //- Construct from a primary axis with the other two unset
86 inline triad(const vector& pa);
87
88 //- Construct from a quaternion
89 triad(const quaternion& q);
90
91 //- Construct from Istream
92 inline triad(Istream&);
93
94
95 // Static data members
97 static const triad I;
98 static const triad unset;
99
100
101 // Member Functions
102
103 //- Is the vector in the direction d set
104 inline bool set(const direction d) const;
105
106 //- Are all the vector set
107 inline bool set() const;
108
109 //- Return the primary direction of the vector v
110 static inline direction primaryDirection(const vector& v);
111
112 //- Return the vector orthogonal to the two provided
113 static inline vector orthogonal(const vector& v1, const vector& v2);
114
115 //- Inplace orthogonalise so that it is ortho-normal
116 void orthogonalise();
117
118 //- Normalise each set axis vector to have a unit magnitude
119 // Uses vector::normalise with handling of small magnitudes.
120 void normalise();
121
122 //- Align this triad with the given vector v
123 // by rotating the most aligned axis to be coincident with v
124 void align(const vector& v);
125
126 //- Sort the axes such that they are closest to the x, y and z axes
127 triad sortxyz() const;
128
129 //- Convert to a quaternion
130 operator quaternion() const;
131
132 //- Return transpose
133 inline triad T() const;
134
135
136 // Column-vector access.
137
138 //- Extract vector for column 0
139 inline vector cx() const;
140
141 //- Extract vector for column 1
142 inline vector cy() const;
143
144 //- Extract vector for column 2
145 inline vector cz() const;
146
147
148 // Member Operators
149
150 inline void operator=(const Vector<vector>& vv);
151
152 inline void operator=(const tensor& t);
153
154 //- Add the triad t2 to this triad
155 // without normalising or orthogonalising
156 void operator+=(const triad& t2);
157
158
159 // IOstream Operators
162 friend Ostream& operator<<(Ostream&, const triad&);
163
164
165 // Housekeeping
166
167 //- Same as orthogonalise
168 void orthogonalize() { this->orthogonalise(); }
169
170 //- Same as normalise
171 void normalize() { this->normalise(); }
172};
173
174
175// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
176
177//- Contiguous data for triad
178template<> struct is_contiguous<triad> : std::true_type {};
179
180//- Contiguous 'scalar' data for triad
181template<> struct is_contiguous_scalar<triad> : std::true_type {};
182
183
184// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
185
186//- Return a quantity of the difference between two triads
187scalar diff(const triad& A, const triad& B);
188
189
190// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191
192} // End namespace Foam
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196#include "triadI.H"
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200#endif
201
202// ************************************************************************* //
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
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
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:65
const vector & z() const
Access to the vector z component.
Definition: VectorI.H:85
const vector & y() const
Access to the vector y component.
Definition: VectorI.H:79
const vector & x() const
Access to the vector x component.
Definition: VectorI.H:73
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:58
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
Definition: triad.H:67
void align(const vector &v)
Align this triad with the given vector v.
Definition: triad.C:240
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
friend Ostream & operator<<(Ostream &, const triad &)
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
triad sortxyz() const
Sort the axes such that they are closest to the x, y and z axes.
Definition: triad.C:285
friend Istream & operator>>(Istream &, triad &)
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 normalize()
Same as normalise.
Definition: triad.H:170
static const triad I
Definition: triad.H:96
void normalise()
Normalise each set axis vector to have a unit magnitude.
Definition: triadI.H:120
void operator+=(const triad &t2)
Add the triad t2 to this triad.
Definition: triad.C:177
void orthogonalise()
Inplace orthogonalise so that it is ortho-normal.
Definition: triad.C:102
void orthogonalize()
Same as orthogonalise.
Definition: triad.H:167
static vector orthogonal(const vector &v1, const vector &v2)
Return the vector orthogonal to the two provided.
Definition: triadI.H:100
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
uint8_t direction
Definition: direction.H:56
A template class to specify if a data type is composed solely of Foam::scalar elements.
Definition: contiguous.H:94
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:78