00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 char tslice_dirac_max_C[] = "$Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_dirac_max.C,v 1.24 2008/12/04 18:22:49 j_novak Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 #include <assert.h>
00127
00128
00129 #include "time_slice.h"
00130 #include "utilitaires.h"
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 Tslice_dirac_max::Tslice_dirac_max(const Scalar& lapse_in, const Vector& shift_in,
00143 const Metric_flat& ff_in, const Scalar& psi_in,
00144 const Sym_tensor_trans& hh_in, const Sym_tensor& hata_in,
00145 int depth_in)
00146 : Time_slice_conf( lapse_in, shift_in, ff_in, psi_in, hh_in, hata_in,
00147 0*lapse_in, depth_in),
00148 A_hh_evol(depth_in), B_hh_evol(depth_in), source_A_hh_evol(depth_in),
00149 source_B_hh_evol(depth_in), source_A_hata_evol(depth_in) ,
00150 source_B_hata_evol(depth_in), trh_evol(hh_in.the_trace(), depth_in)
00151 { }
00152
00153
00154
00155
00156 Tslice_dirac_max::Tslice_dirac_max(const Map& mp, const Base_vect& triad,
00157 const Metric_flat& ff_in, int depth_in)
00158 : Time_slice_conf(mp, triad, ff_in, depth_in),
00159 A_hh_evol(depth_in), B_hh_evol(depth_in),
00160 source_A_hh_evol(depth_in), source_B_hh_evol(depth_in),
00161 source_A_hata_evol(depth_in), source_B_hata_evol(depth_in),
00162 trh_evol(depth_in) {
00163
00164 double time_init = the_time[jtime] ;
00165
00166
00167 Scalar tmp(mp) ;
00168 tmp.set_etat_zero() ;
00169 A_hh_evol.update(tmp, jtime, time_init) ;
00170 B_hh_evol.update(tmp, jtime, time_init) ;
00171
00172 source_A_hh_evol.update(tmp, jtime, time_init) ;
00173 source_B_hh_evol.update(tmp, jtime, time_init) ;
00174
00175 source_A_hata_evol.update(tmp, jtime, time_init) ;
00176 source_B_hata_evol.update(tmp, jtime, time_init) ;
00177
00178
00179 trh_evol.update(tmp, jtime, time_init) ;
00180 }
00181
00182
00183
00184
00185
00186 Tslice_dirac_max::Tslice_dirac_max(const Map& mp, const Base_vect& triad,
00187 const Metric_flat& ff_in, FILE* fich,
00188 bool partial_read, int depth_in)
00189 : Time_slice_conf(mp, triad, ff_in, fich, true, depth_in),
00190 A_hh_evol(depth_in), B_hh_evol(depth_in),
00191 source_A_hh_evol(depth_in), source_B_hh_evol(depth_in),
00192 source_A_hata_evol(depth_in), source_B_hata_evol(depth_in),
00193 trh_evol(depth_in) {
00194
00195 if (partial_read) {
00196 cout <<
00197 "Constructor of Tslice_dirac_max from file: the case of partial reading\n"
00198 << " is not ready yet !"
00199 << endl ;
00200 abort() ;
00201 }
00202
00203
00204
00205
00206 int jmin = jtime - depth + 1 ;
00207 int indicator ;
00208
00209
00210 for (int j=jmin; j<=jtime; j++) {
00211 fread_be(&indicator, sizeof(int), 1, fich) ;
00212 if (indicator == 1) {
00213 Sym_tensor hh_file(mp, triad, fich) ;
00214 hh_evol.update(hh_file, j, the_time[j]) ;
00215 }
00216 }
00217
00218
00219 for (int j=jmin; j<=jtime; j++) {
00220 fread_be(&indicator, sizeof(int), 1, fich) ;
00221 if (indicator == 1) {
00222 Scalar A_hh_file(mp, *(mp.get_mg()), fich) ;
00223 A_hh_evol.update(A_hh_file, j, the_time[j]) ;
00224 }
00225 }
00226
00227
00228 for (int j=jmin; j<=jtime; j++) {
00229 fread_be(&indicator, sizeof(int), 1, fich) ;
00230 if (indicator == 1) {
00231 Scalar B_hh_file(mp, *(mp.get_mg()), fich) ;
00232 B_hh_evol.update(B_hh_file, j, the_time[j]) ;
00233 }
00234 }
00235 }
00236
00237
00238
00239
00240 Tslice_dirac_max::Tslice_dirac_max(const Star_rot_Dirac& star, double pdt, int depth_in)
00241 : Time_slice_conf(star.get_nn(), star.get_beta(), star.get_mp().flat_met_spher(),
00242 0.*star.get_nn(), star.get_hh(), 0.*star.get_aa(),
00243 0.*star.get_nn(), depth_in),
00244 A_hh_evol(depth_in), B_hh_evol(depth_in),
00245 source_A_hh_evol(depth_in), source_B_hh_evol(depth_in),
00246 source_A_hata_evol(depth_in), source_B_hata_evol(depth_in),
00247 trh_evol(depth_in) {
00248
00249 Scalar tmp = exp(star.get_ln_psi()) ;
00250 tmp.std_spectral_base() ;
00251 psi_evol.downdate(jtime) ;
00252 psi_evol.update(tmp, jtime, the_time[jtime]) ;
00253
00254 Sym_tensor tmp2 = psi4()*psi()*psi()*star.get_aa() ;
00255 hata_evol.downdate(jtime) ;
00256 hata_evol.update(tmp2, jtime, the_time[jtime]) ;
00257
00258 A_hh() ;
00259 B_hh() ;
00260 A_hata() ;
00261 B_hata() ;
00262 compute_sources() ;
00263
00264
00265
00266 double ttime1 = the_time[jtime] ;
00267 int jtime1 = jtime ;
00268 for (int j=1; j < depth; j++) {
00269 jtime1++ ;
00270 ttime1 += pdt ;
00271 psi_evol.update(psi_evol[jtime], jtime1, ttime1) ;
00272 n_evol.update(n_evol[jtime], jtime1, ttime1) ;
00273 beta_evol.update(beta_evol[jtime], jtime1, ttime1) ;
00274 hh_evol.update(hh_evol[jtime], jtime1, ttime1) ;
00275 trk_evol.update(trk_evol[jtime], jtime1, ttime1) ;
00276 A_hh_evol.update(A_hh_evol[jtime], jtime1, ttime1) ;
00277 B_hh_evol.update(B_hh_evol[jtime], jtime1, ttime1) ;
00278 A_hata_evol.update(A_hata_evol[jtime], jtime1, ttime1) ;
00279 B_hata_evol.update(B_hata_evol[jtime], jtime1, ttime1) ;
00280 trh_evol.update(trh_evol[jtime], jtime1, ttime1) ;
00281 k_dd_evol.update(k_dd_evol[jtime], jtime1, ttime1) ;
00282 the_time.update(ttime1, jtime1, ttime1) ;
00283 }
00284 jtime += depth - 1 ;
00285
00286 initialize_sources_copy() ;
00287 }
00288
00289
00290
00291
00292 Tslice_dirac_max::Tslice_dirac_max(const Tslice_dirac_max& tin)
00293 : Time_slice_conf(tin),
00294 A_hh_evol(tin.A_hh_evol),
00295 B_hh_evol(tin.B_hh_evol),
00296 source_A_hh_evol(tin.source_A_hh_evol),
00297 source_B_hh_evol(tin.source_B_hh_evol),
00298 source_A_hata_evol(tin.source_A_hata_evol),
00299 source_B_hata_evol(tin.source_B_hata_evol),
00300 trh_evol(tin.trh_evol) { }
00301
00302
00303
00304
00305
00306
00307 Tslice_dirac_max::~Tslice_dirac_max(){ }
00308
00309
00310
00311
00312
00313
00314 void Tslice_dirac_max::operator=(const Tslice_dirac_max& tin) {
00315
00316 Time_slice_conf::operator=(tin) ;
00317
00318 A_hh_evol = tin.A_hh_evol ;
00319 B_hh_evol = tin.B_hh_evol ;
00320 source_A_hh_evol = tin.source_A_hh_evol ;
00321 source_B_hh_evol = tin.source_B_hh_evol ;
00322 source_A_hata_evol = tin.source_A_hata_evol ;
00323 source_B_hata_evol = tin.source_B_hata_evol ;
00324 trh_evol = tin.trh_evol ;
00325
00326 }
00327
00328
00329 void Tslice_dirac_max::set_hh(const Sym_tensor& hh_in) {
00330
00331 Time_slice_conf::set_hh(hh_in) ;
00332
00333
00334 A_hh_evol.downdate(jtime) ;
00335 B_hh_evol.downdate(jtime) ;
00336 source_A_hh_evol.downdate(jtime) ;
00337 source_B_hh_evol.downdate(jtime) ;
00338 source_A_hata_evol.downdate(jtime) ;
00339 source_B_hata_evol.downdate(jtime) ;
00340 trh_evol.downdate(jtime) ;
00341
00342 }
00343
00344
00345 void Tslice_dirac_max::initial_data_cts(const Sym_tensor& uu,
00346 const Scalar& trk_in, const Scalar& trk_point,
00347 double pdt, double precis, int method_poisson_vect,
00348 const char* graph_device, const Scalar* p_ener_dens,
00349 const Vector* p_mom_dens, const Scalar* p_trace_stress) {
00350
00351
00352 Time_slice_conf::initial_data_cts(uu, trk_in, trk_point, pdt, precis,
00353 method_poisson_vect, graph_device,
00354 p_ener_dens, p_mom_dens, p_trace_stress) ;
00355
00356 int nz = trk_in.get_mp().get_mg()->get_nzone() ;
00357
00358
00359 for (int j = jtime-depth+1 ; j <= jtime; j++) {
00360
00361
00362 Scalar tmp = hh_evol[j].compute_A(true) ;
00363 assert (tmp.get_etat() != ETATNONDEF) ;
00364 if (tmp.get_etat() != ETATZERO) {
00365 assert(tmp.get_mp().get_mg()->get_type_r(nz-1) == UNSURR) ;
00366 tmp.annule_domain(nz-1) ;
00367 }
00368 tmp.set_dzpuis(0) ;
00369 A_hh_evol.update(tmp, j, the_time[j]) ;
00370
00371 tmp = hh_evol[jtime].compute_tilde_B_tt(true) ;
00372 assert (tmp.get_etat() != ETATNONDEF) ;
00373 if (tmp.get_etat() != ETATZERO) {
00374 assert(tmp.get_mp().get_mg()->get_type_r(nz-1) == UNSURR) ;
00375 tmp.annule_domain(nz-1) ;
00376 }
00377 tmp.set_dzpuis(0) ;
00378 B_hh_evol.update(tmp, j, the_time[j]) ;
00379 }
00380
00381 cout << endl <<
00382 "Tslice_dirac_max::initial_data_cts : variation of A and tilde(B) for J = "
00383 << jtime << " :\n" ;
00384 maxabs(A_hh_evol[jtime] - A_hh_evol[jtime-1], "A(h)^J - A(h)^{J-1}") ;
00385
00386 maxabs(B_hh_evol[jtime] - B_hh_evol[jtime-1], "B(h)^J - B(h)^{J-1}") ;
00387
00388 maxabs(A_hata_evol[jtime] - A_hata_evol[jtime-1], "A(hat{A})^J - A(hat{A})^{J-1}") ;
00389
00390 maxabs(B_hata_evol[jtime] - B_hata_evol[jtime-1], "B(hat{A})^J - B(hat{A})^{J-1}") ;
00391
00392
00393
00394 del_deriv() ;
00395
00396 compute_sources() ;
00397 initialize_sources_copy() ;
00398 }
00399
00400
00401 void Tslice_dirac_max::set_khi_mu(const Scalar& khi_in, const Scalar& mu_in) {
00402
00403 const Map& mp = khi_in.get_mp() ;
00404
00405 Sym_tensor_tt hh_tt(mp, mp.get_bvect_spher(), mp.flat_met_spher());
00406 hh_tt.set_khi_mu(khi_in, mu_in, 2) ;
00407
00408 Sym_tensor_trans hh_tmp(mp, mp.get_bvect_spher(), mp.flat_met_spher());
00409 hh_tmp.trace_from_det_one(hh_tt) ;
00410
00411
00412
00413 Scalar tmp = hh_tmp.the_trace() ;
00414 tmp.dec_dzpuis(4) ;
00415 trh_evol.update(tmp, jtime, the_time[jtime]) ;
00416
00417
00418 Vector wzero(mp, CON, *(ff.get_triad())) ;
00419 wzero.set_etat_zero() ;
00420
00421
00422 Sym_tensor hh_new(mp, CON, *(ff.get_triad())) ;
00423
00424 hh_new.set_longit_trans(wzero, hh_tmp) ;
00425
00426 hh_evol.update(hh_new, jtime, the_time[jtime]) ;
00427
00428 }
00429
00430 void Tslice_dirac_max::set_trh(const Scalar& trh_in) {
00431
00432 trh_evol.update(trh_in, jtime, the_time[jtime]) ;
00433 cout << "Tslice_dirac_max::set_trh : #### WARNING : \n"
00434 << " this method does not check whether det(tilde gamma) = 1"
00435 << endl ;
00436
00437
00438 hh_evol.downdate(jtime) ;
00439 if (p_tgamma != 0x0) {
00440 delete p_tgamma ;
00441 p_tgamma = 0x0 ;
00442 }
00443 if (p_hdirac != 0x0) {
00444 delete p_hdirac ;
00445 p_hdirac = 0x0 ;
00446 }
00447 if (p_gamma != 0x0) {
00448 delete p_gamma ;
00449 p_gamma = 0x0 ;
00450 }
00451 source_A_hh_evol.downdate(jtime) ;
00452 source_B_hh_evol.downdate(jtime) ;
00453 source_A_hata_evol.downdate(jtime) ;
00454 source_B_hata_evol.downdate(jtime) ;
00455 gam_dd_evol.downdate(jtime) ;
00456 gam_uu_evol.downdate(jtime) ;
00457 adm_mass_evol.downdate(jtime) ;
00458
00459 }
00460
00461
00462
00463
00464
00465
00466
00467 const Sym_tensor& Tslice_dirac_max::hh(Param* par_bc, Param* par_mat) const {
00468
00469 if (!( hh_evol.is_known(jtime) ) ) {
00470
00471 assert (A_hh_evol.is_known(jtime)) ;
00472 assert (B_hh_evol.is_known(jtime)) ;
00473
00474
00475
00476 hh_det_one(jtime, par_bc, par_mat) ;
00477 }
00478
00479 return hh_evol[jtime] ;
00480
00481 }
00482
00483
00484 const Scalar& Tslice_dirac_max::trk() const {
00485
00486 if( !(trk_evol.is_known(jtime)) ) {
00487
00488 Scalar resu(ff.get_mp()) ;
00489 resu.set_etat_zero() ;
00490
00491 trk_evol.update(resu, jtime, the_time[jtime]) ;
00492
00493 }
00494
00495 return trk_evol[jtime] ;
00496
00497 }
00498
00499
00500 const Vector& Tslice_dirac_max::hdirac() const {
00501
00502 if (p_hdirac == 0x0) {
00503 p_hdirac = new Vector(ff.get_mp(), CON, ff.get_triad() ) ;
00504 p_hdirac->set_etat_zero() ;
00505 }
00506
00507 return *p_hdirac ;
00508
00509 }
00510
00511
00512
00513
00514
00515
00516
00517
00518 const Scalar& Tslice_dirac_max::A_hh() const {
00519
00520 if (!( A_hh_evol.is_known(jtime) ) ) {
00521 assert( hh_evol.is_known(jtime) ) ;
00522
00523 A_hh_evol.update( hh_evol[jtime].compute_A(true), jtime, the_time[jtime] ) ;
00524
00525 }
00526 return A_hh_evol[jtime] ;
00527 }
00528
00529 const Scalar& Tslice_dirac_max::B_hh() const {
00530
00531 if (!( B_hh_evol.is_known(jtime) ) ) {
00532 assert( hh_evol.is_known(jtime) ) ;
00533
00534 B_hh_evol.update( hh_evol[jtime].compute_tilde_B_tt(true), jtime, the_time[jtime] ) ;
00535
00536 }
00537 return B_hh_evol[jtime] ;
00538 }
00539
00540 const Scalar& Tslice_dirac_max::trh() const {
00541
00542 if( !(trh_evol.is_known(jtime)) ) {
00543
00544
00545 hh_det_one(jtime) ;
00546
00547 }
00548
00549 return trh_evol[jtime] ;
00550
00551 }
00552
00553
00554
00555
00556
00557
00558
00559 ostream& Tslice_dirac_max::operator>>(ostream& flux) const {
00560
00561 Time_slice_conf::operator>>(flux) ;
00562
00563 flux << "Dirac gauge and maximal slicing" << '\n' ;
00564
00565 if (A_hh_evol.is_known(jtime)) {
00566 maxabs( A_hh_evol[jtime], "A_hh", flux) ;
00567 }
00568 if (B_hh_evol.is_known(jtime)) {
00569 maxabs( B_hh_evol[jtime], "B_hh", flux) ;
00570 }
00571 if (trh_evol.is_known(jtime)) {
00572 maxabs( trh_evol[jtime], "tr h", flux) ;
00573 }
00574
00575 return flux ;
00576
00577 }
00578
00579
00580 void Tslice_dirac_max::sauve(FILE* fich, bool partial_save) const {
00581
00582 if (partial_save) {
00583 cout <<
00584 "Tslice_dirac_max::sauve : the partial_save case is not ready yet !"
00585 << endl ;
00586 abort() ;
00587 }
00588
00589
00590
00591
00592 Time_slice_conf::sauve(fich, true) ;
00593
00594
00595
00596
00597 int jmin = jtime - depth + 1 ;
00598
00599
00600 assert( hh_evol.is_known(jtime) ) ;
00601 for (int j=jmin; j<=jtime; j++) {
00602 int indicator = (hh_evol.is_known(j)) ? 1 : 0 ;
00603 fwrite_be(&indicator, sizeof(int), 1, fich) ;
00604 if (indicator == 1) hh_evol[j].sauve(fich) ;
00605 }
00606
00607
00608 A_hh() ;
00609 for (int j=jmin; j<=jtime; j++) {
00610 int indicator = (A_hh_evol.is_known(j)) ? 1 : 0 ;
00611 fwrite_be(&indicator, sizeof(int), 1, fich) ;
00612 if (indicator == 1) A_hh_evol[j].sauve(fich) ;
00613 }
00614
00615
00616 B_hh() ;
00617 for (int j=jmin; j<=jtime; j++) {
00618 int indicator = (B_hh_evol.is_known(j)) ? 1 : 0 ;
00619 fwrite_be(&indicator, sizeof(int), 1, fich) ;
00620 if (indicator == 1) B_hh_evol[j].sauve(fich) ;
00621 }
00622 }
00623
00624
00625
00626
00627
00628
00629