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