Report patch name instead of index in debug
[foam-extend-3.2.git] / src / foam / coordinateSystems / ellipticCylindricalCS.C
blobae56a5326c41af695ae4969c03057e04bd6f4228
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ellipticCylindricalCS.H"
28 #include "Switch.H"
29 #include "mathematicalConstants.H"
30 #include "boundBox.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
37     defineTypeNameAndDebug(ellipticCylindricalCS, 0);
38     addToRunTimeSelectionTable
39     (
40         coordinateSystem,
41         ellipticCylindricalCS,
42         dictionary
43     );
47 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
49 Foam::ellipticCylindricalCS::ellipticCylindricalCS(const bool inDegrees)
51     coordinateSystem(),
52     a_(0),
53     inDegrees_(inDegrees)
57 Foam::ellipticCylindricalCS::ellipticCylindricalCS
59     const coordinateSystem& cs,
60     const bool inDegrees
63     coordinateSystem(cs),
64     a_(0),
65     inDegrees_(inDegrees)
69 Foam::ellipticCylindricalCS::ellipticCylindricalCS
71     const word& name,
72     const coordinateSystem& cs,
73     const bool inDegrees
76     coordinateSystem(name, cs),
77     a_(0),
78     inDegrees_(inDegrees)
82 Foam::ellipticCylindricalCS::ellipticCylindricalCS
84     const word& name,
85     const point& origin,
86     const coordinateRotation& cr,
87     const scalar a,
88     const bool inDegrees
91     coordinateSystem(name, origin, cr),
92     a_(a),
93     inDegrees_(inDegrees)
97 Foam::ellipticCylindricalCS::ellipticCylindricalCS
99     const word& name,
100     const point& origin,
101     const vector& axis,
102     const vector& direction,
103     const scalar a,
104     const bool inDegrees
107     coordinateSystem(name, origin, axis, direction),
108     a_(a),
109     inDegrees_(inDegrees)
113 Foam::ellipticCylindricalCS::ellipticCylindricalCS
115     const word& name,
116     const dictionary& dict
119     coordinateSystem(name, dict),
120     a_(readScalar(dict.lookup("a"))),
121     inDegrees_(dict.lookupOrDefault<Switch>("degrees", true))
125 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
127 Foam::coordinateSystem::spanInfo
128 Foam::ellipticCylindricalCS::spanLimited() const
130     spanInfo b(Pair<bool>(true, true));
132     // Upper bound or r is unlimited
133     b[0] = Pair<bool>(true, false);
135     // z is unlimited
136     b[2] = Pair<bool>(false, false);
138     return b;
142 Foam::boundBox Foam::ellipticCylindricalCS::spanBounds() const
144     return boundBox
145     (
146         vector
147         (
148             0,
149             ( inDegrees_ ? -180.0 : -mathematicalConstant::pi ),
150             -GREAT
151         ),
152         vector
153         (
154             GREAT,
155             ( inDegrees_ ? 180.0 : mathematicalConstant::pi ),
156             GREAT
157         )
158     );
162 bool Foam::ellipticCylindricalCS::inDegrees() const
164     return inDegrees_;
168 Foam::Switch& Foam::ellipticCylindricalCS::inDegrees()
170     return inDegrees_;
174 Foam::vector Foam::ellipticCylindricalCS::localToGlobal
176     const vector& local,
177     bool translate
178 ) const
180     // Notation: u = local.x() v = local.y() z = local.z();
181     scalar theta =
182         local.y()*( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 );
184     return coordinateSystem::localToGlobal
185     (
186         vector
187         (
188             a_*cosh(local.x())*cos(theta),
189             a_*sinh(local.x())*sin(theta),
190             local.z()
191         ),
192         translate
193     );
196 Foam::tmp<Foam::vectorField> Foam::ellipticCylindricalCS::localToGlobal
198     const vectorField& local,
199     bool translate
200 ) const
202     scalarField theta =
203         local.component(vector::Y)*
204         ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 );
206     vectorField lc(local.size());
207     lc.replace
208     (
209         vector::X,
210         a_*cosh(local.component(vector::X))*cos(theta)
211     );
213     lc.replace
214     (
215         vector::Y,
216         a_*sinh(local.component(vector::X))*sin(theta)
217     );
219     lc.replace
220     (
221         vector::Z,
222         local.component(vector::Z)
223     );
225     return coordinateSystem::localToGlobal(lc, translate);
229 Foam::vector Foam::ellipticCylindricalCS::globalToLocal
231     const vector& global,
232     bool translate
233 ) const
235     notImplemented
236     (
237         "ellipticCylindricalCS::globalToLocal(const vector&, bool) const"
238     );
240     return vector::zero;
243 Foam::tmp<Foam::vectorField> Foam::ellipticCylindricalCS::globalToLocal
245     const vectorField& global,
246     bool translate
247 ) const
249     notImplemented
250     (
251         "ellipticCylindricalCS::globalToLocal(const vectorField&, bool) const"
252     );
254     return tmp<vectorField>(vectorField::null());
258 void Foam::ellipticCylindricalCS::write(Ostream& os) const
260     coordinateSystem::write(os);
261     os << "inDegrees: " << inDegrees() << endl;
265 void Foam::ellipticCylindricalCS::writeDict(Ostream& os, bool subDict) const
267     if (subDict)
268     {
269         os  << indent << nl
270             << indent << token::BEGIN_BLOCK << incrIndent << nl;
271     }
273     coordinateSystem::writeDict(os, false);
274     os.writeKeyword("inDegrees") << inDegrees_ << token::END_STATEMENT << nl;
276     if (subDict)
277     {
278         os << decrIndent << indent << token::END_BLOCK << endl;
279     }
283 // ************************************************************************* //