| 1 | /* |
| 2 | * Definition of Lorene class Metric |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak |
| 8 | * |
| 9 | * Copyright (c) 1999-2001 Philippe Grandclement (for previous class Metrique) |
| 10 | * |
| 11 | * This file is part of LORENE. |
| 12 | * |
| 13 | * LORENE is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License version 2 |
| 15 | * as published by the Free Software Foundation. |
| 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 | #ifndef __METRIC_H_ |
| 29 | #define __METRIC_H_ |
| 30 | |
| 31 | /* |
| 32 | * $Id: metric.h,v 1.9 2014/10/13 08:52:35 j_novak Exp $ |
| 33 | * $Log: metric.h,v $ |
| 34 | * Revision 1.9 2014/10/13 08:52:35 j_novak |
| 35 | * Lorene classes and functions now belong to the namespace Lorene. |
| 36 | * |
| 37 | * Revision 1.8 2004/11/18 12:23:42 jl_jaramillo |
| 38 | * radial vector normal to a spherical slicing and pointing towards |
| 39 | * spatial infinity |
| 40 | * |
| 41 | * Revision 1.7 2004/03/22 13:12:42 j_novak |
| 42 | * Modification of comments to use doxygen instead of doc++ |
| 43 | * |
| 44 | * Revision 1.6 2003/12/30 23:04:58 e_gourgoulhon |
| 45 | * Important reorganization of class Metric: |
| 46 | * -- suppression of virtual methods fait_* : the actual computations |
| 47 | * are now performed via the virtual methods con(), cov(), connect(), |
| 48 | * ricci(), ricci_scal(), determinant() |
| 49 | * -- the member p_connect is now treated as an ordinary derived data |
| 50 | * member |
| 51 | * -- the construction of the associated connection (member p_connect) |
| 52 | * is performed thanks to the new methods Map::flat_met_spher() and |
| 53 | * Map::flat_met_cart(). |
| 54 | * |
| 55 | * Revision 1.5 2003/11/06 14:43:37 e_gourgoulhon |
| 56 | * Gave a name to const arguments in certain method prototypes (e.g. |
| 57 | * constructors) to correct a bug of DOC++. |
| 58 | * |
| 59 | * Revision 1.4 2003/10/06 15:30:32 j_novak |
| 60 | * Defined methods for flat metric. |
| 61 | * |
| 62 | * Revision 1.3 2003/10/06 13:58:45 j_novak |
| 63 | * The memory management has been improved. |
| 64 | * Implementation of the covariant derivative with respect to the exact Tensor |
| 65 | * type. |
| 66 | * |
| 67 | * Revision 1.2 2003/10/03 11:21:45 j_novak |
| 68 | * More methods for the class Metric |
| 69 | * |
| 70 | * Revision 1.1 2003/10/02 15:45:48 j_novak |
| 71 | * New class Metric |
| 72 | * |
| 73 | * |
| 74 | * |
| 75 | * |
| 76 | * $Header: /cvsroot/Lorene/C++/Include/metric.h,v 1.9 2014/10/13 08:52:35 j_novak Exp $ |
| 77 | * |
| 78 | */ |
| 79 | |
| 80 | // Lorene headers |
| 81 | #include "connection.h" |
| 82 | |
| 83 | #define N_TENSOR_DEPEND 200 |
| 84 | |
| 85 | namespace Lorene { |
| 86 | /** |
| 87 | * Metric for tensor calculation. \ingroup (tensor) |
| 88 | * |
| 89 | */ |
| 90 | class Metric { |
| 91 | |
| 92 | // Data : |
| 93 | // ----- |
| 94 | protected: |
| 95 | const Map* const mp ; ///< Reference mapping. |
| 96 | |
| 97 | /** |
| 98 | * Pointer on the contravariant representation. |
| 99 | */ |
| 100 | mutable Sym_tensor* p_met_cov ; |
| 101 | |
| 102 | /** |
| 103 | * Pointer on the covariant representation. |
| 104 | */ |
| 105 | mutable Sym_tensor* p_met_con ; |
| 106 | |
| 107 | |
| 108 | // Derived data : |
| 109 | // ------------ |
| 110 | protected: |
| 111 | |
| 112 | mutable Connection* p_connect ; ///< Connection associated with the metric |
| 113 | |
| 114 | /** |
| 115 | * Pointer on the Ricci scalar. |
| 116 | * Remark: the Ricci tensor is stored in the connection (member |
| 117 | * \c p_connect->p_ricci ). |
| 118 | */ |
| 119 | mutable Scalar* p_ricci_scal ; |
| 120 | |
| 121 | /** |
| 122 | * Pointer to the radial vector normal to a spherical slicing and pointing |
| 123 | * toward spatial infinity |
| 124 | */ |
| 125 | mutable Vector* p_radial_vect ; |
| 126 | |
| 127 | |
| 128 | |
| 129 | /** |
| 130 | * Pointer on the determinant. |
| 131 | */ |
| 132 | mutable Scalar* p_determinant ; |
| 133 | |
| 134 | /** |
| 135 | * Pointer on the dependancies, that means the array contains pointers |
| 136 | * on all the \c Tensor whom derivative members have been calculated |
| 137 | * using \c *this . |
| 138 | */ |
| 139 | mutable const Tensor* tensor_depend[N_TENSOR_DEPEND] ; |
| 140 | |
| 141 | // Constructors - Destructor |
| 142 | // ------------------------- |
| 143 | public: |
| 144 | /** Standard constructor from a \c Sym_tensor . |
| 145 | * |
| 146 | * The symmetric tensor can be either the covariant or |
| 147 | * the contravariant representation of the metric. |
| 148 | */ |
| 149 | explicit Metric(const Sym_tensor& tens) ; |
| 150 | |
| 151 | Metric(const Metric& met) ; ///< Copy constructor |
| 152 | |
| 153 | /// Constructor from a file (see \c sauve(FILE*) ) |
| 154 | Metric(const Map&, FILE* ) ; |
| 155 | |
| 156 | protected: |
| 157 | /// Simplified constructor used by derived classes. |
| 158 | explicit Metric(const Map& mpi) ; |
| 159 | |
| 160 | public: |
| 161 | virtual ~Metric() ; ///< Destructor |
| 162 | |
| 163 | |
| 164 | // Memory management |
| 165 | // ----------------- |
| 166 | protected: |
| 167 | /// Deletes all the derived quantities |
| 168 | void del_deriv() const ; |
| 169 | |
| 170 | /// Sets to \c 0x0 all the pointers on derived quantities |
| 171 | void set_der_0x0() const ; |
| 172 | |
| 173 | /** |
| 174 | * Deletes all the derivative members of the \c Tensor contained in |
| 175 | * \c tensor_depend . Those quantities had been previously |
| 176 | * calculated using \c *this . |
| 177 | */ |
| 178 | void del_tensor_depend() const ; |
| 179 | |
| 180 | ///Sets all elements of \c tensor_depend to 0x0. |
| 181 | void set_tensor_depend_0x0() const ; |
| 182 | |
| 183 | |
| 184 | // Mutators / assignment |
| 185 | // --------------------- |
| 186 | public: |
| 187 | /// Assignment to another Metric |
| 188 | void operator=(const Metric& met) ; |
| 189 | |
| 190 | /** |
| 191 | * Assignment from a \c Sym_tensor . |
| 192 | * The allocated representation depends on the type of the |
| 193 | * input tensor indices. |
| 194 | * All the other members are deleted. |
| 195 | */ |
| 196 | virtual void operator=(const Sym_tensor& tens) ; |
| 197 | |
| 198 | // Accessors |
| 199 | // --------- |
| 200 | public: |
| 201 | /// Returns the mapping |
| 202 | const Map& get_mp() const {return *mp ; } ; |
| 203 | |
| 204 | /// Read-only access to the covariant representation |
| 205 | virtual const Sym_tensor& cov() const ; |
| 206 | |
| 207 | /// Read-only access to the contravariant representation |
| 208 | virtual const Sym_tensor& con() const ; |
| 209 | |
| 210 | /// Returns the connection |
| 211 | virtual const Connection& connect() const ; |
| 212 | |
| 213 | /** Returns the Ricci tensor (given by the \c Connection |
| 214 | * \c p_connect ) |
| 215 | */ |
| 216 | const Sym_tensor& ricci() const ; |
| 217 | |
| 218 | /// Returns the Ricci scalar |
| 219 | virtual const Scalar& ricci_scal() const ; |
| 220 | |
| 221 | /** Returns the radial vector normal to a spherical slicing and pointing |
| 222 | * toward spatial infinity |
| 223 | */ |
| 224 | |
| 225 | virtual const Vector& radial_vect() const ; |
| 226 | |
| 227 | |
| 228 | /**Returns the determinant. |
| 229 | * |
| 230 | * This determinant is stored as a \c Scalar although it |
| 231 | * a scalar density. To be a real scalar it must be divided |
| 232 | * by e.g. the determinant of a flat metric. |
| 233 | */ |
| 234 | virtual const Scalar& determinant() const ; |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | // Outputs |
| 241 | // ------- |
| 242 | public: |
| 243 | virtual void sauve(FILE *) const ; ///< Save in a file |
| 244 | |
| 245 | /// Display |
| 246 | friend ostream& operator<<(ostream& , const Metric& ) ; |
| 247 | |
| 248 | protected: |
| 249 | /// Operator >> (virtual function called by the operator <<). |
| 250 | virtual ostream& operator>>(ostream& ) const ; |
| 251 | |
| 252 | |
| 253 | friend class Tensor ; |
| 254 | |
| 255 | }; |
| 256 | |
| 257 | /** |
| 258 | * Flat metric for tensor calculation.\ingroup (tensor) |
| 259 | * |
| 260 | */ |
| 261 | class Metric_flat: public Metric { |
| 262 | |
| 263 | // Data : |
| 264 | // ----- |
| 265 | protected: |
| 266 | |
| 267 | /** Vectorial basis (triad) with respect to which the components of |
| 268 | * the flat metric are defined. |
| 269 | */ |
| 270 | const Base_vect* triad ; |
| 271 | |
| 272 | // Constructors - Destructor |
| 273 | // ------------------------- |
| 274 | public: |
| 275 | /** Standard constructor. |
| 276 | * |
| 277 | * Standard constructor from a mapping and a triad. |
| 278 | */ |
| 279 | Metric_flat(const Map&, const Base_vect& ) ; |
| 280 | |
| 281 | Metric_flat(const Metric_flat& ) ; ///< Copy constructor |
| 282 | |
| 283 | /// Constructor from a file (see \c sauve(FILE*) ) |
| 284 | Metric_flat(const Map&, FILE* ) ; |
| 285 | |
| 286 | public: |
| 287 | virtual ~Metric_flat() ; ///< Destructor |
| 288 | |
| 289 | |
| 290 | // Mutators / assignment |
| 291 | // --------------------- |
| 292 | public: |
| 293 | /// Assignment to another Metric_flat |
| 294 | void operator=(const Metric_flat&) ; |
| 295 | |
| 296 | /** |
| 297 | * Assignment from a \c Sym_tensor . |
| 298 | * In principle, this method should not be used for a \c Metric_flat . |
| 299 | */ |
| 300 | virtual void operator=(const Sym_tensor& tens) ; |
| 301 | |
| 302 | |
| 303 | // Accessors |
| 304 | // --------- |
| 305 | public: |
| 306 | /** Returns the vectorial basis (triad) on which the metric |
| 307 | * is defined. |
| 308 | */ |
| 309 | const Base_vect* get_triad() const {return triad;} ; |
| 310 | |
| 311 | /// Read-only access to the covariant representation |
| 312 | virtual const Sym_tensor& cov() const ; |
| 313 | |
| 314 | /// Read-only access to the contravariant representation |
| 315 | virtual const Sym_tensor& con() const ; |
| 316 | |
| 317 | /// Returns the connection |
| 318 | virtual const Connection& connect() const ; |
| 319 | |
| 320 | /// Returns the Ricci scalar |
| 321 | virtual const Scalar& ricci_scal() const ; |
| 322 | |
| 323 | /**Returns the determinant. |
| 324 | * |
| 325 | * This determinant is stored as a \c Scalar although it |
| 326 | * a scalar density. To be a real scalar it must be divided |
| 327 | * by e.g. the determinant of a flat metric. |
| 328 | */ |
| 329 | virtual const Scalar& determinant() const ; |
| 330 | |
| 331 | |
| 332 | // Outputs |
| 333 | // ------- |
| 334 | public: |
| 335 | virtual void sauve(FILE *) const ; ///< Save in a file |
| 336 | |
| 337 | protected: |
| 338 | /// Operator >> (virtual function called by the operator <<). |
| 339 | virtual ostream& operator>>(ostream& ) const ; |
| 340 | |
| 341 | |
| 342 | }; |
| 343 | |
| 344 | |
| 345 | |
| 346 | } |
| 347 | #endif |