FreeFOAM The Cross-Platform CFD Toolkit
STARCDCoordinateRotation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 #include <OpenFOAM/Switch.H>
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(STARCDCoordinateRotation, 0);
38  (
39  coordinateRotation,
40  STARCDCoordinateRotation,
41  dictionary
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 void Foam::STARCDCoordinateRotation::calcTransform
49 (
50  const scalar rotZ,
51  const scalar rotX,
52  const scalar rotY,
53  const bool inDegrees
54 )
55 {
56  scalar x = rotX;
57  scalar y = rotY;
58  scalar z = rotZ;
59 
60  if (inDegrees)
61  {
62  x *= mathematicalConstant::pi/180.0;
63  y *= mathematicalConstant::pi/180.0;
64  z *= mathematicalConstant::pi/180.0;
65  }
66 
68  (
69  tensor
70  (
71  cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
72  -cos(x)*sin(z),
73  sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
74 
75  cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
76  cos(x)*cos(z),
77  sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
78 
79  -cos(x)*sin(y),
80  sin(x),
81  cos(x)*cos(y)
82  )
83  );
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 
90 :
92 {}
93 
94 
96 (
97  const vector& rotZrotXrotY,
98  const bool inDegrees
99 )
100 :
102 {
103  calcTransform
104  (
105  rotZrotXrotY.component(vector::X),
106  rotZrotXrotY.component(vector::Y),
107  rotZrotXrotY.component(vector::Z),
108  inDegrees
109  );
110 }
111 
112 
114 (
115  const scalar rotZ,
116  const scalar rotX,
117  const scalar rotY,
118  const bool inDegrees
119 )
120 :
122 {
123  calcTransform(rotZ, rotX, rotY, inDegrees);
124 }
125 
126 
128 (
129  const dictionary& dict
130 )
131 :
133 {
134  vector rotation(dict.lookup("rotation"));
135 
136  calcTransform
137  (
138  rotation.component(vector::X),
139  rotation.component(vector::Y),
140  rotation.component(vector::Z),
141  dict.lookupOrDefault<Switch>("degrees", true)
142  );
143 }
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //