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-2014 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 \*---------------------------------------------------------------------------*/
49 
50 #ifndef EulerCoordinateRotation_H
51 #define EulerCoordinateRotation_H
52 
53 #include "coordinateRotation.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class EulerCoordinateRotation Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 :
66  public coordinateRotation
67 {
68 
69  // Private Member Data
70 
71  //- Local-to-global transformation tensor
72  tensor R_;
73 
74  //- Global-to-Local transformation tensor
75  tensor Rtr_;
76 
77 
78  // Private Member Functions
79 
80  //- Calculate transformation tensor
81  void calcTransform
82  (
83  const scalar phiAngle,
84  const scalar thetaAngle,
85  const scalar psiAngle,
86  const bool inDegrees=true
87  );
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("EulerRotation");
94 
95 
96  // Constructors
97 
98  //- Construct null
100 
101  //- Construct from rotation vector
103  (
104  const vector& phiThetaPsi,
105  const bool inDegrees=true
106  );
107 
108  //- Construct from components of rotation vector
110  (
111  const scalar phiAngle,
112  const scalar thetaAngle,
113  const scalar psiAngle,
114  const bool inDegrees=true
115  );
116 
117  //- Construct from dictionary
119 
120  //- Construct from dictionary and mesh
122 
123 
124  // Member Functions
125 
126  //- Reset rotation to an identity rotation
127  virtual void clear()
128  {
129  R_ = sphericalTensor::I;
130  Rtr_ = sphericalTensor::I;
131  }
132 
133  //- Update the rotation for a list of cells
134  virtual void updateCells(const polyMesh&, const labelList&)
135  {
136  // do nothing
137  }
138 
139  //- Return local-to-global transformation tensor
140  virtual const tensor& R() const
141  {
142  return R_;
143  }
144 
145  //- Return global-to-local transformation tensor
146  virtual const tensor& Rtr() const
147  {
148  return Rtr_;
149  };
150 
151  //- Return local Cartesian x-axis
152  virtual const vector e1() const
153  {
154  return R_.x();
155  }
156 
157  //- Return local Cartesian y-axis
158  virtual const vector e2() const
159  {
160  return R_.y();
161  }
162 
163  //- Return local Cartesian z-axis
164  virtual const vector e3() const
165  {
166  return R_.z();
167  }
168 
169  //- Return transformation tensor field
170  virtual const tensorField& Tr() const;
171 
172  //- Transform vectorField using transformation tensor field
173  virtual tmp<vectorField> transform(const vectorField& st) const;
174 
175  //- Transform vector using transformation tensor
176  virtual vector transform(const vector& st) const;
177 
178  //- Inverse transform vectorField using transformation tensor field
179  virtual tmp<vectorField> invTransform(const vectorField& st) const;
180 
181  //- Inverse transform vector using transformation tensor
182  virtual vector invTransform(const vector& st) const;
183 
184  //- Transform tensor field using transformation tensorField
185  virtual tmp<tensorField> transformTensor(const tensorField& st) const;
186 
187  //- Transform tensor using transformation tensorField
188  virtual tensor transformTensor(const tensor& st) const;
189 
190  //- Transform tensor sub-field using transformation tensorField
192  (
193  const tensorField& st,
194  const labelList& cellMap
195  ) const;
196 
197  //- Transform vectorField using transformation tensorField and return
198  // symmetrical tensorField
200  (
201  const vectorField& st
202  ) const;
203 
204  //- Transform vector using transformation tensor and return
205  // symmetrical tensor
206  virtual symmTensor transformVector(const vector& st) const;
207 
208 
209  // Write
210 
211  //- Write
212  virtual void write(Ostream&) const;
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
virtual const vector e1() const
Return local Cartesian x-axis.
virtual const tensor & Rtr() const
Return global-to-local transformation tensor.
virtual const vector e2() const
Return local Cartesian y-axis.
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
virtual const tensor & R() const
Return local-to-global transformation tensor.
virtual void updateCells(const polyMesh &, const labelList &)
Update the rotation for a list of cells.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Vector< Cmpt > x() const
Definition: TensorI.H:121
Namespace for OpenFOAM.
Vector< Cmpt > y() const
Definition: TensorI.H:128
virtual void clear()
Reset rotation to an identity rotation.
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
TypeName("EulerRotation")
Runtime type information.
Abstract base class for coordinate rotation.
Vector< Cmpt > z() const
Definition: TensorI.H:135
virtual const tensorField & Tr() const
Return transformation tensor field.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Registry of regIOobjects.
A coordinateRotation defined in the z-x-y Euler convention.
static const SphericalTensor I
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
A class for managing temporary objects.
Definition: PtrList.H:118
virtual const vector e3() const
Return local Cartesian z-axis.
virtual void write(Ostream &) const
Write.