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-2017 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 
143  //- Return local-to-global transformation tensor
144  virtual const tensor& R() const
145  {
146  return R_;
147  }
148 
149  //- Return global-to-local transformation tensor
150  virtual const tensor& Rtr() const
151  {
152  return Rtr_;
153  }
154 
155  //- Return local Cartesian x-axis in global coordinates
156  virtual const vector e1() const
157  {
158  return Rtr_.x();
159  }
160 
161  //- Return local Cartesian y-axis in global coordinates
162  virtual const vector e2() const
163  {
164  return Rtr_.y();
165  }
166 
167  //- Return local Cartesian z-axis in global coordinates
168  virtual const vector e3() const
169  {
170  return Rtr_.z();
171  }
172 
173  //- Return transformation tensor field
174  virtual const tensorField& Tr() const;
175 
176  //- Transform vectorField using transformation tensor field
177  virtual tmp<vectorField> transform(const vectorField& st) const;
178 
179  //- Transform vector using transformation tensor
180  virtual vector transform(const vector& st) const;
181 
182  //- Inverse transform vectorField using transformation tensor field
183  virtual tmp<vectorField> invTransform(const vectorField& st) const;
184 
185  //- Inverse transform vector using transformation tensor
186  virtual vector invTransform(const vector& st) const;
187 
188  //- Transform tensor field using transformation tensorField
189  virtual tmp<tensorField> transformTensor(const tensorField& st) const;
190 
191  //- Transform tensor using transformation tensorField
192  virtual tensor transformTensor(const tensor& st) const;
193 
194  //- Transform tensor sub-field using transformation tensorField
196  (
197  const tensorField& st,
198  const labelList& cellMap
199  ) const;
200 
201  //- Transform vectorField using transformation tensorField and return
202  // symmetric tensorField
204  (
205  const vectorField& st
206  ) const;
207 
208  //- Transform vector using transformation tensor and return
209  // symmetric tensor
210  virtual symmTensor transformVector(const vector& st) const;
211 
212 
213  // Member Operators
214 
215  //- Assign from dictionary
216  void operator=(const dictionary&);
217 
218 
219  // Write
220 
221  //- Write
222  virtual void write(Ostream&) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
axesRotation()
Construct null.
Definition: axesRotation.C:108
Abstract base class for coordinate rotation.
virtual const tensor & Rtr() const
Return global-to-local transformation tensor.
Definition: axesRotation.H:149
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
Vector< Cmpt > x() const
Definition: TensorI.H:279
virtual ~axesRotation()
Destructor.
Definition: axesRotation.H:125
Vector< Cmpt > y() const
Definition: TensorI.H:286
virtual const vector e2() const
Return local Cartesian y-axis in global coordinates.
Definition: axesRotation.H:161
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
Definition: axesRotation.C:185
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
Definition: axesRotation.C:230
virtual const tensor & R() const
Return local-to-global transformation tensor.
Definition: axesRotation.H:143
Vector< Cmpt > z() const
Definition: TensorI.H:293
TypeName("axesRotation")
Runtime type information.
virtual const vector e3() const
Return local Cartesian z-axis in global coordinates.
Definition: axesRotation.H:167
virtual const tensorField & Tr() const
Return transformation tensor field.
Definition: axesRotation.C:162
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
Definition: axesRotation.C:170
virtual const vector e1() const
Return local Cartesian x-axis in global coordinates.
Definition: axesRotation.H:155
void operator=(const dictionary &)
Assign from dictionary.
Definition: axesRotation.C:256
virtual void write(Ostream &) const
Write.
Definition: axesRotation.C:299
autoPtr< axesRotation > clone() const
Return clone.
Definition: axesRotation.H:118
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
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:53
Registry of regIOobjects.
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Definition: axesRotation.C:200
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