STARCDCoordinateRotation.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "STARCDCoordinateRotation.H"
00028
00029 #include "Switch.H"
00030 #include "mathematicalConstants.H"
00031 #include "addToRunTimeSelectionTable.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(STARCDCoordinateRotation, 0);
00038 addToRunTimeSelectionTable
00039 (
00040 coordinateRotation,
00041 STARCDCoordinateRotation,
00042 dictionary
00043 );
00044 }
00045
00046
00047
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
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