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  //- Construct as copy
125 
126  //- Return clone
128  {
130  (
132  (
133  *this
134  )
135  );
136  }
137 
138 
139  // Member Functions
140 
141  //- Reset rotation to an identity rotation
142  virtual void clear()
143  {
146  }
147 
148  //- Update the rotation for a list of cells
149  virtual void updateCells(const polyMesh&, const labelList&)
150  {
151  // do nothing
152  }
153 
154  //- Return local-to-global transformation tensor
155  virtual const tensor& R() const
156  {
157  return R_;
158  }
159 
160  //- Return global-to-local transformation tensor
161  virtual const tensor& Rtr() const
162  {
163  return Rtr_;
164  };
165 
166  //- Return local Cartesian x-axis
167  virtual const vector e1() const
168  {
169  return R_.x();
170  }
171 
172  //- Return local Cartesian y-axis
173  virtual const vector e2() const
174  {
175  return R_.y();
176  }
177 
178  //- Return local Cartesian z-axis
179  virtual const vector e3() const
180  {
181  return R_.z();
182  }
183 
184  //- Return transformation tensor field
185  virtual const tensorField& Tr() const;
186 
187  //- Transform vectorField using transformation tensor field
188  virtual tmp<vectorField> transform(const vectorField& st) const;
189 
190  //- Transform vector using transformation tensor
191  virtual vector transform(const vector& st) const;
192 
193  //- Inverse transform vectorField using transformation tensor field
194  virtual tmp<vectorField> invTransform(const vectorField& st) const;
195 
196  //- Inverse transform vector using transformation tensor
197  virtual vector invTransform(const vector& st) const;
198 
199  //- Transform tensor field using transformation tensorField
200  virtual tmp<tensorField> transformTensor(const tensorField& st) const;
201 
202  //- Transform tensor using transformation tensorField
203  virtual tensor transformTensor(const tensor& st) const;
204 
205  //- Transform tensor sub-field using transformation tensorField
207  (
208  const tensorField& st,
209  const labelList& cellMap
210  ) const;
211 
212  //- Transform vectorField using transformation tensorField and return
213  // symmetrical tensorField
215  (
216  const vectorField& st
217  ) const;
218 
219  //- Transform vector using transformation tensor and return
220  // symmetrical tensor
221  virtual symmTensor transformVector(const vector& st) const;
222 
223 
224  // Write
225 
226  //- Write
227  virtual void write(Ostream&) const;
228 };
229 
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
Foam::EulerCoordinateRotation::calcTransform
void calcTransform(const scalar phiAngle, const scalar thetaAngle, const scalar psiAngle, const bool inDegrees=true)
Calculate transformation tensor.
Definition: EulerCoordinateRotation.C:153
Foam::EulerCoordinateRotation::e3
virtual const vector e3() const
Return local Cartesian z-axis.
Definition: EulerCoordinateRotation.H:178
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::EulerCoordinateRotation::clone
autoPtr< coordinateRotation > clone() const
Return clone.
Definition: EulerCoordinateRotation.H:126
Foam::SymmTensor< scalar >
Foam::EulerCoordinateRotation::e2
virtual const vector e2() const
Return local Cartesian y-axis.
Definition: EulerCoordinateRotation.H:172
Foam::Tensor::y
Vector< Cmpt > y() const
Definition: TensorI.H:128
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::EulerCoordinateRotation::R
virtual const tensor & R() const
Return local-to-global transformation tensor.
Definition: EulerCoordinateRotation.H:154
Foam::EulerCoordinateRotation::transform
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
Definition: EulerCoordinateRotation.C:68
Foam::EulerCoordinateRotation::transformTensor
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Definition: EulerCoordinateRotation.C:95
Foam::EulerCoordinateRotation::Rtr_
tensor Rtr_
Global-to-Local transformation tensor.
Definition: EulerCoordinateRotation.H:74
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::EulerCoordinateRotation::invTransform
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
Definition: EulerCoordinateRotation.C:78
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::EulerCoordinateRotation::Tr
virtual const tensorField & Tr() const
Return transformation tensor field.
Definition: EulerCoordinateRotation.C:87
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::coordinateRotation
Abstract base class for coordinate rotation.
Definition: coordinateRotation.H:68
Foam::EulerCoordinateRotation::EulerCoordinateRotation
EulerCoordinateRotation()
Construct null.
Definition: EulerCoordinateRotation.C:195
Foam::EulerCoordinateRotation::write
virtual void write(Ostream &) const
Write.
Definition: EulerCoordinateRotation.C:287
Foam::EulerCoordinateRotation::updateCells
virtual void updateCells(const polyMesh &, const labelList &)
Update the rotation for a list of cells.
Definition: EulerCoordinateRotation.H:148
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::EulerCoordinateRotation::Rtr
virtual const tensor & Rtr() const
Return global-to-local transformation tensor.
Definition: EulerCoordinateRotation.H:160
Foam::EulerCoordinateRotation::e1
virtual const vector e1() const
Return local Cartesian x-axis.
Definition: EulerCoordinateRotation.H:166
Foam::EulerCoordinateRotation::clear
virtual void clear()
Reset rotation to an identity rotation.
Definition: EulerCoordinateRotation.H:141
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Tensor::z
Vector< Cmpt > z() const
Definition: TensorI.H:135
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::Tensor::x
Vector< Cmpt > x() const
Definition: TensorI.H:121
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::EulerCoordinateRotation
A coordinateRotation defined in the z-x-y Euler convention.
Definition: EulerCoordinateRotation.H:63
coordinateRotation.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::EulerCoordinateRotation::TypeName
TypeName("EulerRotation")
Runtime type information.
Foam::SphericalTensor::I
static const SphericalTensor I
Definition: SphericalTensor.H:78
Foam::EulerCoordinateRotation::R_
tensor R_
Local-to-global transformation tensor.
Definition: EulerCoordinateRotation.H:71
Foam::EulerCoordinateRotation::transformVector
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
Definition: EulerCoordinateRotation.C:126