Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / coordinateSystems / coordinateRotation / STARCDCoordinateRotation.C
blob6dc2722d3c2ac1e98815d10c0c13db3d7adf0d49
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "STARCDCoordinateRotation.H"
28 #include "mathematicalConstants.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(STARCDCoordinateRotation, 0);
36     addToRunTimeSelectionTable
37     (
38         coordinateRotation,
39         STARCDCoordinateRotation,
40         dictionary
41     );
45 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
47 void Foam::STARCDCoordinateRotation::calcTransform
49     const scalar rotZ,
50     const scalar rotX,
51     const scalar rotY,
52     const bool inDegrees
55     scalar x = rotX;
56     scalar y = rotY;
57     scalar z = rotZ;
59     if (inDegrees)
60     {
61         x *= constant::mathematical::pi/180.0;
62         y *= constant::mathematical::pi/180.0;
63         z *= constant::mathematical::pi/180.0;
64     }
66     tensor::operator=
67     (
68         tensor
69         (
70             cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
71             -cos(x)*sin(z),
72             sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
74             cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
75             cos(x)*cos(z),
76             sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
78             -cos(x)*sin(y),
79             sin(x),
80             cos(x)*cos(y)
81         )
82     );
86 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
88 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation()
90     coordinateRotation()
94 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
96     const vector& rotZrotXrotY,
97     const bool inDegrees
100     coordinateRotation()
102     calcTransform
103     (
104         rotZrotXrotY.component(vector::X),
105         rotZrotXrotY.component(vector::Y),
106         rotZrotXrotY.component(vector::Z),
107         inDegrees
108     );
112 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
114     const scalar rotZ,
115     const scalar rotX,
116     const scalar rotY,
117     const bool inDegrees
120     coordinateRotation()
122     calcTransform(rotZ, rotX, rotY, inDegrees);
126 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
128     const dictionary& dict
131     coordinateRotation()
133     vector rotation(dict.lookup("rotation"));
135     calcTransform
136     (
137         rotation.component(vector::X),
138         rotation.component(vector::Y),
139         rotation.component(vector::Z),
140         dict.lookupOrDefault("degrees", true)
141     );
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //