1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 "cylindricalCS.H"
31 #include "mathematicalConstants.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(cylindricalCS, 0);
39 addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary);
40 addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origRotation);
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 Foam::cylindricalCS::cylindricalCS(const bool inDegrees)
53 Foam::cylindricalCS::cylindricalCS
55 const coordinateSystem& cs,
64 Foam::cylindricalCS::cylindricalCS
67 const coordinateSystem& cs,
71 coordinateSystem(name, cs),
76 Foam::cylindricalCS::cylindricalCS
80 const coordinateRotation& cr,
84 coordinateSystem(name, origin, cr),
89 Foam::cylindricalCS::cylindricalCS
98 coordinateSystem(name, origin, axis, dirn),
103 Foam::cylindricalCS::cylindricalCS
106 const dictionary& dict
109 coordinateSystem(name, dict),
110 inDegrees_(dict.lookupOrDefault<Switch>("degrees", true))
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 bool Foam::cylindricalCS::inDegrees() const
122 bool& Foam::cylindricalCS::inDegrees()
128 Foam::vector Foam::cylindricalCS::localToGlobal
136 local.y() * ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
139 return coordinateSystem::localToGlobal
141 vector(local.x()*cos(theta), local.x()*sin(theta), local.z()),
147 Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal
149 const vectorField& local,
155 local.component(vector::Y)
156 * ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
160 vectorField lc(local.size());
161 lc.replace(vector::X, local.component(vector::X)*cos(theta));
162 lc.replace(vector::Y, local.component(vector::X)*sin(theta));
163 lc.replace(vector::Z, local.component(vector::Z));
165 return coordinateSystem::localToGlobal(lc, translate);
169 Foam::vector Foam::cylindricalCS::globalToLocal
171 const vector& global,
175 const vector lc = coordinateSystem::globalToLocal(global, translate);
179 sqrt(sqr(lc.x()) + sqr(lc.y())),
184 ) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 ),
190 Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
192 const vectorField& global,
196 const vectorField lc =
197 coordinateSystem::globalToLocal(global, translate);
199 tmp<vectorField> tresult(new vectorField(lc.size()));
200 vectorField& result = tresult();
205 sqrt(sqr(lc.component(vector::X)) + sqr(lc.component(vector::Y)))
213 lc.component(vector::Y),
214 lc.component(vector::X)
215 ) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 )
218 result.replace(vector::Z, lc.component(vector::Z));
224 // ************************************************************************* //