axesRotation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 from 2 axes
104  axesRotation(const vector& axis, const vector& dir);
105 
106  //- Construct from components
107  axesRotation(const tensor& R);
108 
109  //- Construct from dictionary
110  axesRotation(const dictionary&);
111 
112  //- Construct from dictionary and list of points
114 
115  //- Construct and return a clone
116  virtual autoPtr<coordinateRotation> clone() const
117  {
118  return autoPtr<coordinateRotation>(new axesRotation(*this));
119  }
120 
121 
122  //- Destructor
123  virtual ~axesRotation()
124  {}
125 
126 
127  // Member Functions
128 
129  //- Update the rotation for a list of points
130  virtual void updatePoints(const UList<vector>& points)
131  {}
132 
133  //- Return local-to-global transformation tensor
134  virtual const tensor& R() const
135  {
136  return R_;
137  }
138 
139  //- Return local Cartesian x-axis in global coordinates
140  virtual const vector e1() const
141  {
142  return Rtr_.x();
143  }
144 
145  //- Return local Cartesian y-axis in global coordinates
146  virtual const vector e2() const
147  {
148  return Rtr_.y();
149  }
150 
151  //- Return local Cartesian z-axis in global coordinates
152  virtual const vector e3() const
153  {
154  return Rtr_.z();
155  }
156 
157  //- Transform vector using transformation tensor
158  virtual vector transform(const vector& v) const;
159 
160  //- Transform vectorField using transformation tensor field
161  virtual tmp<vectorField> transform(const vectorField& tf) const;
162 
163  //- Inverse transform vector using transformation tensor
164  virtual vector invTransform(const vector& v) const;
165 
166  //- Inverse transform vectorField using transformation tensor field
167  virtual tmp<vectorField> invTransform(const vectorField& vf) const;
168 
169  //- Transform tensor using transformation tensorField
170  virtual tensor transform(const vector& p, const tensor& t) const;
171 
172  //- Transform tensor field using transformation tensorField
173  virtual tmp<tensorField> transform(const tensorField& tf) const;
174 
175  //- Transform diagTensor masquerading as a vector using transformation
176  // tensor and return symmTensor
178  (
179  const vector& p,
180  const vector& v
181  ) const;
182 
183  //- Transform diagTensorField masquerading as a vectorField
184  // using transformation tensorField and return symmTensorField
186  (
187  const vectorField& vf
188  ) const;
189 
190 
191  // Member Operators
192 
193  //- Assign from dictionary
194  void operator=(const dictionary&);
195 
196 
197  // Write
198 
199  //- Write
200  virtual void write(Ostream&) const;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Vector< Cmpt > z() const
Definition: TensorI.H:303
Vector< Cmpt > y() const
Definition: TensorI.H:296
Vector< Cmpt > x() const
Definition: TensorI.H:289
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:74
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A coordinate rotation specified using global axis.
Definition: axesRotation.H:67
virtual const vector e2() const
Return local Cartesian y-axis in global coordinates.
Definition: axesRotation.H:145
virtual void write(Ostream &) const
Write.
Definition: axesRotation.C:223
axesRotation(const vector &axis, const vector &dir)
Construct from 2 axes.
Definition: axesRotation.C:104
virtual autoPtr< coordinateRotation > clone() const
Construct and return a clone.
Definition: axesRotation.H:115
virtual const tensor & R() const
Return local-to-global transformation tensor.
Definition: axesRotation.H:133
TypeName("axesRotation")
Runtime type information.
virtual void updatePoints(const UList< vector > &points)
Update the rotation for a list of points.
Definition: axesRotation.H:129
virtual vector transform(const vector &v) const
Transform vector using transformation tensor.
Definition: axesRotation.C:156
virtual const vector e1() const
Return local Cartesian x-axis in global coordinates.
Definition: axesRotation.H:139
virtual const vector e3() const
Return local Cartesian z-axis in global coordinates.
Definition: axesRotation.H:151
virtual symmTensor transformDiagTensor(const vector &p, const vector &v) const
Transform diagTensor masquerading as a vector using transformation.
Definition: axesRotation.C:214
void operator=(const dictionary &)
Assign from dictionary.
Definition: axesRotation.C:233
virtual ~axesRotation()
Destructor.
Definition: axesRotation.H:122
virtual vector invTransform(const vector &v) const
Inverse transform vector using transformation tensor.
Definition: axesRotation.C:171
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:160
A class for managing temporary objects.
Definition: tmp.H:55
const tensorField & tf
const pointField & points
Namespace for OpenFOAM.
Macros to ease declaration of run-time selection tables.
volScalarField & p