| 1 | /* |
| 2 | * Definition of class Bin_BH (binary black hole exportation) |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2001 Eric Gourgoulhon |
| 8 | * |
| 9 | * This file is part of LORENE. |
| 10 | * |
| 11 | * LORENE is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 |
| 13 | * as published by the Free Software Foundation. |
| 14 | * |
| 15 | * LORENE is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with LORENE; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef __BIN_BH_H_ |
| 27 | #define __BIN_BH_H_ |
| 28 | |
| 29 | /* |
| 30 | * $Id: bin_bh.h,v 1.12 2014/10/13 08:54:05 j_novak Exp $ |
| 31 | * $Log: bin_bh.h,v $ |
| 32 | * Revision 1.12 2014/10/13 08:54:05 j_novak |
| 33 | * Lorene classes and functions now belong to the namespace Lorene. |
| 34 | * |
| 35 | * Revision 1.11 2014/10/06 15:13:25 j_novak |
| 36 | * Modified #include directives to use c++ syntax. |
| 37 | * |
| 38 | * Revision 1.10 2010/07/14 16:47:30 e_gourgoulhon |
| 39 | * Corrected error in the documentation for K_xx, K_xy, etc...: |
| 40 | * the components are the covariant ones, not the contravariant ones. |
| 41 | * |
| 42 | * Revision 1.9 2009/09/22 09:23:23 p_grandclement |
| 43 | * forgot to commit |
| 44 | * |
| 45 | * Revision 1.8 2009/09/10 10:05:35 p_grandclement |
| 46 | * slight change to read different mass BH |
| 47 | * |
| 48 | * Revision 1.7 2003/10/24 15:49:03 e_gourgoulhon |
| 49 | * Updated documentation. |
| 50 | * |
| 51 | * Revision 1.6 2003/01/09 11:08:00 j_novak |
| 52 | * headcpp.h is now compliant with C++ norm. |
| 53 | * The include files have been ordered, as well as the local_settings_linux |
| 54 | * |
| 55 | * Revision 1.5 2002/03/20 08:27:45 e_gourgoulhon |
| 56 | * Added the derivatives of Psi. |
| 57 | * |
| 58 | * Revision 1.4 2002/02/06 14:54:44 e_gourgoulhon |
| 59 | * Update of bibliographical references |
| 60 | * |
| 61 | * Revision 1.3 2002/01/10 14:06:58 e_gourgoulhon |
| 62 | * Modif commentaries. |
| 63 | * |
| 64 | * Revision 1.2 2001/12/19 10:14:31 e_gourgoulhon |
| 65 | * Updated documentation |
| 66 | * |
| 67 | * Revision 1.1 2001/12/19 10:08:31 e_gourgoulhon |
| 68 | * Exporting Lorene structures |
| 69 | * |
| 70 | * |
| 71 | * |
| 72 | * $Header: /cvsroot/Lorene/Export/C++/Include/bin_bh.h,v 1.12 2014/10/13 08:54:05 j_novak Exp $ |
| 73 | * |
| 74 | */ |
| 75 | |
| 76 | // Headers C |
| 77 | #include <cstdio> |
| 78 | |
| 79 | #include <iostream> |
| 80 | #include <fstream> |
| 81 | using namespace std ; |
| 82 | |
| 83 | namespace Lorene { |
| 84 | /** |
| 85 | * Binary black hole configuration on a Cartesian grid. |
| 86 | * |
| 87 | * A binary black hole system is constructed on a Cartesian grid from |
| 88 | * data stored in a file resulting from a computation by Grandclement, |
| 89 | * Gourgoulhon and Bonazzola, Phys. Rev. D 65, 044021 (2002). |
| 90 | * |
| 91 | * All the quantities are in units derived from the length |
| 92 | * scale defined by the coordinate radius $a$ of black hole 1 apparent horizon |
| 93 | * (throat). |
| 94 | * |
| 95 | * Importation of Lorene data is performed by means of the constructor |
| 96 | * {\tt Bin\_BH::Bin\_BH(int, const double*, const double*, const double*, const char*)}. |
| 97 | * This constructor takes general arrays for the location of the Cartesian coordinates |
| 98 | * $(x, y, z)$, i.e. it does not assume that the grid is a uniform one. Note also |
| 99 | * that these arrays are 1-D, as well as all the metric fields, |
| 100 | * in order to be use with any ordering of the 3-D storage. |
| 101 | * |
| 102 | * This class is very simple, with all data members being public. |
| 103 | * A typical example of use is the following one |
| 104 | * |
| 105 | * \begin{verbatim} |
| 106 | * // Define the Cartesian grid by means of the arrays xg, yg, zg: |
| 107 | * for (int i=0; i<nb_points; i++) { |
| 108 | * xg[i] = ... |
| 109 | * yg[i] = ... |
| 110 | * zg[i] = ... |
| 111 | * } |
| 112 | * |
| 113 | * // Read the file containing the spectral data and evaluate |
| 114 | * // all the fields on the Cartesian grid : |
| 115 | * |
| 116 | * Bin_BH binary_system(nb_points, xg, yg, zg, fill, datafile) ; |
| 117 | * |
| 118 | * // Extract what you need : |
| 119 | * |
| 120 | * double* gamma_xx = binary_system.g_xx ; // metric coefficient g_xx |
| 121 | * |
| 122 | * double* shift_x = binary_system.beta_x ; // x comp. of shift vector |
| 123 | * |
| 124 | * ... |
| 125 | * |
| 126 | * // Save everything in an ASCII file : |
| 127 | * |
| 128 | * ofstream file_ini("ini.d") ; |
| 129 | * binary_system.save_form(file_ini) ; |
| 130 | * file_ini.close() ; |
| 131 | * |
| 132 | * \end{verbatim} |
| 133 | * |
| 134 | * @version #$Id: bin_bh.h,v 1.12 2014/10/13 08:54:05 j_novak Exp $# |
| 135 | */ |
| 136 | |
| 137 | class Bin_BH { |
| 138 | |
| 139 | // Data : |
| 140 | // ----- |
| 141 | public: |
| 142 | /// Orbital angular velocity [unit: $a^{-1}$] |
| 143 | double omega ; |
| 144 | |
| 145 | /** Distance between the coordinate centers of two black |
| 146 | * holes [unit: $a$] |
| 147 | */ |
| 148 | double dist ; |
| 149 | |
| 150 | /** Coordinate radius of the apparent horizon (throat) of |
| 151 | * black hole 2 [unit: $a$]. |
| 152 | * NB: The coordinate radius of black hole 1 is 1 by definition |
| 153 | * of the length unit. |
| 154 | */ |
| 155 | double radius2 ; |
| 156 | |
| 157 | /// Total number of grid points |
| 158 | int np ; |
| 159 | |
| 160 | /// 1-D array storing the values of coordinate x of the {\tt np} grid points [unit: $a$] |
| 161 | double* xx ; |
| 162 | |
| 163 | /// 1-D array storing the values of coordinate y of the {\tt np} grid points [unit: $a$] |
| 164 | double* yy ; |
| 165 | |
| 166 | /// 1-D array storing the values of coordinate z of the {\tt np} grid points [unit: $a$] |
| 167 | double* zz ; |
| 168 | |
| 169 | /// Lapse function $N$ at the {\tt np} grid points (1-D array) |
| 170 | double* nnn ; |
| 171 | |
| 172 | /// Component $\beta^x$ of the shift vector of corotating coordinates [unit: $c$] |
| 173 | double* beta_x ; |
| 174 | |
| 175 | /// Component $\beta^y$ of the shift vector of corotating coordinates [unit: $c$] |
| 176 | double* beta_y ; |
| 177 | |
| 178 | /// Component $\beta^z$ of the shift vector of corotating coordinates [unit: $c$] |
| 179 | double* beta_z ; |
| 180 | |
| 181 | /// Metric coefficient $\gamma_{xx}$ at the grid points (1-D array) |
| 182 | double* g_xx ; |
| 183 | |
| 184 | /// Metric coefficient $\gamma_{xy}$ at the grid points (1-D array) |
| 185 | double* g_xy ; |
| 186 | |
| 187 | /// Metric coefficient $\gamma_{xz}$ at the grid points (1-D array) |
| 188 | double* g_xz ; |
| 189 | |
| 190 | /// Metric coefficient $\gamma_{yy}$ at the grid points (1-D array) |
| 191 | double* g_yy ; |
| 192 | |
| 193 | /// Metric coefficient $\gamma_{yz}$ at the grid points (1-D array) |
| 194 | double* g_yz ; |
| 195 | |
| 196 | /// Metric coefficient $\gamma_{zz}$ at the grid points (1-D array) |
| 197 | double* g_zz ; |
| 198 | |
| 199 | /// Component $K_{xx}$ of the extrinsic curvature at the grid points (1-D array) [unit: $c/a$] |
| 200 | double* k_xx ; |
| 201 | |
| 202 | /// Component $K_{xy}$ of the extrinsic curvature at the grid points (1-D array) [unit: $c/a$] |
| 203 | double* k_xy ; |
| 204 | |
| 205 | /// Component $K_{xz}$ of the extrinsic curvature at the grid points (1-D array) [unit: $c/a$] |
| 206 | double* k_xz ; |
| 207 | |
| 208 | /// Component $K_{yy}$ of the extrinsic curvature at the grid points (1-D array) [unit: $c/a$] |
| 209 | double* k_yy ; |
| 210 | |
| 211 | /// Component $K_{yz}$ of the extrinsic curvature at the grid points (1-D array) [unit: $c/a$] |
| 212 | double* k_yz ; |
| 213 | |
| 214 | /// Component $K_{zz}$ of the extrinsic curvature at the grid points (1-D array) [unit: $c/a$] |
| 215 | double* k_zz ; |
| 216 | |
| 217 | /// First derivative $\partial/\partial x$ of the conformal factor $\Psi$ [unit: $a^{-1}$] |
| 218 | double* dpsi_x ; |
| 219 | |
| 220 | /// First derivative $\partial/\partial y$ of the conformal factor $\Psi$ [unit: $a^{-1}$] |
| 221 | double* dpsi_y ; |
| 222 | |
| 223 | /// First derivative $\partial/\partial z$ of the conformal factor $\Psi$ [unit: $a^{-1}$] |
| 224 | double* dpsi_z ; |
| 225 | |
| 226 | /// Second derivative $\partial^2/\partial x^2$ of the conformal factor $\Psi$ [unit: $a^{-2}$] |
| 227 | double* d2psi_xx ; |
| 228 | |
| 229 | /// Second derivative $\partial^2/\partial x\partial y$ of the conformal factor $\Psi$ [unit: $a^{-2}$] |
| 230 | double* d2psi_xy ; |
| 231 | |
| 232 | /// Second derivative $\partial^2/\partial x\partial z$ of the conformal factor $\Psi$ [unit: $a^{-2}$] |
| 233 | double* d2psi_xz ; |
| 234 | |
| 235 | /// Second derivative $\partial^2/\partial y^2$ of the conformal factor $\Psi$ [unit: $a^{-2}$] |
| 236 | double* d2psi_yy ; |
| 237 | |
| 238 | /// Second derivative $\partial^2/\partial y\partial z$ of the conformal factor $\Psi$ [unit: $a^{-2}$] |
| 239 | double* d2psi_yz ; |
| 240 | |
| 241 | /// Second derivative $\partial^2/\partial z^2$ of the conformal factor $\Psi$ [unit: $a^{-2}$] |
| 242 | double* d2psi_zz ; |
| 243 | |
| 244 | // Constructors - Destructor |
| 245 | // ------------------------- |
| 246 | public: |
| 247 | /** Constructor from Lorene spectral data. |
| 248 | * |
| 249 | * This constructor takes general arrays {\tt xi, yi, zi} |
| 250 | * for the location of the Cartesian coordinates |
| 251 | * $(x, y, z)$, i.e. it does not assume that the grid is a uniform one. |
| 252 | * These arrays are 1-D to deal with any ordering of a 3-D storage. |
| 253 | * |
| 254 | * @param nbpoints [input] Total number of grid points |
| 255 | * @param xi [input] 1-D array (size {\tt nbpoints}) storing the |
| 256 | * values of coordinate x of the grid points [unit: $a$] |
| 257 | * @param yi [input] 1-D array (size {\tt nbpoints}) storing the |
| 258 | * values of coordinate y of the grid points [unit: $a$] |
| 259 | * @param zi [input] 1-D array (size {\tt nbpoints}) storing the |
| 260 | * values of coordinate z of the grid points [unit: $a$] |
| 261 | * @param fill [input] sets how the hole "interiors" must be |
| 262 | * filled: \\ |
| 263 | * fill = 0 : all the fields are set to zero \\ |
| 264 | * fill = 1 : the fields are extrapolated from their |
| 265 | * values "outside" the holes, by means of |
| 266 | * parabolas along radial directions |
| 267 | * @param filename [input] Name of the (binary) file containing the result |
| 268 | * of a computation by means of the multi-domain |
| 269 | * spectral method. |
| 270 | */ |
| 271 | Bin_BH(int nbpoints, const double* xi, const double* yi, |
| 272 | const double* zi, int fill, const char* filename, bool mdiff=false) ; |
| 273 | |
| 274 | |
| 275 | /** Constructor from a binary file |
| 276 | * (previously created by {\tt save\_bin}) |
| 277 | */ |
| 278 | Bin_BH(FILE* ) ; |
| 279 | |
| 280 | /** Constructor from a formatted file |
| 281 | * (previously created by {\tt save\_form}) |
| 282 | */ |
| 283 | Bin_BH(ifstream& ) ; |
| 284 | |
| 285 | /// Destructor |
| 286 | ~Bin_BH() ; |
| 287 | |
| 288 | |
| 289 | // Memory management |
| 290 | // ----------------- |
| 291 | private: |
| 292 | |
| 293 | /// Allocate the memory for the arrays g_ij, k_ij, etc... |
| 294 | void alloc_memory() ; |
| 295 | |
| 296 | // Outputs |
| 297 | // ------- |
| 298 | public: |
| 299 | /** Save in a binary file. |
| 300 | * This file can be subsenquently read by the evolution code, |
| 301 | * or by the constructor {\tt Bin\_BH::Bin\_BH(FILE* )}. |
| 302 | */ |
| 303 | void save_bin(FILE* ) const ; |
| 304 | |
| 305 | /** Save in a formatted file. |
| 306 | * This file can be subsenquently read by the evolution code, |
| 307 | * or by the constructor {\tt Bin\_BH::Bin\_BH(ifstream\& )}. |
| 308 | */ |
| 309 | void save_form(ofstream& ) const ; |
| 310 | |
| 311 | /// Display |
| 312 | friend ostream& operator<<(ostream& , const Bin_BH& ) ; |
| 313 | |
| 314 | }; |
| 315 | |
| 316 | } |
| 317 | #endif |