Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / coordinateSystems / coordinateRotation / EulerCoordinateRotation.C
blob99037d65b72e203e66b7df700b8f68b62d811fa3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "EulerCoordinateRotation.H"
29 #include "Switch.H"
30 #include "mathematicalConstants.H"
31 #include "dictionary.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
38     defineTypeNameAndDebug(EulerCoordinateRotation, 0);
39     addToRunTimeSelectionTable
40     (
41         coordinateRotation,
42         EulerCoordinateRotation,
43         dictionary
44     );
47 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
49 void Foam::EulerCoordinateRotation::calcTransform
51     const scalar phiAngle,
52     const scalar thetaAngle,
53     const scalar psiAngle,
54     const bool inDegrees
57     scalar phi = phiAngle;
58     scalar theta = thetaAngle;
59     scalar psi = psiAngle;
61     if (inDegrees)
62     {
63         phi   *= mathematicalConstant::pi/180.0;
64         theta *= mathematicalConstant::pi/180.0;
65         psi   *= mathematicalConstant::pi/180.0;
66     }
68     tensor::operator=
69     (
70         tensor
71         (
72             cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
73             -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
74             sin(phi)*sin(theta),
76             cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
77             cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
78             -cos(phi)*sin(theta),
80             sin(psi)*sin(theta),
81             cos(psi)*sin(theta),
82             cos(theta)
83         )
84     );
88 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
90 Foam::EulerCoordinateRotation::EulerCoordinateRotation()
92     coordinateRotation()
96 Foam::EulerCoordinateRotation::EulerCoordinateRotation
98     const vector& phiThetaPsi,
99     const bool inDegrees
102     coordinateRotation()
104     calcTransform
105     (
106         phiThetaPsi.component(vector::X),
107         phiThetaPsi.component(vector::Y),
108         phiThetaPsi.component(vector::Z),
109         inDegrees
110     );
114 Foam::EulerCoordinateRotation::EulerCoordinateRotation
116     const scalar phiAngle,
117     const scalar thetaAngle,
118     const scalar psiAngle,
119     const bool inDegrees
122     coordinateRotation()
124     calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees);
128 Foam::EulerCoordinateRotation::EulerCoordinateRotation
130     const dictionary& dict
133     coordinateRotation()
135     vector rotation(dict.lookup("rotation"));
137     calcTransform
138     (
139         rotation.component(vector::X),
140         rotation.component(vector::Y),
141         rotation.component(vector::Z),
142         dict.lookupOrDefault<Switch>("degrees", true)
143     );
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //