OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "STARCDCoordinateRotation.H"
00028 
00029 #include "Switch.H"
00030 #include "mathematicalConstants.H"
00031 #include "addToRunTimeSelectionTable.H"
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037     defineTypeNameAndDebug(STARCDCoordinateRotation, 0);
00038     addToRunTimeSelectionTable
00039     (
00040         coordinateRotation,
00041         STARCDCoordinateRotation,
00042         dictionary
00043     );
00044 }
00045 
00046 
00047 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00048 
00049 void Foam::STARCDCoordinateRotation::calcTransform
00050 (
00051     const scalar rotZ,
00052     const scalar rotX,
00053     const scalar rotY,
00054     const bool inDegrees
00055 )
00056 {
00057     scalar x = rotX;
00058     scalar y = rotY;
00059     scalar z = rotZ;
00060 
00061     if (inDegrees)
00062     {
00063         x *= mathematicalConstant::pi/180.0;
00064         y *= mathematicalConstant::pi/180.0;
00065         z *= mathematicalConstant::pi/180.0;
00066     }
00067 
00068     tensor::operator=
00069     (
00070         tensor
00071         (
00072             cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
00073             -cos(x)*sin(z),
00074             sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
00075 
00076             cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
00077             cos(x)*cos(z),
00078             sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
00079 
00080             -cos(x)*sin(y),
00081             sin(x),
00082             cos(x)*cos(y)
00083         )
00084     );
00085 }
00086 
00087 
00088 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00089 
00090 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation()
00091 :
00092     coordinateRotation()
00093 {}
00094 
00095 
00096 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
00097 (
00098     const vector& rotZrotXrotY,
00099     const bool inDegrees
00100 )
00101 :
00102     coordinateRotation()
00103 {
00104     calcTransform
00105     (
00106         rotZrotXrotY.component(vector::X),
00107         rotZrotXrotY.component(vector::Y),
00108         rotZrotXrotY.component(vector::Z),
00109         inDegrees
00110     );
00111 }
00112 
00113 
00114 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
00115 (
00116     const scalar rotZ,
00117     const scalar rotX,
00118     const scalar rotY,
00119     const bool inDegrees
00120 )
00121 :
00122     coordinateRotation()
00123 {
00124     calcTransform(rotZ, rotX, rotY, inDegrees);
00125 }
00126 
00127 
00128 Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
00129 (
00130     const dictionary& dict
00131 )
00132 :
00133     coordinateRotation()
00134 {
00135     vector rotation(dict.lookup("rotation"));
00136 
00137     calcTransform
00138     (
00139         rotation.component(vector::X),
00140         rotation.component(vector::Y),
00141         rotation.component(vector::Z),
00142         dict.lookupOrDefault<Switch>("degrees", true)
00143     );
00144 }
00145 
00146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Copyright © 2000-2009 OpenCFD Ltd