1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "cylindricalCS.H"
29 #include "mathematicalConstants.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(cylindricalCS, 0);
37 addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary);
38 addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origRotation);
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 Foam::cylindricalCS::cylindricalCS(const bool inDegrees)
51 Foam::cylindricalCS::cylindricalCS
53 const coordinateSystem& cs,
62 Foam::cylindricalCS::cylindricalCS
65 const coordinateSystem& cs,
69 coordinateSystem(name, cs),
74 Foam::cylindricalCS::cylindricalCS
78 const coordinateRotation& cr,
82 coordinateSystem(name, origin, cr),
87 Foam::cylindricalCS::cylindricalCS
96 coordinateSystem(name, origin, axis, dirn),
101 Foam::cylindricalCS::cylindricalCS
104 const dictionary& dict
107 coordinateSystem(name, dict),
108 inDegrees_(dict.lookupOrDefault("degrees", true))
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 bool Foam::cylindricalCS::inDegrees() const
120 bool& Foam::cylindricalCS::inDegrees()
126 Foam::vector Foam::cylindricalCS::localToGlobal
134 local.y()*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
137 return coordinateSystem::localToGlobal
139 vector(local.x()*cos(theta), local.x()*sin(theta), local.z()),
145 Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal
147 const vectorField& local,
153 local.component(vector::Y)
154 *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
158 vectorField lc(local.size());
159 lc.replace(vector::X, local.component(vector::X)*cos(theta));
160 lc.replace(vector::Y, local.component(vector::X)*sin(theta));
161 lc.replace(vector::Z, local.component(vector::Z));
163 return coordinateSystem::localToGlobal(lc, translate);
167 Foam::vector Foam::cylindricalCS::globalToLocal
169 const vector& global,
175 coordinateSystem::globalToLocal(global, translate)
180 sqrt(sqr(lc.x()) + sqr(lc.y())),
185 )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0),
191 Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
193 const vectorField& global,
199 coordinateSystem::globalToLocal(global, translate)
202 tmp<vectorField> tresult(new vectorField(lc.size()));
203 vectorField& result = tresult();
208 sqrt(sqr(lc.component(vector::X)) + sqr(lc.component(vector::Y)))
216 lc.component(vector::Y),
217 lc.component(vector::X)
218 )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0)
221 result.replace(vector::Z, lc.component(vector::Z));
227 // ************************************************************************* //