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 char bin_ns_bh_kij_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh_kij.C,v 1.9 2008/09/26 08:44:04 p_grandclement Exp $" ;
00028
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 #include "headcpp.h"
00071
00072
00073 #include <math.h>
00074
00075
00076 #include "bin_ns_bh.h"
00077 #include "proto.h"
00078 #include "utilitaires.h"
00079
00080 #include "graphique.h"
00087 void Et_bin_nsbh::fait_taij_auto() {
00088
00089 Tenseur copie_shift (shift_auto) ;
00090 copie_shift.change_triad(mp.get_bvect_cart()) ;
00091
00092 if (shift_auto.get_etat() == ETATZERO)
00093 taij_auto.set_etat_zero() ;
00094 else {
00095 Tenseur grad (copie_shift.gradient()) ;
00096 Tenseur trace (contract (grad,0, 1)) ;
00097
00098 taij_auto.set_triad(mp.get_bvect_cart()) ;
00099 taij_auto.set_etat_qcq() ;
00100 for (int i=0 ; i<3 ; i++)
00101 for (int j=i ; j<3 ; j++)
00102 taij_auto.set(i, j) = grad(i, j)+grad(j, i) ;
00103 for (int i=0 ; i<3 ; i++)
00104 taij_auto.set(i, i) -= 2./3.*trace() ;
00105 }
00106
00107 taij_auto.change_triad(ref_triad) ;
00108 }
00109
00110 void Bin_ns_bh::fait_decouple () {
00111
00112 int nz_bh = hole.mp.get_mg()->get_nzone() ;
00113 int nz_ns = star.mp.get_mg()->get_nzone() ;
00114
00115
00116 double distance = star.mp.get_ori_x()-hole.mp.get_ori_x() ;
00117 double lim_ns = distance/2. ;
00118 double lim_bh = distance/2. ;
00119 double int_ns = lim_ns/3. ;
00120 double int_bh = lim_bh/3. ;
00121
00122
00123 Cmp decouple_ns (star.mp) ;
00124 decouple_ns.allocate_all() ;
00125 Cmp decouple_bh (hole.mp) ;
00126 decouple_bh.allocate_all() ;
00127
00128 Mtbl xabs_ns (star.mp.xa) ;
00129 Mtbl yabs_ns (star.mp.ya) ;
00130 Mtbl zabs_ns (star.mp.za) ;
00131
00132 Mtbl xabs_bh (hole.mp.xa) ;
00133 Mtbl yabs_bh (hole.mp.ya) ;
00134 Mtbl zabs_bh (hole.mp.za) ;
00135
00136 double xabs, yabs, zabs, air_ns, air_bh, theta, phi ;
00137
00138
00139 for (int l=0 ; l<nz_ns ; l++) {
00140 int nr = star.mp.get_mg()->get_nr (l) ;
00141
00142 if (l==nz_ns-1)
00143 nr -- ;
00144
00145 int np = star.mp.get_mg()->get_np (l) ;
00146 int nt = star.mp.get_mg()->get_nt (l) ;
00147
00148 for (int k=0 ; k<np ; k++)
00149 for (int j=0 ; j<nt ; j++)
00150 for (int i=0 ; i<nr ; i++) {
00151
00152 xabs = xabs_ns (l, k, j, i) ;
00153 yabs = yabs_ns (l, k, j, i) ;
00154 zabs = zabs_ns (l, k, j, i) ;
00155
00156
00157 star.mp.convert_absolute
00158 (xabs, yabs, zabs, air_ns, theta, phi) ;
00159 hole.mp.convert_absolute
00160 (xabs, yabs, zabs, air_bh, theta, phi) ;
00161
00162 if (air_ns <= lim_ns)
00163 if (air_ns < int_ns)
00164 decouple_ns.set(l, k, j, i) = 1 ;
00165 else
00166 decouple_ns.set(l, k, j, i) =
00167 0.5*pow(cos((air_ns-int_ns)*M_PI/2./(lim_ns-int_ns)), 2.)+0.5
00168 ;
00169 else
00170 if (air_bh <= lim_bh)
00171 if (air_bh < int_bh)
00172 decouple_ns.set(l, k, j, i) = 0 ;
00173 else
00174 decouple_ns.set(l, k, j, i) = 0.5*
00175 pow(sin((air_bh-int_bh)*M_PI/2./(lim_bh-int_bh)), 2.)
00176 ;
00177 else
00178
00179 decouple_ns.set(l, k, j, i) = 0.5 ;
00180 }
00181
00182
00183 if (l==nz_ns-1)
00184 for (int k=0 ; k<np ; k++)
00185 for (int j=0 ; j<nt ; j++)
00186 decouple_ns.set(nz_ns-1, k, j, nr) = 0.5 ;
00187 }
00188
00189 for (int l=0 ; l<nz_bh ; l++) {
00190 int nr = hole.mp.get_mg()->get_nr (l) ;
00191
00192 if (l==nz_bh-1)
00193 nr -- ;
00194
00195 int np = hole.mp.get_mg()->get_np (l) ;
00196 int nt = hole.mp.get_mg()->get_nt (l) ;
00197
00198 for (int k=0 ; k<np ; k++)
00199 for (int j=0 ; j<nt ; j++)
00200 for (int i=0 ; i<nr ; i++) {
00201
00202 xabs = xabs_bh (l, k, j, i) ;
00203 yabs = yabs_bh (l, k, j, i) ;
00204 zabs = zabs_bh (l, k, j, i) ;
00205
00206
00207 star.mp.convert_absolute
00208 (xabs, yabs, zabs, air_ns, theta, phi) ;
00209 hole.mp.convert_absolute
00210 (xabs, yabs, zabs, air_bh, theta, phi) ;
00211
00212 if (air_bh <= lim_bh)
00213 if (air_bh < int_bh)
00214 decouple_bh.set(l, k, j, i) = 1 ;
00215 else
00216 decouple_bh.set(l, k, j, i) = 0.5*
00217 pow(cos((air_bh-int_bh)*M_PI/2./(lim_bh-int_bh)), 2.)+0.5 ;
00218 else
00219 if (air_ns <= lim_ns)
00220 if (air_ns < int_ns)
00221 decouple_bh.set(l, k, j, i) = 0 ;
00222 else
00223 decouple_bh.set(l, k, j, i) = 0.5*
00224 pow(sin((air_ns-int_ns)*M_PI/2./(lim_ns-int_ns)), 2.) ;
00225
00226 else
00227
00228 decouple_bh.set(l, k, j, i) = 0.5 ;
00229 }
00230
00231
00232 if (l==nz_bh-1)
00233 for (int k=0 ; k<np ; k++)
00234 for (int j=0 ; j<nt ; j++)
00235 decouple_bh.set(nz_bh-1, k, j, nr) = 0.5 ;
00236 }
00237
00238 decouple_ns.std_base_scal() ;
00239 decouple_bh.std_base_scal() ;
00240
00241 star.decouple = decouple_ns ;
00242 hole.decouple = decouple_bh ;
00243 }
00244
00245
00246
00247
00248 void Bin_ns_bh::fait_tkij (int bound_nn, double lim_nn) {
00249
00250 fait_decouple() ;
00251
00252 double norme_hole = 0 ;
00253 double norme_star = 0 ;
00254
00255 for (int i=0 ; i<3 ; i++) {
00256 norme_hole += max(norme(hole.get_shift_auto()(i))) ;
00257 norme_star += max(norme(star.get_shift_auto()(i))) ;
00258 }
00259
00260 #ifndef NDEBUG
00261 bool zero_shift_hole = (norme_hole <1e-14) ? true : false ;
00262 #endif
00263 bool zero_shift_star = (norme_star <1e-14) ? true : false ;
00264
00265 assert (zero_shift_hole == zero_shift_star) ;
00266
00267 if (zero_shift_star == true) {
00268 hole.tkij_tot.set_etat_zero() ;
00269 hole.tkij_auto.set_etat_zero() ;
00270
00271 hole.taij_tot.set_etat_zero() ;
00272 hole.taij_auto.set_etat_zero() ;
00273 hole.taij_comp.set_etat_zero() ;
00274
00275 star.tkij_auto.set_etat_zero() ;
00276 star.tkij_comp.set_etat_zero() ;
00277 star.akcar_comp.set_etat_zero() ;
00278 star.akcar_auto.set_etat_zero() ;
00279 }
00280 else {
00281
00282 if (bound_nn < 0){
00283 int nnt = hole.mp.get_mg()->get_nt(1) ;
00284 int nnp = hole.mp.get_mg()->get_np(1) ;
00285
00286 for (int k=0; k<nnp; k++)
00287 for (int j=0; j<nnt; j++){
00288 if (fabs((hole.n_auto+hole.n_comp)()(1, k, j , 0)) < 1e-2){
00289 bound_nn = 0 ;
00290 lim_nn = 0. ;
00291 break ;
00292 }
00293 }
00294 }
00295
00296 if (bound_nn != 0 || lim_nn != 0){
00297
00298 hole.fait_taij_auto () ;
00299 star.fait_taij_auto() ;
00300
00301
00302 hole.taij_comp.set_etat_qcq() ;
00303
00304 Tenseur_sym ns_taij_comp (star.mp, 2, CON, ref_triad) ;
00305 ns_taij_comp.set_etat_qcq() ;
00306
00307 Tenseur_sym copie_ns (star.taij_auto) ;
00308 copie_ns.dec2_dzpuis() ;
00309 Tenseur_sym copie_bh (hole.taij_auto) ;
00310 copie_bh.dec2_dzpuis() ;
00311
00312
00313 if (hole.taij_auto.get_etat() == ETATZERO)
00314 ns_taij_comp.set_etat_zero() ;
00315 else {
00316 ns_taij_comp.set(0, 0).import(copie_bh(0, 0)) ;
00317 ns_taij_comp.set(0, 1).import(copie_bh(0, 1)) ;
00318 ns_taij_comp.set(0, 2).import(copie_bh(0, 2)) ;
00319 ns_taij_comp.set(1, 1).import(copie_bh(1, 1)) ;
00320 ns_taij_comp.set(1, 2).import(copie_bh(1, 2)) ;
00321 ns_taij_comp.set(2, 2).import(copie_bh(2, 2)) ;
00322 ns_taij_comp.set_triad(*copie_bh.get_triad()) ;
00323 ns_taij_comp.change_triad(star.ref_triad) ;
00324 }
00325
00326 if (star.taij_auto.get_etat() == ETATZERO)
00327 hole.taij_comp.set_etat_zero() ;
00328 else {
00329 hole.taij_comp.set(0, 0).import(copie_ns(0, 0)) ;
00330 hole.taij_comp.set(0, 1).import(copie_ns(0, 1)) ;
00331 hole.taij_comp.set(0, 2).import(copie_ns(0, 2)) ;
00332 hole.taij_comp.set(1, 1).import(copie_ns(1, 1)) ;
00333 hole.taij_comp.set(1, 2).import(copie_ns(1, 2)) ;
00334 hole.taij_comp.set(2, 2).import(copie_ns(2, 2)) ;
00335 hole.taij_comp.set_triad(*copie_ns.get_triad()) ;
00336 hole.taij_comp.change_triad (hole.mp.get_bvect_cart()) ;
00337 }
00338
00339 hole.taij_comp.set_std_base() ;
00340 ns_taij_comp.set_std_base() ;
00341 hole.taij_comp.inc2_dzpuis() ;
00342 ns_taij_comp.inc2_dzpuis() ;
00343
00344
00345 hole.taij_tot = hole.taij_auto + hole.taij_comp ;
00346 Tenseur_sym ns_taij_tot (star.taij_auto + ns_taij_comp) ;
00347 star.taij_tot = ns_taij_tot ;
00348
00349
00350 star.tkij_tot.set_etat_qcq() ;
00351 star.tkij_auto.set_etat_qcq() ;
00352 star.tkij_comp.set_etat_qcq() ;
00353 hole.tkij_tot.set_etat_qcq() ;
00354 hole.tkij_auto.set_etat_qcq() ;
00355
00356 for (int i = 0 ; i<3 ; i++)
00357 for (int j = i ; j<3 ; j++) {
00358 star.tkij_tot.set(i,j) = 0.5*star.taij_tot(i,j)/star.nnn() ;
00359
00360
00361 hole.tkij_tot.set(i,j) = 0.5*hole.taij_tot(i,j)/hole.n_tot() ;
00362
00363 }
00364
00365 for (int lig=0 ; lig<3 ; lig++)
00366 for (int col=lig ; col<3 ; col++) {
00367 star.tkij_auto.set(lig, col) = star.tkij_tot(lig, col)*
00368 star.decouple ;
00369 star.tkij_comp.set(lig, col) = star.tkij_tot(lig, col)*
00370 (1-star.decouple) ;
00371 hole.tkij_auto.set(lig, col) = hole.tkij_tot(lig, col)*
00372 hole.decouple ;
00373 }
00374 star.tkij_auto.set_std_base() ;
00375 star.tkij_comp.set_std_base() ;
00376 hole.tkij_auto.set_std_base() ;
00377 }
00378 else {
00379
00380 hole.tkij_tot.set_etat_qcq() ;
00381 star.tkij_tot.set_etat_qcq() ;
00382
00383
00384
00385 hole.fait_taij_auto () ;
00386 star.fait_taij_auto() ;
00387
00388
00389 hole.taij_comp.set_etat_qcq() ;
00390
00391 Tenseur_sym ns_taij_comp (star.mp, 2, CON, ref_triad) ;
00392 ns_taij_comp.set_etat_qcq() ;
00393
00394 Tenseur_sym copie_ns (star.taij_auto) ;
00395 copie_ns.dec2_dzpuis() ;
00396 Tenseur_sym copie_bh (hole.taij_auto) ;
00397 copie_bh.dec2_dzpuis() ;
00398
00399
00400 if (hole.taij_auto.get_etat() == ETATZERO)
00401 ns_taij_comp.set_etat_zero() ;
00402 else {
00403 ns_taij_comp.set(0, 0).import_asymy(copie_bh(0, 0)) ;
00404 ns_taij_comp.set(0, 1).import_symy(copie_bh(0, 1)) ;
00405 ns_taij_comp.set(0, 2).import_asymy(copie_bh(0, 2)) ;
00406 ns_taij_comp.set(1, 1).import_asymy(copie_bh(1, 1)) ;
00407 ns_taij_comp.set(1, 2).import_symy(copie_bh(1, 2)) ;
00408 ns_taij_comp.set(2, 2).import_asymy(copie_bh(2, 2)) ;
00409 ns_taij_comp.set_triad(*copie_bh.get_triad()) ;
00410 ns_taij_comp.change_triad(star.ref_triad) ;
00411 }
00412
00413 if (star.taij_auto.get_etat() == ETATZERO)
00414 hole.taij_comp.set_etat_zero() ;
00415 else {
00416 hole.taij_comp.set(0, 0).import_asymy(copie_ns(0, 0)) ;
00417 hole.taij_comp.set(0, 1).import_symy(copie_ns(0, 1)) ;
00418 hole.taij_comp.set(0, 2).import_asymy(copie_ns(0, 2)) ;
00419 hole.taij_comp.set(1, 1).import_asymy(copie_ns(1, 1)) ;
00420 hole.taij_comp.set(1, 2).import_symy(copie_ns(1, 2)) ;
00421 hole.taij_comp.set(2, 2).import_asymy(copie_ns(2, 2)) ;
00422 hole.taij_comp.set_triad(*copie_ns.get_triad()) ;
00423 hole.taij_comp.change_triad (hole.mp.get_bvect_cart()) ;
00424 }
00425
00426 hole.taij_comp.set_std_base() ;
00427 ns_taij_comp.set_std_base() ;
00428 hole.taij_comp.inc2_dzpuis() ;
00429 ns_taij_comp.inc2_dzpuis() ;
00430
00431
00432 hole.taij_tot = hole.taij_auto + hole.taij_comp ;
00433 Tenseur_sym ns_taij_tot (star.taij_auto + ns_taij_comp) ;
00434 star.taij_tot = ns_taij_tot ;
00435
00436 int nz_ns = star.mp.get_mg()->get_nzone() ;
00437 Cmp ntot_ns (star.get_nnn()()) ;
00438
00439 Cmp ntot_bh (hole.n_tot()) ;
00440
00441 ntot_bh = division_xpun (ntot_bh, 0) ;
00442 ntot_bh.raccord(1) ;
00443
00444
00445
00446
00447 for (int lig = 0 ; lig<3 ; lig++)
00448 for (int col = lig ; col<3 ; col++) {
00449
00450
00451 Cmp auxi_bh (hole.taij_tot(lig, col)/2.) ;
00452 auxi_bh.dec2_dzpuis() ;
00453 auxi_bh = division_xpun (auxi_bh, 0) ;
00454
00455
00456 auxi_bh = auxi_bh / ntot_bh ;
00457 auxi_bh.raccord(1) ;
00458
00459
00460 Cmp auxi_ns (star.mp) ;
00461 auxi_ns.allocate_all() ;
00462
00463
00464 Cmp copie_ns_bis (ns_taij_tot(lig, col)) ;
00465 copie_ns_bis.dec2_dzpuis() ;
00466
00467
00468 double lim_bh = hole.mp.get_alpha()[1] + hole.mp.get_beta()[1] ;
00469
00470 Mtbl xabs_ns (star.mp.xa) ;
00471 Mtbl yabs_ns (star.mp.ya) ;
00472 Mtbl zabs_ns (star.mp.za) ;
00473
00474 double xabs, yabs, zabs, air, theta, phi ;
00475
00476
00477 for (int l=0 ; l<nz_ns ; l++) {
00478
00479 int nr = star.mp.get_mg()->get_nr (l) ;
00480
00481 if (l==nz_ns-1)
00482 nr -- ;
00483
00484 int np = star.mp.get_mg()->get_np (l) ;
00485 int nt = star.mp.get_mg()->get_nt (l) ;
00486
00487 for (int k=0 ; k<np ; k++)
00488 for (int j=0 ; j<nt ; j++)
00489 for (int i=0 ; i<nr ; i++) {
00490
00491 xabs = xabs_ns (l, k, j, i) ;
00492 yabs = yabs_ns (l, k, j, i) ;
00493 zabs = zabs_ns (l, k, j, i) ;
00494
00495
00496 hole.mp.convert_absolute
00497 (xabs, yabs, zabs, air, theta, phi) ;
00498
00499 if (air >= lim_bh)
00500
00501 auxi_ns.set(l, k, j, i) =
00502 copie_ns_bis(l, k, j, i) / ntot_ns (l, k, j, i)/2. ;
00503 else
00504
00505 auxi_ns.set(l, k, j, i) = auxi_bh.val_point (air, theta, phi) ;
00506 }
00507
00508
00509 if (l==nz_ns-1)
00510 for (int k=0 ; k<np ; k++)
00511 for (int j=0 ; j<nt ; j++)
00512 auxi_ns.set(nz_ns-1, k, j, nr) = 0 ;
00513 }
00514
00515
00516 star.tkij_tot.set(lig, col) = auxi_ns ;
00517 hole.tkij_tot.set(lig, col) = auxi_bh ;
00518 }
00519
00520 star.tkij_tot.set_std_base() ;
00521 hole.tkij_tot.set_std_base() ;
00522 star.tkij_tot.inc2_dzpuis() ;
00523
00524 hole.tkij_tot.inc2_dzpuis() ;
00525
00526
00527
00528
00529
00530
00531 star.tkij_auto.set_etat_qcq() ;
00532 star.tkij_comp.set_etat_qcq() ;
00533 hole.tkij_auto.set_etat_qcq() ;
00534
00535 for (int lig=0 ; lig<3 ; lig++)
00536 for (int col=lig ; col<3 ; col++) {
00537 star.tkij_auto.set(lig, col) = star.tkij_tot(lig, col)*
00538 star.decouple ;
00539 star.tkij_comp.set(lig, col) = star.tkij_tot(lig, col)*
00540 (1-star.decouple) ;
00541 hole.tkij_auto.set(lig, col) = hole.tkij_tot(lig, col)*
00542 hole.decouple ;
00543 }
00544 star.tkij_auto.set_std_base() ;
00545 star.tkij_comp.set_std_base() ;
00546 hole.tkij_auto.set_std_base() ;
00547
00548 }
00549
00550
00551 star.akcar_auto.set_etat_qcq() ;
00552 star.akcar_auto.set() = 0 ;
00553
00554 for (int i=0; i<3; i++)
00555 for (int j=0; j<3; j++)
00556 star.akcar_auto.set() += star.tkij_auto(i, j) % star.tkij_auto(i, j) ;
00557
00558 star.akcar_auto.set_std_base() ;
00559 star.akcar_auto = star.a_car % star.akcar_auto ;
00560
00561 star.akcar_comp.set_etat_qcq() ;
00562 star.akcar_comp.set() = 0 ;
00563
00564 for (int i=0; i<3; i++)
00565 for (int j=0; j<3; j++)
00566 star.akcar_comp.set() += star.tkij_auto(i, j) % star.tkij_comp(i, j) ;
00567
00568 star.akcar_comp.set_std_base() ;
00569 star.akcar_comp = star.a_car % star.akcar_comp ;
00570 }
00571 }