axesRotation.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-2015 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::axesRotation
26 
27 Description
28  A coordinate rotation specified using global axis
29 
30  The rotation is defined by a combination of vectors (e1/e2), (e2/e3)
31  or (e3/e1). Any nonorthogonality will be absorbed into the second vector.
32 
33  \verbatim
34  axesRotation
35  {
36  type axesRotation;
37  e1 (1 0 0);
38  e2 (0 1 0);
39  }
40  \endverbatim
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef axesRotation_H
45 #define axesRotation_H
46 
47 #include "vector.H"
48 #include "coordinateRotation.H"
49 #include "dictionary.H"
50 #include "runTimeSelectionTables.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class axesRotation Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class axesRotation
62 :
63  public coordinateRotation
64 {
65  // Private data
66 
67  //- Local-to-Global transformation tensor
68  tensor R_;
69 
70  //- Global-to-Local transformation tensor
71  tensor Rtr_;
72 
73  //- The combination of local axes to be used
74  enum axisOrder
75  {
78  e3e1
79  };
80 
81  // Private Member Functions
82 
83  //- Calculate transformation tensor
84  void calcTransform
85  (
86  const vector& axis1,
87  const vector& axis2,
88  const axisOrder& order = e3e1
89  );
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("axesRotation");
96 
97  // Constructors
98 
99  //- Construct null
100  axesRotation();
101 
102  //- Construct from 2 axes
103  axesRotation(const vector& axis, const vector& dir);
104 
105  //- Construct from dictionary
106  axesRotation(const dictionary&);
107 
108  //- Construct from components
109  axesRotation(const tensor& R);
110 
111  //- Construct from dictionary and mesh
112  axesRotation(const dictionary&, const objectRegistry&);
113 
114  //- Construct as copy
115  axesRotation(const axesRotation&);
116 
117  //- Return clone
119  {
120  return autoPtr<coordinateRotation>(new axesRotation(*this));
121  }
122 
123 
124  //- Destructor
125  virtual ~axesRotation()
126  {}
127 
128 
129  // Member Functions
130 
131  //- Reset rotation to an identity rotation
132  virtual void clear()
133  {
136  }
137 
138  //- Update the rotation for a list of cells
139  virtual void updateCells(const polyMesh&, const labelList&)
140  {
141  // Do nothing
142  }
143 
144  //- Return local-to-global transformation tensor
145  virtual const tensor& R() const
146  {
147  return R_;
148  }
149 
150  //- Return global-to-local transformation tensor
151  virtual const tensor& Rtr() const
152  {
153  return Rtr_;
154  }
155 
156  //- Return local Cartesian x-axis
157  virtual const vector e1() const
158  {
159  return R_.x();
160  }
161 
162  //- Return local Cartesian y-axis
163  virtual const vector e2() const
164  {
165  return R_.y();
166  }
167 
168  //- Return local Cartesian z-axis
169  virtual const vector e3() const
170  {
171  return R_.z();
172  }
173 
174  //- Return transformation tensor field
175  virtual const tensorField& Tr() const;
176 
177  //- Transform vectorField using transformation tensor field
178  virtual tmp<vectorField> transform(const vectorField& st) const;
179 
180  //- Transform vector using transformation tensor
181  virtual vector transform(const vector& st) const;
182 
183  //- Inverse transform vectorField using transformation tensor field
184  virtual tmp<vectorField> invTransform(const vectorField& st) const;
185 
186  //- Inverse transform vector using transformation tensor
187  virtual vector invTransform(const vector& st) const;
188 
189  //- Transform tensor field using transformation tensorField
190  virtual tmp<tensorField> transformTensor(const tensorField& st) const;
191 
192  //- Transform tensor using transformation tensorField
193  virtual tensor transformTensor(const tensor& st) const;
194 
195  //- Transform tensor sub-field using transformation tensorField
197  (
198  const tensorField& st,
199  const labelList& cellMap
200  ) const;
201 
202  //- Transform vectorField using transformation tensorField and return
203  // symmetric tensorField
205  (
206  const vectorField& st
207  ) const;
208 
209  //- Transform vector using transformation tensor and return
210  // symmetric tensor
211  virtual symmTensor transformVector(const vector& st) const;
212 
213 
214  // Member Operators
215 
216  //- Assign from dictionary
217  void operator=(const dictionary&);
218 
219 
220  // Write
221 
222  //- Write
223  virtual void write(Ostream&) const;
224 };
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace Foam
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #endif
234 
235 // ************************************************************************* //
Foam::axesRotation::e3e1
@ e3e1
Definition: axesRotation.H:77
Foam::axesRotation::write
virtual void write(Ostream &) const
Write.
Definition: axesRotation.C:307
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::SymmTensor< scalar >
Foam::axesRotation::Rtr
virtual const tensor & Rtr() const
Return global-to-local transformation tensor.
Definition: axesRotation.H:150
Foam::axesRotation::invTransform
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
Definition: axesRotation.C:193
Foam::Tensor::y
Vector< Cmpt > y() const
Definition: TensorI.H:128
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::axesRotation
A coordinate rotation specified using global axis.
Definition: axesRotation.H:60
Foam::axesRotation::e2e3
@ e2e3
Definition: axesRotation.H:76
Foam::axesRotation::R_
tensor R_
Local-to-Global transformation tensor.
Definition: axesRotation.H:67
Foam::axesRotation::axesRotation
axesRotation()
Construct null.
Definition: axesRotation.C:108
Foam::axesRotation::transformVector
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
Definition: axesRotation.C:238
Foam::axesRotation::updateCells
virtual void updateCells(const polyMesh &, const labelList &)
Update the rotation for a list of cells.
Definition: axesRotation.H:138
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::axesRotation::e2
virtual const vector e2() const
Return local Cartesian y-axis.
Definition: axesRotation.H:162
Foam::axesRotation::R
virtual const tensor & R() const
Return local-to-global transformation tensor.
Definition: axesRotation.H:144
Foam::axesRotation::calcTransform
void calcTransform(const vector &axis1, const vector &axis2, const axisOrder &order=e3e1)
Calculate transformation tensor.
Definition: axesRotation.C:47
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::axesRotation::e1e2
@ e1e2
Definition: axesRotation.H:75
Foam::coordinateRotation
Abstract base class for coordinate rotation.
Definition: coordinateRotation.H:68
Foam::axesRotation::e1
virtual const vector e1() const
Return local Cartesian x-axis.
Definition: axesRotation.H:156
Foam::axesRotation::TypeName
TypeName("axesRotation")
Runtime type information.
Foam::axesRotation::Rtr_
tensor Rtr_
Global-to-Local transformation tensor.
Definition: axesRotation.H:70
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::axesRotation::Tr
virtual const tensorField & Tr() const
Return transformation tensor field.
Definition: axesRotation.C:170
Foam::axesRotation::~axesRotation
virtual ~axesRotation()
Destructor.
Definition: axesRotation.H:124
Foam::axesRotation::operator=
void operator=(const dictionary &)
Assign from dictionary.
Definition: axesRotation.C:264
Foam::axesRotation::axisOrder
axisOrder
The combination of local axes to be used.
Definition: axesRotation.H:73
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
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
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::axesRotation::e3
virtual const vector e3() const
Return local Cartesian z-axis.
Definition: axesRotation.H:168
dictionary.H
vector.H
Foam::axesRotation::transform
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
Definition: axesRotation.C:178
coordinateRotation.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::SphericalTensor::I
static const SphericalTensor I
Definition: SphericalTensor.H:78
Foam::axesRotation::transformTensor
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Definition: axesRotation.C:208
Foam::axesRotation::clear
virtual void clear()
Reset rotation to an identity rotation.
Definition: axesRotation.H:131
Foam::axesRotation::clone
autoPtr< coordinateRotation > clone() const
Return clone.
Definition: axesRotation.H:117