LORENE
altBH_QI.C
1 /*
2  * Methods of the class AltBH_QI
3  *
4  * (see file compobj.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2013 Odele Straub, Eric Gourgoulhon
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: altBH_QI.C,v 1.6 2016/12/05 16:17:49 j_novak Exp $
32  * $Log: altBH_QI.C,v $
33  * Revision 1.6 2016/12/05 16:17:49 j_novak
34  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35  *
36  * Revision 1.5 2014/10/13 08:52:49 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.4 2014/01/17 07:33:13 o_straub
40  * adjustment to read in files with 4 lines in the header
41  *
42  * Revision 1.3 2014/01/14 16:36:11 e_gourgoulhon
43  * Corrected initialization of bbb
44  *
45  * Revision 1.2 2013/04/17 13:02:47 e_gourgoulhon
46  * Added member krphi + method extrinsic_curvature
47  *
48  * Revision 1.1 2013/04/16 15:27:27 e_gourgoulhon
49  * New class AltBH_QI
50  *
51  *
52  * $Header: /cvsroot/Lorene/C++/Source/Compobj/altBH_QI.C,v 1.6 2016/12/05 16:17:49 j_novak Exp $
53  *
54  */
55 
56 
57 // C headers
58 #include <cassert>
59 
60 // Lorene headers
61 #include "compobj.h"
62 #include "unites.h"
63 #include "nbr_spx.h"
64 
65  //--------------//
66  // Constructors //
67  //--------------//
68 
69 // Standard constructor
70 // --------------------
71 namespace Lorene {
72 AltBH_QI::AltBH_QI(Map& mpi, const char* file_name, double a_spin_i) :
73  Compobj_QI(mpi) ,
74  a_spin(a_spin_i),
75  krphi(mpi)
76 {
77 
78  ifstream file(file_name) ;
79  if ( !file.good() ) {
80  cerr << "Problem in opening the file " << file_name << endl ;
81  abort() ;
82  }
83 
84  file.getline(description1, 256) ;
85  file.getline(description2, 256) ;
86  cout << "description1 : " << description1 << endl ;
87  cout << "description2 : " << description2 << endl ;
88 // description1[0] = " " ;
89 // description2[0] = " " ;
90 // cout << "description1 : " << description1 << endl ;
91 // cout << "description2 : " << description2 << endl ;
92 
93  const Mg3d* mg = mp.get_mg() ;
94  double tmp ;
95  file.ignore(1000,'\n') ;
96  file.ignore(1000,'\n') ;
97  int nz = mg->get_nzone() ;
98  cout << "nz : " << nz << endl ;
99  a_car.set_etat_qcq() ; // Memory allocation for A^2
100  nn.set_etat_qcq() ; // Memory allocation for N
101  nphi.allocate_all() ; // Memory allocation for N^phi
102  krphi.allocate_all() ; // Memory allocation for K_rphi
103  double r_inner = 0 ;
104  for (int l=1; l<nz; l++) {
105  cout << "l = " << l << endl ;
106  int nr = mg->get_nr(l) ;
107  int nt = mg->get_nt(l) ;
108  int np = mg->get_np(l) ;
109  double* r_iso = new double[nr] ;
110  double* r_areal = new double[nr] ;
111  double* psi4 = new double[nr] ;
112  double* alpha = new double[nr] ;
113  double* Krphi = new double[nr] ;
114  double* beta_phi = new double[nr] ;
115  int nr_max = nr ;
116  if (l==nz-1) {
117  nr_max = nr - 1 ;
118  r_areal[nr-1] = __infinity ;
119  r_iso[nr-1] = __infinity ;
120  psi4[nr-1] = 1 ;
121  alpha[nr-1] = 1 ;
122  Krphi[nr-1] = 0 ;
123  beta_phi[nr-1] = 0 ;
124  }
125  for (int i=0; i<nr_max; i++) {
126  file >> r_areal[i] ;
127  file >> r_iso[i] ;
128  file >> tmp ;
129  file >> psi4[i] ;
130  file >> alpha[i] ;
131  file >> tmp ;
132  file >> Krphi[i] ;
133  file >> beta_phi[i] ;
134  cout << "r_iso, psi4, beta_phi : " << r_iso[i] << " " << psi4[i] << " " << beta_phi[i] << endl ;
135  }
136 
137  if (l==1) r_inner = r_iso[0] ;
138 
139  for (int k=0; k<np; k++) {
140  for (int j=0; j<nt; j++) {
141  for (int i=0; i<nr; i++) {
142  a_car.set_grid_point(l,k,j,i) = psi4[i] ;
143  nn.set_grid_point(l,k,j,i) = alpha[i] ;
144  nphi.set_grid_point(l,k,j,i) = - a_spin * beta_phi[i] / psi4[i] / (r_iso[i]*r_iso[i]) ;
145  krphi.set_grid_point(l,k,j,i) = a_spin * Krphi[i] / r_iso[i] ;
146  }
147  }
148  }
149  }
150  file.close() ;
151 
152  mp.homothetie(r_inner / mp.val_r(1,-1.,0.,0.)) ;
153 
154  // Set the shift to zero in domain l=0:
155  nphi.annule(0,0) ;
156 
161 
162  b_car = a_car ; // slow rotation limit: B^2 = A^2
163  bbb = sqrt(b_car) ;
165 
166  // Pointers of derived quantities initialized to zero :
167  set_der_0x0() ;
168 }
169 
170 // Copy constructor
171 // --------------------
173  Compobj_QI(other),
174  krphi(other.krphi)
175 {
176  // Pointers of derived quantities initialized to zero :
177  set_der_0x0() ;
178 }
179 
180 
181 // Constructor from a file
182 // -----------------------
183 AltBH_QI::AltBH_QI(Map& mpi, FILE* ) :
184  Compobj_QI(mpi),
185  krphi(mpi)
186 {
187  // Pointers of derived quantities initialized to zero :
188  set_der_0x0() ;
189 
190  // Read of the saved fields:
191  // ------------------------
192 
193 }
194 
195  //------------//
196  // Destructor //
197  //------------//
198 
200 
201  del_deriv() ;
202 
203 }
204 
205 
206  //----------------------------------//
207  // Management of derived quantities //
208  //----------------------------------//
209 
210 void AltBH_QI::del_deriv() const {
211 
213 
214 
216 }
217 
218 
219 void AltBH_QI::set_der_0x0() const {
220 
221 }
222 
223  //--------------//
224  // Assignment //
225  //--------------//
226 
227 // Assignment to another AltBH_QI
228 // --------------------------------
229 void AltBH_QI::operator=(const AltBH_QI& other) {
230 
231  // Assignment of quantities common to all the derived classes of Compobj_QI
232  Compobj_QI::operator=(other) ;
233 
234  del_deriv() ; // Deletes all derived quantities
235 }
236 
237  //--------------//
238  // Outputs //
239  //--------------//
240 
241 // Save in a file
242 // --------------
243 void AltBH_QI::sauve(FILE* ) const {
244 
245 
246 }
247 
248 // Printing
249 // --------
250 
251 ostream& AltBH_QI::operator>>(ostream& ost) const {
252 
253  using namespace Unites ;
254 
255  Compobj_QI::operator>>(ost) ;
256 
257  ost << endl << "Alternative black hole spacetime in quasi-isotropic coordinates (class AltBH_QI) " << endl ;
258  ost << description1 << endl ;
259  ost << description2 << endl ;
260 
261  return ost ;
262 
263 }
264 
265  //-------------------------//
266  // Computational methods //
267  //-------------------------//
268 
269 // Updates the extrinsic curvature
270 // -------------------------------
271 
273 
274  // Special treatment for axisymmetric case:
275 
276  if ( (mp.get_mg())->get_np(0) == 1) {
277 
278  // What follows is valid only for a mapping of class Map_radial :
279  assert( dynamic_cast<const Map_radial*>(&mp) != 0x0 ) ;
280 
281  Scalar tmp = krphi ;
282  tmp.mult_sint() ; // multiplication by sin(theta)
283  kk.set(1,3) = tmp ;
284 
285  kk.set(2,3) = 0 ;
286 
287  kk.set(1,1) = 0 ;
288  kk.set(1,2) = 0 ;
289  kk.set(2,2) = 0 ;
290  kk.set(3,3) = 0 ;
291  }
292  else {
293 
294  // General case:
295 
297  }
298 
299  // Computation of A^2 K_{ij} K^{ij}
300  // --------------------------------
301 
302  ak_car = 2 * ( kk(1,3)*kk(1,3) + kk(2,3)*kk(2,3) ) / b_car ;
303 
304  del_deriv() ;
305 
306 }
307 }
Base class for axisymmetric stationary compact objects in Quasi-Isotropic coordinates (under developm...
Definition: compobj.h:283
AltBH_QI(Map &mp_i, const char *file_name, double a_spin_i)
Standard constructor.
Definition: altBH_QI.C:72
virtual void extrinsic_curvature()
Computation of the extrinsic curvature.
Definition: altBH_QI.C:272
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: altBH_QI.C:210
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Definition: scalar.C:397
double a_spin
Spin parameter of the model.
Definition: compobj.h:928
Scalar ak_car
Scalar .
Definition: compobj.h:318
Lorene prototypes.
Definition: app_hor.h:67
Standard units of space, time and mass.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:777
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
Base class for coordinate mappings.
Definition: map.h:682
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: altBH_QI.C:251
void mult_sint()
Multiplication by .
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 void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
Definition: scalar.C:371
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: scalar.C:359
Sym_tensor kk
Extrinsic curvature tensor .
Definition: compobj.h:156
virtual void extrinsic_curvature()
Computation of the extrinsic curvature.
Definition: compobj.C:293
Scalar a_car
Square of the metric factor A.
Definition: compobj.h:290
Scalar nphi
Metric coefficient .
Definition: compobj.h:299
Scalar b_car
Square of the metric factor B.
Definition: compobj.h:296
virtual double val_r(int l, double xi, double theta, double pphi) const =0
Returns the value of the radial coordinate r for a given in a given domain.
virtual ~AltBH_QI()
Destructor.
Definition: altBH_QI.C:199
Scalar bbb
Metric factor B.
Definition: compobj.h:293
virtual void sauve(FILE *) const
Save in a file.
Definition: altBH_QI.C:243
virtual void homothetie(double lambda)=0
Sets a new radial scale.
void operator=(const AltBH_QI &)
Assignment to another AltBH_QI.
Definition: altBH_QI.C:229
void operator=(const Compobj_QI &)
Assignment to another Compobj_QI.
Definition: compobj_QI.C:198
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
virtual void set_der_0x0() const
Sets to 0x0 all the pointers on derived quantities.
Definition: altBH_QI.C:219
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
Multi-domain grid.
Definition: grilles.h:279
double & set_grid_point(int l, int k, int j, int i)
Setting the value of the field at a given grid point.
Definition: scalar.h:690
Alternative black hole spacetime in Quasi-Isotropic coordinates (under development).
Definition: compobj.h:920
Scalar & set(const Itbl &ind)
Returns the value of a component (read/write version).
Definition: tensor.C:663
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: compobj_QI.C:267
Scalar krphi
K_{(r)(phi)} read in the file.
Definition: compobj.h:930
Scalar nn
Lapse function N .
Definition: compobj.h:138
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
char description1[256]
String describing the model.
Definition: compobj.h:926
char description2[256]
String describing the model.
Definition: compobj.h:927
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: compobj_QI.C:166
Map & mp
Mapping describing the coordinate system (r,theta,phi)
Definition: compobj.h:135