| 1 | /* |
| 2 | * Definition of Lorene class Coord |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 1999-2000 Jean-Alain Marck |
| 8 | * Copyright (c) 1999-2001 Eric Gourgoulhon |
| 9 | * |
| 10 | * This file is part of LORENE. |
| 11 | * |
| 12 | * LORENE is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * LORENE is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with LORENE; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | #ifndef __COORD_H_ |
| 30 | #define __COORD_H_ |
| 31 | |
| 32 | |
| 33 | /* |
| 34 | * $Id: coord.h,v 1.7 2014/10/13 08:52:33 j_novak Exp $ |
| 35 | * $Log: coord.h,v $ |
| 36 | * Revision 1.7 2014/10/13 08:52:33 j_novak |
| 37 | * Lorene classes and functions now belong to the namespace Lorene. |
| 38 | * |
| 39 | * Revision 1.6 2014/10/06 15:09:39 j_novak |
| 40 | * Modified #include directives to use c++ syntax. |
| 41 | * |
| 42 | * Revision 1.5 2004/03/22 13:12:40 j_novak |
| 43 | * Modification of comments to use doxygen instead of doc++ |
| 44 | * |
| 45 | * Revision 1.4 2003/11/06 14:43:37 e_gourgoulhon |
| 46 | * Gave a name to const arguments in certain method prototypes (e.g. |
| 47 | * constructors) to correct a bug of DOC++. |
| 48 | * |
| 49 | * Revision 1.3 2002/10/16 14:36:28 j_novak |
| 50 | * Reorganization of #include instructions of standard C++, in order to |
| 51 | * use experimental version 3 of gcc. |
| 52 | * |
| 53 | * Revision 1.2 2002/06/17 14:05:16 j_novak |
| 54 | * friend functions are now also declared outside the class definition |
| 55 | * |
| 56 | * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 57 | * LORENE |
| 58 | * |
| 59 | * Revision 2.1 1999/10/15 09:15:56 eric |
| 60 | * Depoussierage. |
| 61 | * Documentation. |
| 62 | * |
| 63 | * Revision 2.0 1999/02/15 10:41:51 hyc |
| 64 | * *** empty log message *** |
| 65 | * |
| 66 | * Revision 2.1 1999/02/15 09:59:50 hyc |
| 67 | * *** empty log message *** |
| 68 | * |
| 69 | * Revision 2.0 1999/01/15 09:10:39 hyc |
| 70 | * *** empty log message *** |
| 71 | * |
| 72 | * |
| 73 | * $Header: /cvsroot/Lorene/C++/Include/coord.h,v 1.7 2014/10/13 08:52:33 j_novak Exp $ |
| 74 | * |
| 75 | */ |
| 76 | |
| 77 | // Fichier includes |
| 78 | #include <cstdlib> |
| 79 | #include <cstdio> |
| 80 | #include "mtbl.h" |
| 81 | |
| 82 | namespace Lorene { |
| 83 | class Map ; |
| 84 | |
| 85 | /** |
| 86 | * Active physical coordinates and mapping derivatives. |
| 87 | * \ingroup (map) |
| 88 | * |
| 89 | */ |
| 90 | class Coord { |
| 91 | |
| 92 | // Data : |
| 93 | // ----- |
| 94 | public: |
| 95 | const Map* mp ; ///< Mapping on which the \c Coord is defined |
| 96 | Mtbl* (*met_fait)(const Map* ) ; ///< Function to compute the coordinate |
| 97 | mutable Mtbl* c ; ///< The coordinate values at each grid point |
| 98 | |
| 99 | // Constructors, destructor : |
| 100 | // ------------------------ |
| 101 | public: |
| 102 | Coord() ; ///< Default constructor |
| 103 | |
| 104 | /** |
| 105 | * Constructor from a mapping and a method. |
| 106 | * @param mp [input] Mapping on which the Coord is defined |
| 107 | * @param construct [input] Method to construct the \c Coord , i.e. to |
| 108 | * initialize the \c Mtbl which contains the value of |
| 109 | * the coordinate or mapping derivative represented by |
| 110 | * the \c Coord |
| 111 | */ |
| 112 | Coord(const Map* mp, Mtbl* (*construct)(const Map*) ) ; |
| 113 | |
| 114 | |
| 115 | private: |
| 116 | /** Copy constructor (private and not implemented to make \c Coord |
| 117 | * a non-copyable class) |
| 118 | */ |
| 119 | Coord(const Coord & ) ; |
| 120 | |
| 121 | public: |
| 122 | ~Coord() ; ///< Destructor |
| 123 | |
| 124 | // Various methods : |
| 125 | // --------------- |
| 126 | |
| 127 | /** Assignement operator (private and not implemented to make |
| 128 | * \c Coord a non-copyable class) |
| 129 | */ |
| 130 | private: |
| 131 | void operator=(const Coord& ) ; |
| 132 | |
| 133 | public: |
| 134 | /** |
| 135 | * Semi-constructor from a mapping and a method. |
| 136 | * This function is intended to complete the construction started by |
| 137 | * the default constructor. |
| 138 | * @param mp [input] Mapping on which the Coord is defined |
| 139 | * @param construct [input] Method to construct the \c Coord , i.e. to |
| 140 | * initialize the \c Mtbl which contains the value of |
| 141 | * the coordinate or mapping derivative represented by |
| 142 | * the \c Coord |
| 143 | */ |
| 144 | void set(const Map* mp, Mtbl* (*construct)(const Map*) ) ; |
| 145 | |
| 146 | /** |
| 147 | * Computes, at each point of the grid, the value of the coordinate or |
| 148 | * mapping derivative represented by the \c Coord . |
| 149 | * The result is stored in the \c Mtbl member \c *c . |
| 150 | */ |
| 151 | void fait() const ; |
| 152 | |
| 153 | /// Logical destructor (deletes the \c Mtbl member \c *c ). |
| 154 | void del_t() const ; |
| 155 | |
| 156 | friend ostream& operator<<(ostream& , const Coord& ) ; ///< Display |
| 157 | |
| 158 | } ; |
| 159 | ostream& operator<<(ostream& , const Coord& ) ; |
| 160 | |
| 161 | // Prototypage de l'arithmetique |
| 162 | /** |
| 163 | * \defgroup coord_ari Coord Arithmetics. |
| 164 | * \ingroup (map) |
| 165 | * @{ |
| 166 | */ |
| 167 | |
| 168 | Mtbl operator+(const Coord&) ; ///< + \c Coord |
| 169 | Mtbl operator-(const Coord&) ; ///< \c - \c Coord |
| 170 | |
| 171 | Mtbl operator+(const Coord& a, const Coord& b) ; ///< \c Coord + \c Coord |
| 172 | Mtbl operator-(const Coord& a, const Coord& b) ; ///< \c Coord - \c Coord |
| 173 | Mtbl operator*(const Coord& a, const Coord& b) ; ///< \c Coord * \c Coord |
| 174 | |
| 175 | Mtbl operator+(const Coord& a, const Mtbl& b) ; ///< \c Coord + \c Mtbl |
| 176 | Mtbl operator-(const Coord& a, const Mtbl& b) ; ///< \c Coord - \c Mtbl |
| 177 | Mtbl operator*(const Coord& a, const Mtbl& b) ; ///< \c Coord * \c Mtbl |
| 178 | |
| 179 | Mtbl operator+(const Mtbl& a, const Coord& b) ; ///< \c Mtbl + \c Coord |
| 180 | Mtbl operator-(const Mtbl& a, const Coord& b) ; ///< \c Mtbl - \c Coord |
| 181 | Mtbl operator*(const Mtbl& a, const Coord& b) ; ///< \c Mtbl * \c Coord |
| 182 | /** @} */ |
| 183 | |
| 184 | } |
| 185 | #endif |