FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

STARCDCoordinateRotation.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "STARCDCoordinateRotation.H"
00027 
00028 #include <OpenFOAM/Switch.H>
00029 #include <OpenFOAM/mathematicalConstants.H>
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036     defineTypeNameAndDebug(STARCDCoordinateRotation, 0);
00037     addToRunTimeSelectionTable
00038     (
00039         coordinateRotation,
00040         STARCDCoordinateRotation,
00041         dictionary
00042     );
00043 }
00044 
00045 
00046 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00047 
00048 void Foam::STARCDCoordinateRotation::calcTransform
00049 (
00050     const scalar rotZ,
00051     const scalar rotX,
00052     const scalar rotY,
00053     const bool inDegrees
00054 )
00055 {
00056     scalar x = rotX;
00057     scalar y = rotY;
00058     scalar z = rotZ;
00059 
00060     if (inDegrees)
00061     {
00062         x *= mathematicalConstant::pi/180.0;
00063         y *= mathematicalConstant::pi/180.0;
00064         z *= mathematicalConstant::pi/180.0;
00065     }
00066 
00067     tensor::operator=
00068     (
00069         tensor
00070         (
00071             cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
00072             -cos(x)*sin(z),
00073             sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
00074 
00075             cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
00076             cos(x)*cos(z),
00077             sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
00078 
00079             -cos(x)*sin(y),
00080             sin(x),
00081             cos(x)*cos(y)
00082         )
00083     );
00084 }
00085 
00086 
00087 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00088 
00089 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation()
00090 :
00091     coordinateRotation()
00092 {}
00093 
00094 
00095 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
00096 (
00097     const vector& rotZrotXrotY,
00098     const bool inDegrees
00099 )
00100 :
00101     coordinateRotation()
00102 {
00103     calcTransform
00104     (
00105         rotZrotXrotY.component(vector::X),
00106         rotZrotXrotY.component(vector::Y),
00107         rotZrotXrotY.component(vector::Z),
00108         inDegrees
00109     );
00110 }
00111 
00112 
00113 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
00114 (
00115     const scalar rotZ,
00116     const scalar rotX,
00117     const scalar rotY,
00118     const bool inDegrees
00119 )
00120 :
00121     coordinateRotation()
00122 {
00123     calcTransform(rotZ, rotX, rotY, inDegrees);
00124 }
00125 
00126 
00127 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
00128 (
00129     const dictionary& dict
00130 )
00131 :
00132     coordinateRotation()
00133 {
00134     vector rotation(dict.lookup("rotation"));
00135 
00136     calcTransform
00137     (
00138         rotation.component(vector::X),
00139         rotation.component(vector::Y),
00140         rotation.component(vector::Z),
00141         dict.lookupOrDefault<Switch>("degrees", true)
00142     );
00143 }
00144 
00145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines