EulerCoordinateRotation.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) 2011-2018 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::EulerCoordinateRotation
26 
27 Description
28  A coordinateRotation defined in the z-x-y Euler convention.
29 
30  The 3 rotations are defined in the Euler convention
31  (around Z, around X' and around Z').
32  For reference and illustration, see
33  http://mathworld.wolfram.com/EulerAngles.html
34  Note, however, that it is the reverse transformation
35  (local->global) that is defined here.
36 
37  - the rotation angles are in degrees, unless otherwise explicitly specified:
38 
39  \verbatim
40  coordinateRotation
41  {
42  type EulerRotation;
43  degrees false;
44  rotation (0 0 3.141592654);
45  }
46  \endverbatim
47 
48 SourceFiles
49  EulerCoordinateRotation.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef EulerCoordinateRotation_H
54 #define EulerCoordinateRotation_H
55 
56 #include "coordinateRotation.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class EulerCoordinateRotation Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 :
69  public coordinateRotation
70 {
71 
72  // Private Member Data
73 
74  //- Local-to-global transformation tensor
75  tensor R_;
76 
77  //- Global-to-Local transformation tensor
78  tensor Rtr_;
79 
80 
81  // Private Member Functions
82 
83  //- Calculate transformation tensor
84  void calcTransform
85  (
86  const scalar phiAngle,
87  const scalar thetaAngle,
88  const scalar psiAngle,
89  const bool inDegrees=true
90  );
91 
92 
93 public:
94 
95  //- Runtime type information
96  TypeName("EulerRotation");
97 
98 
99  // Constructors
100 
101  //- Construct null
103 
104  //- Construct from rotation vector
106  (
107  const vector& phiThetaPsi,
108  const bool inDegrees=true
109  );
110 
111  //- Construct from components of rotation vector
113  (
114  const scalar phiAngle,
115  const scalar thetaAngle,
116  const scalar psiAngle,
117  const bool inDegrees=true
118  );
119 
120  //- Construct from dictionary
122 
123  //- Construct from dictionary and mesh
125 
126 
127  // Member Functions
128 
129  //- Reset rotation to an identity rotation
130  virtual void clear()
131  {
132  R_ = sphericalTensor::I;
133  Rtr_ = sphericalTensor::I;
134  }
135 
136  //- Update the rotation for a list of cells
137  virtual void updateCells(const polyMesh&, const labelList&)
138  {}
139 
140  //- Return local-to-global transformation tensor
141  virtual const tensor& R() const
142  {
143  return R_;
144  }
145 
146  //- Return global-to-local transformation tensor
147  virtual const tensor& Rtr() const
148  {
149  return Rtr_;
150  };
151 
152  //- Return local Cartesian x-axis in global coordinates
153  virtual const vector e1() const
154  {
155  return Rtr_.x();
156  }
157 
158  //- Return local Cartesian y-axis in global coordinates
159  virtual const vector e2() const
160  {
161  return Rtr_.y();
162  }
163 
164  //- Return local Cartesian z-axis in global coordinates
165  virtual const vector e3() const
166  {
167  return Rtr_.z();
168  }
169 
170  //- Return transformation tensor field
171  virtual const tensorField& Tr() const;
172 
173  //- Transform vectorField using transformation tensor field
174  virtual tmp<vectorField> transform(const vectorField& st) const;
175 
176  //- Transform vector using transformation tensor
177  virtual vector transform(const vector& st) const;
178 
179  //- Inverse transform vectorField using transformation tensor field
180  virtual tmp<vectorField> invTransform(const vectorField& st) const;
181 
182  //- Inverse transform vector using transformation tensor
183  virtual vector invTransform(const vector& st) const;
184 
185  //- Transform tensor field using transformation tensorField
186  virtual tmp<tensorField> transformTensor(const tensorField& st) const;
187 
188  //- Transform tensor using transformation tensorField
189  virtual tensor transformTensor(const tensor& st) const;
190 
191  //- Transform tensor sub-field using transformation tensorField
193  (
194  const tensorField& st,
195  const labelList& cellMap
196  ) const;
197 
198  //- Transform vectorField using transformation tensorField and return
199  // symmetrical tensorField
201  (
202  const vectorField& st
203  ) const;
204 
205  //- Transform vector using transformation tensor and return
206  // symmetrical tensor
207  virtual symmTensor transformVector(const vector& st) const;
208 
209 
210  // Write
211 
212  //- Write
213  virtual void write(Ostream&) const;
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #endif
224 
225 // ************************************************************************* //
Abstract base class for coordinate rotation.
A coordinateRotation defined in the z-x-y Euler convention.
virtual const vector e2() const
Return local Cartesian y-axis in global coordinates.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual const vector e1() const
Return local Cartesian x-axis in global coordinates.
Vector< Cmpt > x() const
Definition: TensorI.H:289
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Vector< Cmpt > y() const
Definition: TensorI.H:296
virtual void write(Ostream &) const
Write.
virtual const vector e3() const
Return local Cartesian z-axis in global coordinates.
virtual const tensor & R() const
Return local-to-global transformation tensor.
TypeName("EulerRotation")
Runtime type information.
Vector< Cmpt > z() const
Definition: TensorI.H:303
virtual void updateCells(const polyMesh &, const labelList &)
Update the rotation for a list of cells.
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual const tensor & Rtr() const
Return global-to-local transformation tensor.
virtual const tensorField & Tr() const
Return transformation tensor field.
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
virtual void clear()
Reset rotation to an identity rotation.
Namespace for OpenFOAM.
static const SphericalTensor I
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.