68 const double& sepa,
bool kerrschild,
69 int mer,
int mermax_ns,
int mermax_potvit,
70 int mermax_poisson,
int filter_r,
71 int filter_r_s,
int filter_p_s,
72 double relax_poisson,
double relax_potvit,
73 double thres_adapt,
double resize_ns,
74 const Tbl& fact_resize,
Tbl& diff) {
83 const Mg3d* mg =
mp.get_mg() ;
92 int i_b = mg->
get_nr(l_b) - 1 ;
102 double& diff_ent = diff.
set(0) ;
103 double& diff_vel_pot = diff.
set(1) ;
104 double& diff_lapconf = diff.
set(2) ;
105 double& diff_confo = diff.
set(3) ;
106 double& diff_shift_x = diff.
set(4) ;
107 double& diff_shift_y = diff.
set(5) ;
108 double& diff_shift_z = diff.
set(6) ;
109 double& diff_dHdr = diff.
set(7) ;
110 double& diff_dHdr_min = diff.
set(8) ;
111 double& diff_phi_min = diff.
set(9) ;
112 double& diff_radius = diff.
set(10) ;
125 int nz_search =
nzet + 1 ;
128 double precis_secant = 1.e-14 ;
130 double reg_map = 1. ;
134 par_adapt.
add_int(nitermax, 0) ;
139 par_adapt.
add_int(nz_search, 2) ;
141 par_adapt.
add_int(adapt_flag, 3) ;
157 par_adapt.
add_tbl(ent_limit, 0) ;
166 double precis_poisson = 1.e-14 ;
173 par_lapconf.
add_int(mermax_poisson, 0) ;
184 par_confo.
add_int(mermax_poisson, 0) ;
195 par_shift2.
add_int(mermax_poisson, 0) ;
203 Tenseur ssjm1wshift(
mp, 1, CON,
mp.get_bvect_cart()) ;
205 for (
int i=0; i<3; i++) {
221 Vector source_shift(
mp, CON,
mp.get_bvect_cart()) ;
229 for (
int mer_ns=0; mer_ns<mermax_ns; mer_ns++) {
231 cout <<
"-----------------------------------------------" << endl ;
232 cout <<
"step: " << mer_ns << endl ;
233 cout <<
"diff_ent = " << diff_ent << endl ;
242 mermax_potvit, precis_poisson,
259 double lapconf_auto_c =
lapconf_auto.val_grid_point(0,0,0,0) - 0.5 ;
260 double lapconf_comp_c =
lapconf_comp.val_grid_point(0,0,0,0) ;
262 double confo_c =
confo_tot.val_grid_point(0,0,0,0) ;
264 double gam_c =
gam.val_grid_point(0,0,0,0) ;
265 double gam0_c =
gam0.val_grid_point(0,0,0,0) ;
267 double hhh_c =
exp(ent_c) ;
268 double hhh_b =
exp(ent_b) ;
274 double alpha_r2 = 0. ;
276 for (
int k=0; k<mg->
get_np(l_b); k++) {
277 for (
int j=0; j<mg->
get_nt(l_b); j++) {
279 double lapconf_auto_b =
281 double lapconf_comp_b =
284 double confo_b =
confo_tot.val_grid_point(l_b,k,j,i_b) ;
286 double gam_b =
gam.val_grid_point(l_b,k,j,i_b) ;
287 double gam0_b =
gam0.val_grid_point(l_b,k,j,i_b) ;
289 double aaa = (gam0_c*gam_b*hhh_b*confo_c)
290 / (gam0_b*gam_c*hhh_c*confo_b) ;
293 double alpha_r2_jk = (aaa * lapconf_comp_b - lapconf_comp_c
295 / (lapconf_auto_c - aaa * lapconf_auto_b ) ;
297 if (alpha_r2_jk > alpha_r2) {
298 alpha_r2 = alpha_r2_jk ;
305 alpha_r =
sqrt(alpha_r2) ;
307 cout <<
"k_b, j_b, alpha_r: " << k_b <<
" " << j_b <<
" "
315 lapconf_tot_tmp.std_spectral_base() ;
334 double log_lapconf_c =
log(lapconf_tot_tmp.val_grid_point(0,0,0,0)) ;
335 double log_confo_c =
log(
confo_tot.val_grid_point(0,0,0,0)) ;
336 double loggam_c =
loggam.val_grid_point(0,0,0,0) ;
337 double pot_centri_c =
pot_centri.val_grid_point(0,0,0,0) ;
339 ent = (ent_c + log_lapconf_c - log_confo_c + loggam_c + pot_centri_c)
341 ent.std_spectral_base() ;
349 double dentdx =
ent.dsdx().val_grid_point(0,0,0,0) ;
350 double dentdy =
ent.dsdy().val_grid_point(0,0,0,0) ;
352 cout <<
"dH/dx|_center = " << dentdx << endl ;
353 cout <<
"dH/dy|_center = " << dentdy << endl ;
355 double dec_fact_x = 1. ;
356 double dec_fact_y = 1. ;
359 func_in = 1. - dec_fact_x * (dentdx/ent_c) *
mp.x
360 - dec_fact_y * (dentdy/ent_c) *
mp.y ;
372 ent =
ent * (func_in + func_ex) ;
374 (
ent.set_spectral_va()).smooth(
nzet,
ent.set_spectral_va()) ;
376 double dentdx_new =
ent.dsdx().val_grid_point(0,0,0,0) ;
377 double dentdy_new =
ent.dsdy().val_grid_point(0,0,0,0) ;
378 cout <<
"dH/dx|_new = " << dentdx_new << endl ;
379 cout <<
"dH/dy|_new = " << dentdy_new << endl ;
385 double dent_eq =
ent.dsdr().val_point(
ray_eq_pi(),M_PI/2.,M_PI) ;
386 double dent_pole =
ent.dsdr().val_point(
ray_pole(),0.,0.) ;
387 double rap_dent = fabs( dent_eq / dent_pole ) ;
388 cout <<
"| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
389 diff_dHdr = rap_dent ;
391 if ( rap_dent < thres_adapt ) {
393 cout <<
"******* FROZEN MAPPING *********" << endl ;
401 for (
int l=0; l<
nzet; l++) {
402 ent_limit.
set(l) =
ent.val_grid_point(l, k_b, j_b, i_b) ;
404 ent_limit.
set(
nzet-1) = ent_b ;
409 mp.adapt(ent_cmp, par_adapt) ;
415 double rr_in_1 =
mp.val_r(1, -1., M_PI/2., 0.) ;
418 double rr_out_nm2 =
mp.val_r(nz-2, 1., M_PI/2., 0.) ;
419 mp.resize(nz-2, rr_in_1/rr_out_nm2 * fact_resize(1)) ;
422 double rr_out_nm3 =
mp.val_r(nz-3, 1., M_PI/2., 0.) ;
423 mp.resize(nz-3, rr_in_1/rr_out_nm3 * fact_resize(0)) ;
430 double rr_out_1 =
mp.val_r(1, 1., M_PI/2., 0.) ;
431 mp.resize(1, rr_in_1/rr_out_1 * resize_ns) ;
436 double rr_out_nm3_new =
mp.val_r(nz-3, 1., M_PI/2., 0.) ;
438 for (
int i=1; i<nz-4; i++) {
440 double rr_out_i =
mp.val_r(i, 1., M_PI/2., 0.) ;
442 double rr_mid = rr_out_i
443 + (rr_out_nm3_new - rr_out_i) /
double(nz - 3 - i) ;
445 double rr_2timesi = 2. * rr_out_i ;
447 if (rr_2timesi < rr_mid) {
449 double rr_out_ip1 =
mp.val_r(i+1, 1., M_PI/2., 0.) ;
450 mp.resize(i+1, rr_2timesi / rr_out_ip1) ;
455 double rr_out_ip1 =
mp.val_r(i+1, 1., M_PI/2., 0.) ;
456 mp.resize(i+1, rr_mid / rr_out_ip1) ;
475 mp.reevaluate(&mp_prev,
nzet+1, ent_cmp2) ;
478 double ent_s_max = -1 ;
482 for (
int k=0; k<mg->
get_np(l_b); k++) {
483 for (
int j=0; j<mg->
get_nt(l_b); j++) {
484 double xx = fabs(
ent.val_grid_point(l_b, k, j, i_b) ) ;
485 if (xx > ent_s_max) {
492 cout <<
"Max. abs(enthalpy) at the boundary between domains nzet-1"
493 <<
" and nzet : " << endl ;
494 cout <<
" " << ent_s_max <<
" reached for k = " << k_s_max
495 <<
" and j = " << j_s_max << endl ;
517 double rad_chi_min =
radius_p(azimu_min) ;
518 double chi_min =
chi_rp(rad_chi_min, azimu_min) ;
520 cout <<
"| dH/dr_eq / dH/dr_pole | (minimum) = " << chi_min << endl ;
521 cout <<
" phi = " << azimu_min / M_PI <<
" [M_PI]" << endl ;
522 cout <<
" radius = " << rad_chi_min / km <<
" [km]" << endl ;
524 diff_dHdr_min = chi_min ;
525 diff_phi_min = azimu_min ;
526 diff_radius = rad_chi_min ;
548 source_lapconf = sou_lap1 + sou_lap2 ;
554 if (source_lapconf.
get_etat() != ETATZERO) {
555 source_lapconf.
filtre(filter_r) ;
567 source_lapconf.
poisson(par_lapconf, lapconf_m1) ;
575 "Relative error in the resolution of the equation for lapconf_auto : "
577 for (
int l=0; l<nz; l++) {
578 cout << tdiff_lapconf(l) <<
" " ;
581 diff_lapconf =
max(
abs(tdiff_lapconf)) ;
607 source_confo = sou_con1 + sou_con2 ;
613 if (source_confo.
get_etat() != ETATZERO) {
614 source_confo.
filtre(filter_r) ;
626 source_confo.
poisson(par_confo, confo_m1) ;
634 "Relative error in the resolution of the equation for confo_auto : "
636 for (
int l=0; l<nz; l++) {
637 cout << tdiff_confo(l) <<
" " ;
640 diff_confo =
max(
abs(tdiff_confo)) ;
655 Vector sou_shif1(
mp, CON,
mp.get_bvect_cart()) ;
658 for (
int i=1; i<=3; i++) {
659 sou_shif1.
set(i) = 4.*qpig * lapconf_tot_tmp
667 for (
int i=1; i<=3; i++) {
668 (sou_shif1.
set(i)).inc_dzpuis(4) ;
671 Vector sou_shif2(
mp, CON,
mp.get_bvect_cart()) ;
673 for (
int i=1; i<=3; i++) {
674 sou_shif2.
set(i) = 2. *
688 source_shift = sou_shif1 + sou_shif2 ;
698 if (filter_r_s != 0) {
699 for (
int i=1; i<=3; i++) {
700 if (source_shift(i).get_etat() != ETATZERO) {
707 if (filter_p_s != 0) {
708 for (
int i=1; i<=3; i++) {
709 if (source_shift(i).get_etat() != ETATZERO) {
710 (source_shift.
set(i)).filtre_phi(filter_p_s, nz-1) ;
716 for (
int i=1; i<=3; i++) {
717 if(source_shift(i).dz_nonzero()) {
718 assert( source_shift(i).get_dzpuis() == 4 ) ;
721 (source_shift.
set(i)).set_dzpuis(4) ;
725 double lambda = double(1) / double(3) ;
727 Tenseur source_p(
mp, 1, CON,
mp.get_bvect_cart() ) ;
729 for (
int i=0; i<3; i++) {
730 source_p.
set(i) =
Cmp(source_shift(i+1)) ;
733 Tenseur vect_auxi(
mp, 1, CON,
mp.get_bvect_cart()) ;
735 for (
int i=0; i<3 ;i++) {
736 vect_auxi.
set(i) = 0. ;
746 source_p.
poisson_vect(lambda, par_shift2, resu_p, vect_auxi,
749 for (
int i=1; i<=3; i++)
754 for (
int i=0; i<3; i++) {
766 Tbl tdiff_shift_x =
diffrel(lap_shift(1), source_shift(1)) ;
767 Tbl tdiff_shift_y =
diffrel(lap_shift(2), source_shift(2)) ;
768 Tbl tdiff_shift_z =
diffrel(lap_shift(3), source_shift(3)) ;
771 "Relative error in the resolution of the equation for shift_auto : "
773 cout <<
"x component : " ;
774 for (
int l=0; l<nz; l++) {
775 cout << tdiff_shift_x(l) <<
" " ;
778 cout <<
"y component : " ;
779 for (
int l=0; l<nz; l++) {
780 cout << tdiff_shift_y(l) <<
" " ;
783 cout <<
"z component : " ;
784 for (
int l=0; l<nz; l++) {
785 cout << tdiff_shift_z(l) <<
" " ;
789 diff_shift_x =
max(
abs(tdiff_shift_x)) ;
790 diff_shift_y =
max(
abs(tdiff_shift_y)) ;
791 diff_shift_z =
max(
abs(tdiff_shift_z)) ;
799 diff_ent = diff_ent_tbl(0) ;
800 for (
int l=0; l<
nzet; l++) {
801 diff_ent += diff_ent_tbl(l) ;