LORENE
blackhole.C
1 /*
2  * Methods of class Black_hole
3  *
4  * (see file blackhole.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2005-2007 Keisuke Taniguchi
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 
29 
30 /*
31  * $Id: blackhole.C,v 1.6 2016/12/05 16:17:48 j_novak Exp $
32  * $Log: blackhole.C,v $
33  * Revision 1.6 2016/12/05 16:17:48 j_novak
34  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35  *
36  * Revision 1.5 2014/10/13 08:52:45 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.4 2014/10/06 15:13:02 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.3 2008/07/03 14:55:26 k_taniguchi
43  * Addition of the angular momentum.
44  *
45  * Revision 1.2 2008/05/15 19:25:07 k_taniguchi
46  * Change of some parameters.
47  *
48  * Revision 1.1 2007/06/22 01:18:47 k_taniguchi
49  * *** empty log message ***
50  *
51  *
52  * $Header: /cvsroot/Lorene/C++/Source/Black_hole/blackhole.C,v 1.6 2016/12/05 16:17:48 j_novak Exp $
53  *
54  */
55 
56 // C++ headers
57 //#include <>
58 
59 // C headers
60 #include <cmath>
61 
62 // Lorene headers
63 #include "blackhole.h"
64 #include "utilitaires.h"
65 #include "unites.h"
66 
67  //----------------------//
68  // Constructors //
69  //----------------------//
70 
71 // Standard constructor
72 // --------------------
73 namespace Lorene {
74 Black_hole::Black_hole(Map& mp_i, bool kerrschild_i, double massbh)
75  : mp(mp_i),
76  kerrschild(kerrschild_i),
77  mass_bh(massbh),
78  lapconf(mp_i),
79  lapconf_rs(mp_i),
80  lapconf_bh(mp_i),
81  lapse(mp_i),
82  shift(mp_i, CON, mp_i.get_bvect_cart()),
83  shift_rs(mp_i, CON, mp_i.get_bvect_cart()),
84  shift_bh(mp_i, CON, mp_i.get_bvect_cart()),
85  confo(mp_i),
86  taij(mp_i, CON, mp_i.get_bvect_cart()),
87  taij_rs(mp_i, CON, mp_i.get_bvect_cart()),
88  taij_quad(mp_i),
89  taij_quad_rs(mp_i),
90  flat(mp_i, mp_i.get_bvect_cart()) {
91 
92  // Pointers of derived quantities are initialized to zero
93  set_der_0x0() ;
94 
95  // The metric quantities are initialized to the flat one
96  lapconf = 1. ;
98  lapconf_rs = 0. ;
100  lapconf_bh = 1. ;
102  lapse = 1. ;
104  shift.set_etat_zero() ;
107  confo = 1. ;
109 
110  taij.set_etat_zero() ;
112  taij_quad = 0. ;
114  taij_quad_rs = 0. ;
116 
117 }
118 
119 // Copy constructor
120 // ----------------
122  : mp(bh.mp),
123  kerrschild(bh.kerrschild),
124  mass_bh(bh.mass_bh),
125  lapconf(bh.lapconf),
126  lapconf_rs(bh.lapconf_rs),
127  lapconf_bh(bh.lapconf_bh),
128  lapse(bh.lapse),
129  shift(bh.shift),
130  shift_rs(bh.shift_rs),
131  shift_bh(bh.shift_bh),
132  confo(bh.confo),
133  taij(bh.taij),
134  taij_rs(bh.taij_rs),
135  taij_quad(bh.taij_quad),
136  taij_quad_rs(bh.taij_quad_rs),
137  flat(bh.flat) {
138 
139  set_der_0x0() ;
140 
141 }
142 
143 // Constructor from a file
144 // -----------------------
145 Black_hole::Black_hole(Map& mp_i, FILE* fich)
146  : mp(mp_i),
147  lapconf(mp_i),
148  lapconf_rs(mp_i, *(mp_i.get_mg()), fich),
149  lapconf_bh(mp_i),
150  lapse(mp_i),
151  shift(mp_i, CON, mp_i.get_bvect_cart()),
152  shift_rs(mp_i, mp_i.get_bvect_cart(), fich),
153  shift_bh(mp_i, CON, mp_i.get_bvect_cart()),
154  confo(mp_i, *(mp_i.get_mg()), fich),
155  taij(mp_i, CON, mp_i.get_bvect_cart()),
156  taij_rs(mp_i, CON, mp_i.get_bvect_cart()),
157  taij_quad(mp_i),
158  taij_quad_rs(mp_i),
159  flat(mp_i, mp_i.get_bvect_cart()) {
160 
161  // Background
162  // ----------
163  fread(&kerrschild, sizeof(bool), 1, fich) ;
164  fread(&mass_bh, sizeof(double), 1, fich) ;
165 
166  // All other fields are initialized to zero or some values
167  // -------------------------------------------------------
168  lapconf = lapconf_rs ;
170  lapconf_bh = 0. ;
172 
173  lapse = lapconf / confo ;
174 
175  shift = shift_rs ;
178 
179  taij.set_etat_zero() ;
181  taij_quad = 0. ;
183  taij_quad_rs = 0. ;
185 
186  // Pointers of derived quantities are initialized to zero
187  // ------------------------------------------------------
188  set_der_0x0() ;
189 
190 }
191 
192 
193  //--------------------//
194  // Destructor //
195  //--------------------//
196 
198 
199  del_deriv() ;
200 
201 }
202 
203 
204  //------------------------------------------//
205  // Management of derived quantities //
206  //------------------------------------------//
207 
208 void Black_hole::del_deriv() const {
209 
210  if (p_mass_irr != 0x0) delete p_mass_irr ;
211  if (p_mass_adm != 0x0) delete p_mass_adm ;
212  if (p_mass_kom != 0x0) delete p_mass_kom ;
213  if (p_rad_ah != 0x0) delete p_rad_ah ;
214  if (p_spin_am_bh != 0x0) delete p_spin_am_bh ;
215  if (p_angu_mom_bh != 0x0) delete p_angu_mom_bh ;
216 
217  set_der_0x0() ;
218 
219 }
220 
222 
223  p_mass_irr = 0x0 ;
224  p_mass_adm = 0x0 ;
225  p_mass_kom = 0x0 ;
226  p_rad_ah = 0x0 ;
227  p_spin_am_bh = 0x0 ;
228  p_angu_mom_bh = 0x0 ;
229 
230 }
231 
232 
233  //--------------------//
234  // Assignment //
235  //--------------------//
236 
237 // Assignment to another Black_hole
238 // --------------------------------
240 
241  assert( &(bh.mp) == &mp ) ; // Same mapping
242 
243  kerrschild = bh.kerrschild ;
244  mass_bh = bh.mass_bh ;
245  lapconf = bh.lapconf ;
246  lapconf_rs = bh.lapconf_rs ;
247  lapconf_bh = bh.lapconf_bh ;
248  lapse = bh.lapse ;
249  shift = bh.shift ;
250  shift_rs = bh.shift_rs ;
251  shift_bh = bh.shift_bh ;
252  confo = bh.confo ;
253  taij = bh.taij ;
254  taij_rs = bh.taij_rs ;
255  taij_quad = bh.taij_quad ;
257  flat = bh.flat ;
258 
259  del_deriv() ; // Deletes all derived quantities
260 
261 }
262 
263 
264  //-----------------//
265  // Outputs //
266  //-----------------//
267 
268 // Save in a file
269 // --------------
270 void Black_hole::sauve(FILE* fich) const {
271 
272  lapconf_rs.sauve(fich) ;
273  shift_rs.sauve(fich) ;
274  confo.sauve(fich) ;
275 
276  fwrite(&kerrschild, sizeof(bool), 1, fich) ;
277  fwrite(&mass_bh, sizeof(double), 1, fich) ;
278 
279 }
280 
281 // Printing
282 // --------
283 ostream& operator<<(ostream& ost, const Black_hole& bh) {
284 
285  bh >> ost ;
286  return ost ;
287 
288 }
289 
290 ostream& Black_hole::operator>>(ostream& ost) const {
291 
292  using namespace Unites ;
293 
294  const Mg3d* mg = mp.get_mg() ;
295  int nt = mg->get_nt(1) ;
296 
297  ost << endl ;
298  if (kerrschild) {
299  ost << "Kerr-Schild background" << endl ;
300  ost << "----------------------" << endl ;
301  }
302  else {
303  ost << "Conformally flat background" << endl ;
304  ost << "---------------------------" << endl ;
305  }
306 
307  ost << "lapconf on the AH : "
308  << lapconf.val_grid_point(1,0,nt-1,0) << endl ;
309  ost << "lapse on the AH : "
310  << lapse.val_grid_point(1,0,nt-1,0) << endl ;
311  ost << "shift(1) on the AH : "
312  << shift(1).val_grid_point(1,0,nt-1,0) << endl ;
313  ost << "shift(2) on the AH : "
314  << shift(2).val_grid_point(1,0,nt-1,0) << endl ;
315  ost << "shift(3) on the AH : "
316  << shift(3).val_grid_point(1,0,nt-1,0) << endl ;
317  ost << "confo on the AH : "
318  << confo.val_grid_point(1,0,nt-1,0) << endl ;
319  ost << "Gravitational mass : "
320  << mass_bh / msol << " M_sol" << endl ;
321  ost << "Irreducible mass : "
322  << mass_irr() / msol << " M_sol" << endl ;
323  ost << "ADM mass : "
324  << mass_adm() / msol << " M_sol" << endl ;
325  ost << "Komar mass : "
326  << mass_kom() / msol << " M_sol" << endl ;
327 
328  double irr_gm, adm_gm, kom_gm ;
329  irr_gm = mass_irr() / mass_bh - 1. ;
330  adm_gm = mass_adm() / mass_bh - 1. ;
331  kom_gm = mass_kom() / mass_bh - 1. ;
332  ost << "Diff. (Mirr-Mg)/Mg : " << irr_gm << endl ;
333  ost << "Diff. (Madm-Mg)/Mg : " << adm_gm << endl ;
334  ost << "Diff. (Mkom-Mg)/Mg : " << kom_gm << endl ;
335 
336  return ost ;
337 
338 }
339 }
Map & mp
Mapping associated with the black hole.
Definition: blackhole.h:80
virtual double mass_irr() const
Irreducible mass of the black hole.
Scalar lapconf_rs
Part of lapconf from the numerical computation.
Definition: blackhole.h:100
Scalar taij_quad
Part of the scalar generated by .
Definition: blackhole.h:135
double * p_mass_adm
Irreducible mass of the black hole.
Definition: blackhole.h:153
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: blackhole.C:208
Sym_tensor taij_rs
Part of the extrinsic curvature tensor.
Definition: blackhole.h:130
Lorene prototypes.
Definition: app_hor.h:67
virtual void sauve(FILE *) const
Save in a file.
Definition: blackhole.C:270
double mass_bh
Gravitational mass of BH.
Definition: blackhole.h:88
Standard units of space, time and mass.
double * p_mass_kom
ADM mass.
Definition: blackhole.h:155
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:783
bool kerrschild
true for a Kerr-Schild background, false for a conformally flat background
Definition: blackhole.h:85
Base class for coordinate mappings.
Definition: map.h:688
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
Definition: scalar.C:790
virtual double mass_adm() const
ADM mass.
virtual void sauve(FILE *) const
Save in a binary file.
Definition: tensor.C:915
Scalar taij_quad_rs
Part of the scalar.
Definition: blackhole.h:138
void operator=(const Black_hole &)
Assignment to another Black_hole.
Definition: blackhole.C:239
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
Definition: scalar.h:643
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition: vector.C:322
Scalar confo
Conformal factor generated by the black hole.
Definition: blackhole.h:118
virtual void sauve(FILE *) const
Save in a file.
Definition: scalar.C:692
double * p_mass_irr
Conformal metric .
Definition: blackhole.h:151
Scalar lapconf_bh
Part of lapconf from the analytic background.
Definition: blackhole.h:103
Vector shift_bh
Part of the shift vector from the analytic background.
Definition: blackhole.h:115
double * p_rad_ah
Komar mass.
Definition: blackhole.h:157
Black_hole(Map &mp_i, bool Kerr_schild, double massbh)
Standard constructor.
Definition: blackhole.C:74
Base class for black holes.
Definition: blackhole.h:74
Vector shift_rs
Part of the shift vector from the numerical computation.
Definition: blackhole.h:112
double * p_spin_am_bh
Radius of the apparent horizon.
Definition: blackhole.h:159
virtual ~Black_hole()
Destructor.
Definition: blackhole.C:197
virtual double mass_kom() const
Komar mass.
Multi-domain grid.
Definition: grilles.h:279
Tbl * p_angu_mom_bh
Spin angular momentum.
Definition: blackhole.h:162
Metric_flat flat
Flat metric defined on the mapping (Spherical components with respect to the mapping of the black hol...
Definition: blackhole.h:143
Scalar lapse
Lapse function generated by the black hole.
Definition: blackhole.h:106
Vector shift
Shift vector generated by the black hole.
Definition: blackhole.h:109
Sym_tensor taij
Trace of the extrinsic curvature.
Definition: blackhole.h:127
virtual void set_etat_zero()
Sets the logical state of all components to ETATZERO (zero state).
Definition: tensor.C:506
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<)
Definition: blackhole.C:290
Scalar lapconf
A function (lapse function * conformal factor) lapconf generated by the black hole.
Definition: blackhole.h:97
void set_der_0x0() const
Sets to 0x0 all the pointers on derived quantities.
Definition: blackhole.C:221