initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / coordinateSystems / coordinateRotation / coordinateRotation.H
blob429d6ef8effe190a914f140dafc7f49cc9c2459b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::coordinateRotation
28 Description
29     A coordinate rotation specified per local axes and the base class for
30     other rotation specifications
32     The rotation is defined by a combination of local vectors (e1/e2), (e2/e3)
33     or (e3/e1). Any nonorthogonality will be absorbed into the second vector.
35     For convenience, the dictionary constructor forms allow a few shortcuts:
36     - if the @c type is not otherwise specified, the type @c axes
37       is implicit
38     - if an axes specification (eg, e3/e1) is used, the coordinateRotation
39       sub-dictionary can be dropped.
41     Specifying the rotation by an EulerCoordinateRotation
42     (type "EulerRotation") or by a STARCDCoordinateRotation
43     (type "STARCDRotation") requires the coordinateRotation sub-dictionary.
45     @verbatim
46         coordinateRotation
47         {
48             type        STARCDRotation
49             rotation    (0 0 90);
50         }
51     @endverbatim
53     - the rotation angles are in degrees, unless otherwise explictly specified:
55     @verbatim
56         coordinateRotation
57         {
58             type        STARCDRotation
59             degrees     false;
60             rotation    (0 0 3.141592654);
61         }
62     @endverbatim
64 Deprecated
65     Specifying the local vectors as an @c axis (corresponding to e3) and a
66     @c direction (corresponding to e1), is allowed for backwards
67     compatibility, but this terminology is generally a bit confusing.
69 \*---------------------------------------------------------------------------*/
71 #ifndef coordinateRotation_H
72 #define coordinateRotation_H
74 #include "vector.H"
75 #include "tensor.H"
76 #include "dictionary.H"
77 #include "runTimeSelectionTables.H"
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 namespace Foam
84 /*---------------------------------------------------------------------------*\
85                     Class coordinateRotation Declaration
86 \*---------------------------------------------------------------------------*/
88 class coordinateRotation
90     public tensor
92     // Private data
94         //- the combination of local axes to be used
95         enum axisOrder
96         {
97             e1e2,
98             e2e3,
99             e3e1
100         };
102     // Private Member Functions
104         //- Calculate transformation tensor
105         void calcTransform
106         (
107             const vector& axis1,
108             const vector& axis2,
109             const axisOrder& order = e3e1
110         );
112 public:
114     //- Runtime type information
115     TypeName("coordinateRotation");
117     // Constructors
119         //- Construct null
120         coordinateRotation();
122         //- Construct from 2 axes
123         coordinateRotation
124         (
125             const vector& axis,
126             const vector& dir
127         );
129         //- Construct from dictionary
130         coordinateRotation(const dictionary&);
132         //- Return clone
133         autoPtr<coordinateRotation> clone() const
134         {
135             return autoPtr<coordinateRotation>(new coordinateRotation(*this));
136         }
138     // Declare run-time constructor selection table
140         declareRunTimeSelectionTable
141         (
142             autoPtr,
143             coordinateRotation,
144             dictionary,
145             (
146                 const dictionary& dict
147             ),
148             (dict)
149         );
152     // Selectors
154         //- Select constructed from Istream
155         static autoPtr<coordinateRotation> New
156         (
157             const dictionary& dict
158         );
161     // Destructor
163         virtual ~coordinateRotation()
164         {}
167     // Member Functions
169         //- Return local-to-global transformation tensor
170         const tensor& R() const
171         {
172             return (*this);
173         }
175         //- Return local Cartesian x-axis
176         vector& e1() const
177         {
178             return tensor::T().x();
179         }
181         //- Return local Cartesian y-axis
182         vector& e2() const
183         {
184             return tensor::T().y();
185         }
187         //- Return local Cartesian z-axis
188         vector& e3() const
189         {
190             return tensor::T().z();
191         }
194     // Member Operators
196         //- assign from dictionary
197         void operator=(const dictionary&);
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 } // End namespace Foam
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 #endif
210 // ************************************************************************* //