EulerCoordinateRotation.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 | Copyright (C) 2011-2016 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 explictly 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  // do nothing
140  }
141 
142  //- Return local-to-global transformation tensor
143  virtual const tensor& R() const
144  {
145  return R_;
146  }
147 
148  //- Return global-to-local transformation tensor
149  virtual const tensor& Rtr() const
150  {
151  return Rtr_;
152  };
153 
154  //- Return local Cartesian x-axis in global coordinates
155  virtual const vector e1() const
156  {
157  return Rtr_.x();
158  }
159 
160  //- Return local Cartesian y-axis in global coordinates
161  virtual const vector e2() const
162  {
163  return Rtr_.y();
164  }
165 
166  //- Return local Cartesian z-axis in global coordinates
167  virtual const vector e3() const
168  {
169  return Rtr_.z();
170  }
171 
172  //- Return transformation tensor field
173  virtual const tensorField& Tr() const;
174 
175  //- Transform vectorField using transformation tensor field
176  virtual tmp<vectorField> transform(const vectorField& st) const;
177 
178  //- Transform vector using transformation tensor
179  virtual vector transform(const vector& st) const;
180 
181  //- Inverse transform vectorField using transformation tensor field
182  virtual tmp<vectorField> invTransform(const vectorField& st) const;
183 
184  //- Inverse transform vector using transformation tensor
185  virtual vector invTransform(const vector& st) const;
186 
187  //- Transform tensor field using transformation tensorField
188  virtual tmp<tensorField> transformTensor(const tensorField& st) const;
189 
190  //- Transform tensor using transformation tensorField
191  virtual tensor transformTensor(const tensor& st) const;
192 
193  //- Transform tensor sub-field using transformation tensorField
195  (
196  const tensorField& st,
197  const labelList& cellMap
198  ) const;
199 
200  //- Transform vectorField using transformation tensorField and return
201  // symmetrical tensorField
203  (
204  const vectorField& st
205  ) const;
206 
207  //- Transform vector using transformation tensor and return
208  // symmetrical tensor
209  virtual symmTensor transformVector(const vector& st) const;
210 
211 
212  // Write
213 
214  //- Write
215  virtual void write(Ostream&) const;
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
Abstract base class for coordinate rotation.
A coordinateRotation defined in the z-x-y Euler convention.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual const tensorField & Tr() const
Return transformation tensor field.
virtual const vector e2() const
Return local Cartesian y-axis in global coordinates.
virtual const vector e1() const
Return local Cartesian x-axis in global coordinates.
Vector< Cmpt > x() const
Definition: TensorI.H:279
Vector< Cmpt > y() const
Definition: TensorI.H:286
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
TypeName("EulerRotation")
Runtime type information.
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
virtual void updateCells(const polyMesh &, const labelList &)
Update the rotation for a list of cells.
Vector< Cmpt > z() const
Definition: TensorI.H:293
virtual const vector e3() const
Return local Cartesian z-axis in global coordinates.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void write(Ostream &) const
Write.
virtual const tensor & R() const
Return local-to-global transformation tensor.
virtual const tensor & Rtr() const
Return global-to-local transformation tensor.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A class for managing temporary objects.
Definition: PtrList.H:54
Registry of regIOobjects.
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
virtual void clear()
Reset rotation to an identity rotation.
Namespace for OpenFOAM.
static const SphericalTensor I