| 1 | /* |
| 2 | * Definition of Lorene class Metrique |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 1999-2001 Philippe Grandclement |
| 8 | * Copyright (c) 2002 Jerome Novak |
| 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 __METRIQUE_H_ |
| 30 | #define __METRIQUE_H_ |
| 31 | |
| 32 | |
| 33 | /* |
| 34 | * $Id: metrique.h,v 1.14 2014/10/13 08:52:35 j_novak Exp $ |
| 35 | * $Log: metrique.h,v $ |
| 36 | * Revision 1.14 2014/10/13 08:52:35 j_novak |
| 37 | * Lorene classes and functions now belong to the namespace Lorene. |
| 38 | * |
| 39 | * Revision 1.13 2003/10/17 13:04:18 f_limousin |
| 40 | * Add new functions get_cov() and get_con(). |
| 41 | * |
| 42 | * Revision 1.12 2003/06/20 14:22:20 f_limousin |
| 43 | * The functions set_con() and set_cov() now returns a Tenseur&. |
| 44 | * |
| 45 | * Revision 1.11 2003/03/03 19:13:46 f_limousin |
| 46 | * Add two new methods : set_con() and set_cov(). |
| 47 | * |
| 48 | * Revision 1.10 2003/02/12 18:30:18 f_limousin |
| 49 | * Added set_cov and set_con methods |
| 50 | * |
| 51 | * Revision 1.9 2003/02/07 15:41:46 e_gourgoulhon |
| 52 | * |
| 53 | * ### Added a PROVISORY set_cov method ### |
| 54 | * |
| 55 | * Revision 1.8 2002/10/16 14:36:29 j_novak |
| 56 | * Reorganization of #include instructions of standard C++, in order to |
| 57 | * use experimental version 3 of gcc. |
| 58 | * |
| 59 | * Revision 1.7 2002/09/13 09:17:33 j_novak |
| 60 | * Modif. commentaires |
| 61 | * |
| 62 | * Revision 1.6 2002/08/09 15:41:08 j_novak |
| 63 | * New class Metconf added for conformal metric handling. |
| 64 | * |
| 65 | * Revision 1.5 2002/08/08 15:10:44 j_novak |
| 66 | * The flag "plat" has been added to the class Metrique to show flat metrics. |
| 67 | * |
| 68 | * Revision 1.4 2002/08/07 16:14:10 j_novak |
| 69 | * class Tenseur can now also handle tensor densities, this should be transparent to older codes |
| 70 | * |
| 71 | * Revision 1.3 2002/08/02 15:07:41 j_novak |
| 72 | * Member function determinant has been added to the class Metrique. |
| 73 | * A better handling of spectral bases is now implemented for the class Tenseur. |
| 74 | * |
| 75 | * Revision 1.2 2002/06/17 14:05:17 j_novak |
| 76 | * friend functions are now also declared outside the class definition |
| 77 | * |
| 78 | * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 79 | * LORENE |
| 80 | * |
| 81 | * Revision 2.4 2000/02/09 19:28:54 eric |
| 82 | * Ajout de l'argument triad dans le constructeur par lecture de fichier. |
| 83 | * |
| 84 | * Revision 2.3 2000/01/11 11:13:45 eric |
| 85 | * Modif commentaires. |
| 86 | * |
| 87 | * Revision 2.2 2000/01/10 17:21:03 eric |
| 88 | * Modif commentaires. |
| 89 | * |
| 90 | * Revision 2.1 1999/12/07 15:24:50 phil |
| 91 | * ajout include |
| 92 | * |
| 93 | * Revision 2.0 1999/12/02 17:15:40 phil |
| 94 | * *** empty log message *** |
| 95 | * |
| 96 | * Revision 1.1 1999/12/02 17:13:23 phil |
| 97 | * Initial revision |
| 98 | * |
| 99 | * |
| 100 | * $Header: /cvsroot/Lorene/C++/Include/metrique.h,v 1.14 2014/10/13 08:52:35 j_novak Exp $ |
| 101 | * |
| 102 | */ |
| 103 | |
| 104 | // Headers Lorene |
| 105 | #include "tenseur.h" |
| 106 | |
| 107 | #define N_DEPEND 200 |
| 108 | |
| 109 | namespace Lorene { |
| 110 | /** |
| 111 | * Metric handling. |
| 112 | * |
| 113 | * This class is used to described 3-dimensionnal metrics. |
| 114 | * |
| 115 | * This class includes a dynamical calculation of the Christoffel symbols, |
| 116 | * the Ricci-curvature and the Ricci-scalar. |
| 117 | * |
| 118 | * @version #$Id: metrique.h,v 1.14 2014/10/13 08:52:35 j_novak Exp $# |
| 119 | */ |
| 120 | class Metrique { |
| 121 | |
| 122 | // Data : |
| 123 | // ----- |
| 124 | protected: |
| 125 | const Map* const mp ; /// Reference mapping. |
| 126 | int etat ; ///Logical state {\tt (ETATZERO, ETATQCQ or ETATNONDEF)} |
| 127 | bool plat ; ///Flag for a flat metric |
| 128 | |
| 129 | /** |
| 130 | * Pointer on the contravariant representation. |
| 131 | */ |
| 132 | mutable Tenseur_sym* p_met_con ; |
| 133 | |
| 134 | /** |
| 135 | * Pointer on the covariant representation. |
| 136 | */ |
| 137 | mutable Tenseur_sym* p_met_cov ; |
| 138 | |
| 139 | // Derived data : |
| 140 | // ------------ |
| 141 | /** |
| 142 | * Pointer on the Christoffel symbols. |
| 143 | */ |
| 144 | mutable Tenseur_sym* p_gamma ; |
| 145 | |
| 146 | /** |
| 147 | * Pointer on the Ricci curvature. |
| 148 | */ |
| 149 | mutable Tenseur_sym* p_ricci ; |
| 150 | |
| 151 | /** |
| 152 | * Pointer on the Ricci scalar. |
| 153 | */ |
| 154 | mutable Tenseur* p_ricci_scal ; |
| 155 | |
| 156 | /** |
| 157 | * Pointer on the determinant. |
| 158 | */ |
| 159 | mutable Tenseur* p_determinant ; |
| 160 | |
| 161 | /** |
| 162 | * Pointer on the dependancies, that means the array contains pointers |
| 163 | * on all the {\tt Tenseur} whom derivative members have been calculated |
| 164 | * using {\tt *this}. |
| 165 | */ |
| 166 | const Tenseur** dependances ; |
| 167 | |
| 168 | // Constructors - Destructor : |
| 169 | // ------------------------- |
| 170 | public: |
| 171 | /** Standard constructor. |
| 172 | * Nothing is allocated but {\tt dependances}. |
| 173 | * By default, the {\tt Metrique} is not flat. |
| 174 | */ |
| 175 | explicit Metrique (const Map&, bool plate = false) ; |
| 176 | |
| 177 | Metrique (const Metrique&) ; /// Constructor by copy. |
| 178 | |
| 179 | /** Constructor from a {\tt Tenseur\_sym} of {\tt valence} = 2. |
| 180 | * One representation is allocated depending on the |
| 181 | * type of {\tt source}. By default, the {\tt Metrique} is not flat. |
| 182 | */ |
| 183 | explicit Metrique (const Tenseur_sym& source, bool plate = false) ; |
| 184 | |
| 185 | /** Constructor from a file (see {\tt sauve(FILE* )}). |
| 186 | * |
| 187 | * @param map the mapping |
| 188 | * @param triad_i vectorial basis (triad) with respect to which |
| 189 | * the tensor components are defined. It will |
| 190 | * be checked that it coincides with the basis |
| 191 | * saved in the file. |
| 192 | * @param fich file which has been created by |
| 193 | * the function {\tt sauve(FILE* )}. |
| 194 | */ |
| 195 | Metrique(const Map& map, const Base_vect& triad_i, FILE* fich) ; |
| 196 | |
| 197 | virtual ~Metrique() ; /// Destructor |
| 198 | |
| 199 | // Memory management |
| 200 | // ----------------- |
| 201 | protected: |
| 202 | void del_t() ; /// Logical destructor |
| 203 | virtual void del_deriv() ; /// Logical destructor of the derivative members. |
| 204 | |
| 205 | /** |
| 206 | * Sets all the pointer on the derivative members to zero. |
| 207 | */ |
| 208 | virtual void set_der_0x0() ; |
| 209 | |
| 210 | /** |
| 211 | * Delete all the derivative members of the {\tt Tenseur} contained in |
| 212 | * {\tt dependances}. Those quantities had been previously |
| 213 | * calculated using {\tt *this}. |
| 214 | */ |
| 215 | void del_dependances() ; |
| 216 | |
| 217 | // Mutators / assignment |
| 218 | // --------------------- |
| 219 | public: |
| 220 | /** |
| 221 | * Sets the logical state to {\tt ETATNONDEF} (undefined state). |
| 222 | * Everything is deallocated. |
| 223 | */ |
| 224 | void set_etat_nondef() ; |
| 225 | |
| 226 | /** |
| 227 | * Sets the logical state to {\tt ETATZERO} (zero state). |
| 228 | * Everything is deallocated. |
| 229 | */ |
| 230 | void set_etat_zero() ; |
| 231 | |
| 232 | /** |
| 233 | * Sets the logical state to {\tt ETATQCQ} (ordinary state). |
| 234 | * The contravariant representation is allocated. |
| 235 | */ |
| 236 | void set_etat_con_qcq() ; |
| 237 | |
| 238 | /** |
| 239 | * Sets the logical state to {\tt ETATQCQ} (ordinary state). |
| 240 | * The covariant representation is allocated. |
| 241 | */ |
| 242 | void set_etat_cov_qcq() ; |
| 243 | |
| 244 | ///Assignment from another {\tt Metrique}. |
| 245 | void operator= (const Metrique&) ; |
| 246 | |
| 247 | /** |
| 248 | * Assignment from a {\tt Tenseur\_sym} of {\tt valence =2}. |
| 249 | * The allocated representation depends on the type of {\tt t}. |
| 250 | * All the other members are deleted. |
| 251 | */ |
| 252 | virtual void operator= (const Tenseur_sym& t) ; |
| 253 | |
| 254 | /** |
| 255 | * Set the standard spectral basis on the allocated representations. |
| 256 | */ |
| 257 | void set_std_base() ; |
| 258 | |
| 259 | /// Sets a component (covariant representation) |
| 260 | Cmp& set_cov(int i, int j) ; |
| 261 | |
| 262 | /// Sets a component (contravariant representation) |
| 263 | Cmp& set_con(int i, int j) ; |
| 264 | |
| 265 | /// Gets a component (covariant representation) |
| 266 | const Cmp& get_cov(int i, int j) const ; |
| 267 | |
| 268 | /// Gets a component (contravariant representation) |
| 269 | const Cmp& get_con(int i, int j) const ; |
| 270 | |
| 271 | /// Sets the covariant representation of the metric. |
| 272 | Tenseur_sym& set_cov() ; |
| 273 | |
| 274 | /// Sets the contravariant representation of the metric. |
| 275 | Tenseur_sym& set_con() ; |
| 276 | |
| 277 | /// Gets the covariant representation of the metric. |
| 278 | const Tenseur_sym& get_cov() const ; |
| 279 | |
| 280 | /// Gets the contravariant representation of the metric. |
| 281 | const Tenseur_sym& get_con() const ; |
| 282 | |
| 283 | |
| 284 | // Accessors |
| 285 | // --------- |
| 286 | public: |
| 287 | /// Returns the contravariant representation. |
| 288 | const Tenseur_sym& con() const ; |
| 289 | /// Returns the covariant representation. |
| 290 | const Tenseur_sym& cov() const ; |
| 291 | /// Returns the Christoffel symbols. |
| 292 | const Tenseur_sym& gamma() const ; |
| 293 | /// Returns the Ricci-curvature. |
| 294 | const Tenseur_sym& ricci() const ; |
| 295 | /// Returns the Ricci-scalar. |
| 296 | const Tenseur& ricci_scal() const ; |
| 297 | /// Returns the determinant. |
| 298 | const Tenseur& determinant() const ; |
| 299 | |
| 300 | /// Returns a pointer on the mapping. |
| 301 | const Map* get_mp() const{return mp ; } ; |
| 302 | int get_etat() const{return etat ;} ; /// Returns the logical state. |
| 303 | bool is_flat() const {return plat;} ; ///Is the metric a flat one? |
| 304 | void set_flat(bool plate) {plat = plate;} ;///Sets the flat flag |
| 305 | // Outputs |
| 306 | // ------- |
| 307 | public: |
| 308 | virtual void sauve(FILE *) const ; /// Save in a file |
| 309 | |
| 310 | friend ostream& operator<<(ostream& , const Metrique & ) ; /// Display. |
| 311 | |
| 312 | // Computation of derived members |
| 313 | // ------------------------------ |
| 314 | protected: |
| 315 | /** |
| 316 | * Calculates, if needed, the contravariant representation. |
| 317 | * The result is in {\tt *p\_met\_con}. |
| 318 | */ |
| 319 | void fait_con() const ; |
| 320 | |
| 321 | /** |
| 322 | * Calculates, if needed, the covariant representation. |
| 323 | * The result is in {\tt *p\_met\_cov}. |
| 324 | */ |
| 325 | void fait_cov() const ; |
| 326 | |
| 327 | /** |
| 328 | * Calculates, if needed, the Christoffel symbols. |
| 329 | * The result is in {\tt *p\_gamma}. |
| 330 | */ |
| 331 | virtual void fait_gamma() const ; |
| 332 | |
| 333 | /** |
| 334 | * Calculates, if needed, the Ricci-curvature. |
| 335 | * The result is in {\tt *p\_ricci}. |
| 336 | */ |
| 337 | virtual void fait_ricci() const ; |
| 338 | |
| 339 | /** |
| 340 | * Calculates, if needed, the Ricci-scalar. |
| 341 | * The result is in {\tt *p\_ricci\_scal}. |
| 342 | */ |
| 343 | virtual void fait_ricci_scal() const ; |
| 344 | |
| 345 | /** |
| 346 | * Calculates, if needed, the determinant. |
| 347 | * The result is in {\tt *p\_determinant}. |
| 348 | */ |
| 349 | virtual void fait_determinant() const ; |
| 350 | |
| 351 | // Friend classes |
| 352 | // --------------- |
| 353 | |
| 354 | friend class Tenseur ; /// Friend class {\tt Tenseur}. |
| 355 | |
| 356 | }; |
| 357 | ostream& operator<<(ostream& , const Metrique & ) ; |
| 358 | |
| 359 | /** |
| 360 | * @name Utilities for {\tt Metrique} |
| 361 | */ |
| 362 | //@{ |
| 363 | /** |
| 364 | * Calculates the inverse of {\tt t}, being a {\tt Tenseur\_sym} |
| 365 | * of {\tt valence} = 2. |
| 366 | */ |
| 367 | Tenseur_sym fait_inverse (const Tenseur_sym& t) ; |
| 368 | |
| 369 | //@} |
| 370 | |
| 371 | } |
| 372 | #endif |