1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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/>.
25 Foam::coordinateSystem
28 A cartesian coordinate system and the base class for other coordinate
29 system specifications.
31 All systems are defined by an origin point and a coordinateRotation.
32 For convenience, the dictionary constructor forms allow a few shortcuts:
33 - the default origin corresponds to <em>(0 0 0)</em>
34 - if the @c type is not otherwise specified, a Cartesian coordinateSystem
49 - if an axes specification (eg, e3/e1) is used, the coordinateRotation
50 sub-dictionary can be dropped.
53 flipped // the same, specified as axes
63 flipped // the same, using all the shortcuts
70 - if a sub-dictionary coordinateSystem is found within the dictionary, it
71 will be used. This provides a convenient means of embedding
72 coordinateSystem information in another dictionary.
73 This is used, for example, in the porousZones:
92 d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08);
93 f f [0 -1 0 0 0] (-1000 -1000 12.83);
99 - additionally, if the coordinateSystem points to a plain entry,
100 it can be used to reference one of the global coordinateSystems
107 coordinateSystem system_10;
111 d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08);
112 f f [0 -1 0 0 0] (-1000 -1000 12.83);
117 For this to work correctly, the coordinateSystem constructor must be
118 supplied with both a dictionary and an objectRegistry.
121 coordinateSystems and coordinateSystems::New
125 newCoordinateSystem.C
126 \*---------------------------------------------------------------------------*/
128 #ifndef coordinateSystem_H
129 #define coordinateSystem_H
135 #include "vectorField.H"
136 #include "pointField.H"
138 #include "coordinateRotation.H"
139 #include "objectRegistry.H"
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 // Forward declaration of friend functions and operators
149 /*---------------------------------------------------------------------------*\
150 Class coordinateSystem Declaration
151 \*---------------------------------------------------------------------------*/
153 class coordinateSystem
157 //- Name of coordinate system
161 mutable string note_;
164 mutable point origin_;
166 //- Local-to-Global transformation tensor
167 coordinateRotation R_;
169 //- Global-to-Local transformation tensor
175 // Protected Member Functions
177 //- Convert from local coordinate system to the global Cartesian system
178 // with optional translation for the origin
179 virtual vector localToGlobal(const vector&, bool translate) const;
181 //- Convert from local coordinate system to the global Cartesian system
182 // with optional translation for the origin
183 virtual tmp<vectorField> localToGlobal
189 //- Convert from global Cartesian system to the local coordinate system
190 // with optional translation for the origin
191 virtual vector globalToLocal(const vector&, bool translate) const;
193 //- Convert from global Cartesian system to the local coordinate system
194 // with optional translation for the origin
195 virtual tmp<vectorField> globalToLocal
204 //- Runtime type information
205 TypeName("coordinateSystem");
207 //- Type reporting on min-max bounds on coordinate span
208 typedef FixedList<Pair<bool>, 3> spanInfo;
213 //- Construct null. This is equivalent to an identity coordinateSystem
216 //- Construct copy with a different name
220 const coordinateSystem&
223 //- Construct from origin and rotation
228 const coordinateRotation&
231 //- Construct from origin and 2 axes
240 //- Construct from dictionary with a given name
241 coordinateSystem(const word& name, const dictionary&);
243 //- Construct from dictionary with default name
244 coordinateSystem(const dictionary&);
246 //- Construct from dictionary (default name)
247 // With the ability to reference global coordinateSystems
248 coordinateSystem(const dictionary&, const objectRegistry&);
250 //- Construct from Istream
251 // The Istream contains a word followed by a dictionary
252 coordinateSystem(Istream&);
255 virtual autoPtr<coordinateSystem> clone() const
257 return autoPtr<coordinateSystem>(new coordinateSystem(*this));
261 // Declare run-time constructor selection table
264 declareRunTimeSelectionTable
271 const dictionary& dict
276 declareRunTimeSelectionTable
284 const coordinateRotation& cr
293 //- Select constructed from dictionary
294 static autoPtr<coordinateSystem> New
300 //- Select constructed from origin and rotation
301 static autoPtr<coordinateSystem> New
303 const word& coordType,
306 const coordinateRotation&
309 //- Select constructed from Istream
310 static autoPtr<coordinateSystem> New(Istream& is);
315 virtual ~coordinateSystem();
320 // Global information about the coordinate system
322 //- Directions in which the span is limited
323 virtual spanInfo spanLimited() const;
326 virtual boundBox spanBounds() const;
332 const word& name() const
337 //- Return non-constant access to the optional note
343 //- Return the optional note
344 const string& note() const
350 const point& origin() const
355 //- Return coordinate rotation
356 const coordinateRotation& rotation() const
361 //- Return local-to-global transformation tensor
362 const tensor& R() const
367 //- Return local Cartesian x-axis
373 //- Return local Cartesian y-axis
379 //- Return local Cartesian z-axis
385 //- Return axis (e3: local Cartesian z-axis)
386 // @deprecated method e3 is preferred
392 //- Return direction (e1: local Cartesian x-axis)
393 // @deprecated method e1 is preferred
394 const vector direction() const
399 //- Return as dictionary of entries
400 // @param [in] ignoreType drop type (cartesian, cylindrical, etc)
401 // when generating the dictionary
402 virtual dictionary dict(bool ignoreType = false) const;
408 virtual void rename(const word& newName)
413 //- Edit access to origin
423 virtual void write(Ostream&) const;
426 virtual void writeDict(Ostream&, bool subDict = true) const;
431 //- Convert from position in local coordinate system to
432 // global Cartesian position
433 point globalPosition(const point& local) const
435 return localToGlobal(local, true);
438 //- Convert from position in local coordinate system to
439 // global Cartesian position
440 tmp<pointField> globalPosition(const pointField& local) const
442 return localToGlobal(local, true);
445 //- Convert from vector components in local coordinate system
446 // to global Cartesian vector
447 vector globalVector(const vector& local) const
449 return localToGlobal(local, false);
452 //- Convert from vector components in local coordinate system
453 // to global Cartesian vector
454 tmp<vectorField> globalVector(const vectorField& local) const
456 return localToGlobal(local, false);
459 //- Convert from global Cartesian position to position in
460 // local coordinate system
461 point localPosition(const point& global) const
463 return globalToLocal(global, true);
466 //- Convert from global Cartesian position to position in
467 // local coordinate system
468 tmp<pointField> localPosition(const pointField& global) const
470 return globalToLocal(global, true);
473 //- Convert from global Cartesian vector to components in
474 // local coordinate system
475 vector localVector(const vector& global) const
477 return globalToLocal(global, false);
480 //- Convert from global Cartesian vector to components in
481 // local coordinate system
482 tmp<vectorField> localVector(const vectorField& global) const
484 return globalToLocal(global, false);
490 //- Assign from dictionary
491 void operator=(const dictionary&);
496 friend bool operator!=
498 const coordinateSystem&,
499 const coordinateSystem&
502 // IOstream Operators
504 friend Ostream& operator<<(Ostream&, const coordinateSystem&);
508 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
510 } // End namespace Foam
512 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
516 // ************************************************************************* //