triad.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-2021 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 Class
25  Foam::triad
26 
27 Description
28  Representation of a 3D Cartesian coordinate system as a Vector of vectors.
29 
30 See also
31  Foam::quaternion
32 
33 SourceFiles
34  triadI.H
35  triad.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef triad_H
40 #define triad_H
41 
42 #include "vector.H"
43 #include "tensor.H"
44 #include "contiguous.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of classes
52 class Istream;
53 class Ostream;
54 
55 // Forward declaration of friend functions and operators
56 class triad;
57 Istream& operator>>(Istream&, triad&);
58 Ostream& operator<<(Ostream&, const triad&);
59 
60 class quaternion;
61 
62 /*---------------------------------------------------------------------------*\
63  Class triad Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class triad
67 :
68  public Vector<vector>
69 {
70 
71 public:
72 
73  // Constructors
74 
75  //- Construct null
76  inline triad();
77 
78  //- Construct from components
79  inline triad(const Vector<vector>& vv);
80 
81  //- Construct from coordinate axes
82  inline triad(const vector& x, const vector& y, const vector& z);
83 
84  //- Construct from a primary axis with the other two unset
85  inline triad(const vector& pa);
86 
87  //- Construct from a quaternion
88  triad(const quaternion& q);
89 
90  //- Construct from a tensor
91  triad(const tensor& t);
92 
93  //- Construct from Istream
94  inline triad(Istream&);
95 
96 
97  // Static Data Members
98 
99  static const triad I;
100  static const triad unset;
101 
102 
103  // Member Functions
104 
105  //- Is the vector in the direction d set
106  inline bool set(const direction d) const;
107 
108  //- Are all the vector set
109  inline bool set() const;
110 
111  //- Return the primary direction of the vector v
112  static inline direction primaryDirection(const vector& v);
113 
114  //- Return the vector orthogonal to the two provided
115  static inline vector orthogonal(const vector& v1, const vector& v2);
116 
117  //- Orthogonalise this triad so that it is ortho-normal
118  void orthogonalise();
119 
120  //- Normalise each set axis vector to have a unit magnitude
121  void normalise();
122 
123  //- Align this triad with the given vector v
124  // by rotating the most aligned axis to be coincident with v
125  void align(const vector& v);
126 
127  //- Sort the axes such that they are closest to the x, y and z axes
128  triad sortxyz() const;
129 
130  //- Convert to a quaternion
131  operator quaternion() const;
132 
133 
134  // Member Operators
135 
136  inline void operator=(const Vector<vector>&);
137 
138  void operator=(const tensor& t);
139 
140  //- Add the triad t2 to this triad
141  // without normalising or orthogonalising
142  void operator+=(const triad& t2);
143 
144 
145  // IOstream Operators
146 
147  inline friend Istream& operator>>(Istream&, triad&);
148  inline friend Ostream& operator<<(Ostream&, const triad&);
149 };
150 
151 
152 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
153 
154 //- Return a quantity of the difference between two triads
155 scalar diff(const triad& A, const triad& B);
156 
157 //- Data associated with quaternion type are contiguous
158 template<>
159 inline bool contiguous<triad>() {return true;}
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #include "triadI.H"
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
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:57
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:60
const vector & z() const
Definition: VectorI.H:87
const vector & y() const
Definition: VectorI.H:81
const vector & x() const
Definition: VectorI.H:75
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:61
Representation of a 3D Cartesian coordinate system as a Vector of vectors.
Definition: triad.H:68
void align(const vector &v)
Align this triad with the given vector v.
Definition: triad.C:261
static const triad unset
Definition: triad.H:99
bool set() const
Are all the vector set.
Definition: triadI.H:67
static direction primaryDirection(const vector &v)
Return the primary direction of the vector v.
Definition: triadI.H:73
triad()
Construct null.
Definition: triadI.H:28
triad sortxyz() const
Sort the axes such that they are closest to the x, y and z axes.
Definition: triad.C:306
friend Ostream & operator<<(Ostream &, const triad &)
static const triad I
Definition: triad.H:98
void normalise()
Normalise each set axis vector to have a unit magnitude.
Definition: triadI.H:111
void operator+=(const triad &t2)
Add the triad t2 to this triad.
Definition: triad.C:198
void operator=(const Vector< vector > &)
Definition: triadI.H:121
friend Istream & operator>>(Istream &, triad &)
void orthogonalise()
Orthogonalise this triad so that it is ortho-normal.
Definition: triad.C:114
static vector orthogonal(const vector &v1, const vector &v2)
Return the vector orthogonal to the two provided.
Definition: triadI.H:91
Template function to specify if the data of a type are contiguous.
Namespace for OpenFOAM.
bool contiguous< triad >()
Data associated with quaternion type are contiguous.
Definition: triad.H:158
Istream & operator>>(Istream &, pistonPointEdgeData &)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:409
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
uint8_t direction
Definition: direction.H:45