OpenFOAM logo
Open Source CFD Toolkit

coordinateSystem.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     coordinateSystem
00027 
00028 Description
00029     Virtual base class for coordinate systems.
00030 
00031     All systems are defined in two ways:
00032     1) In terms of a position (the coordinate origin), and axis
00033     (usually the z axis) and a direction (effectively the x-axis).
00034     The code requires that the axis and the direction are orthogonal.
00035     2) Given the origin and a coordinate rotation.
00036 
00037 SourceFiles
00038     coordinateSystem.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef coordinateSystem_H
00043 #define coordinateSystem_H
00044 
00045 #include "vector.H"
00046 #include "tensor.H"
00047 #include "vectorField.H"
00048 #include "tmp.H"
00049 #include "coordinateRotation.H"
00050 #include "mathematicalConstants.H"
00051 
00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00053 
00054 namespace Foam
00055 {
00056 
00057 /*---------------------------------------------------------------------------*\
00058                            Class coordinateSystem Declaration
00059 \*---------------------------------------------------------------------------*/
00060 
00061 class coordinateSystem
00062 {
00063     // Private data
00064 
00065         //- Name of patch
00066         word name_;
00067 
00068         //- Origin
00069         vector origin_;
00070 
00071         //- Axis
00072         vector axis_;
00073 
00074         //- Origin
00075         vector dir_;
00076 
00077 
00078 public:
00079 
00080     //- Runtime type information
00081     TypeName("coordinateSystem");
00082 
00083 
00084     // Constructors
00085 
00086         //- Construct from origin and 2 axes
00087         coordinateSystem
00088         (
00089             const word& name,
00090             const vector& origin,
00091             const vector& axis,
00092             const vector& dir
00093         );
00094 
00095         //- Construct from origin and rotation angles
00096         coordinateSystem
00097         (
00098             const word& name,
00099             const vector& origin,
00100             const coordinateRotation& cr
00101         );
00102 
00103         //- Construct from dictionary
00104         coordinateSystem(const word& name, const dictionary& dict);
00105 
00106 
00107     // Declare run-time constructor selection table
00108 
00109         declareRunTimeSelectionTable
00110         (
00111             autoPtr,
00112             coordinateSystem,
00113             origAxisDir,
00114             (
00115                 const word& name,
00116                 const vector& origin,
00117                 const vector& axis,
00118                 const vector& dir
00119             ),
00120             (name, origin, axis, dir)
00121         );
00122 
00123         declareRunTimeSelectionTable
00124         (
00125             autoPtr,
00126             coordinateSystem,
00127             origRotation,
00128             (
00129                 const word& name,
00130                 const vector& origin,
00131                 const coordinateRotation& cr
00132             ),
00133             (name, origin, cr)
00134         );
00135 
00136         declareRunTimeSelectionTable
00137         (
00138             autoPtr,
00139             coordinateSystem,
00140             dictionary,
00141             (
00142                 const word& name,
00143                 const dictionary& dict
00144             ),
00145             (name, dict)
00146         );
00147 
00148 
00149     // Selectors
00150 
00151         //- Select constructed from origin and 2 axes
00152         static autoPtr<coordinateSystem> New
00153         (
00154             const word& coordType,
00155             const word& name,
00156             const vector& origin,
00157             const vector& axis,
00158             const vector& dir
00159         );
00160 
00161         //- Select constructed from origin and rotation
00162         static autoPtr<coordinateSystem> New
00163         (
00164             const word& coordType,
00165             const word& name,
00166             const vector& origin,
00167             const coordinateRotation& cr
00168         );
00169 
00170         //- Select constructed from Istream
00171         static autoPtr<coordinateSystem> New
00172         (
00173             const word& name,
00174             const dictionary& dict
00175         );
00176 
00177 
00178     // Destructor
00179 
00180         virtual ~coordinateSystem();
00181 
00182 
00183     // Member Functions
00184 
00185         //- Return name
00186         const word& name() const
00187         {
00188             return name_;
00189         }
00190 
00191         //- Return origin
00192         const vector& origin() const
00193         {
00194             return origin_;
00195         }
00196 
00197         //- Return axis
00198         const vector& axis() const
00199         {
00200             return axis_;
00201         }
00202 
00203         //- Return direction
00204         const vector& direction() const
00205         {
00206             return dir_;
00207         }
00208 
00209 
00210         //- Convert from local coordinate system to the global Cartesian system
00211         virtual vector toGlobal(const vector& localV) const = 0;
00212 
00213         virtual tmp<vectorField> toGlobal(const vectorField& localV) const = 0;
00214 
00215         //- Convert from global Cartesian system to the local coordinate system 
00216         virtual vector toLocal(const vector& globalV) const = 0;
00217 
00218         virtual tmp<vectorField> toLocal(const vectorField& globalV) const = 0;
00219 
00220         //- Write
00221         virtual void write(Ostream&) const;
00222 
00223         //- Write dictionary
00224         virtual void writeDict(Ostream&) const;
00225 
00226 
00227     // Ostream Operator
00228 
00229         friend Ostream& operator<<(Ostream&, const coordinateSystem&);
00230 };
00231 
00232 
00233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00234 
00235 } // End namespace Foam
00236 
00237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00238 
00239 #endif
00240 
00241 // ************************************************************************* //
For further information go to www.openfoam.org