74 const double& sepa,
bool kerrschild,
75 int,
int mermax_ns,
int mermax_potvit,
76 int mermax_poisson,
int filter_r,
77 int filter_r_s,
int filter_p_s,
78 double relax_poisson,
double relax_potvit,
79 double thres_adapt,
double resize_ns,
80 const Tbl& fact_resize,
Tbl& diff) {
89 const Mg3d* mg =
mp.get_mg() ;
98 int i_b = mg->
get_nr(l_b) - 1 ;
108 double& diff_ent = diff.
set(0) ;
109 double& diff_vel_pot = diff.
set(1) ;
110 double& diff_lapconf = diff.
set(2) ;
111 double& diff_confo = diff.
set(3) ;
112 double& diff_shift_x = diff.
set(4) ;
113 double& diff_shift_y = diff.
set(5) ;
114 double& diff_shift_z = diff.
set(6) ;
115 double& diff_dHdr = diff.
set(7) ;
116 double& diff_dHdr_min = diff.
set(8) ;
117 double& diff_phi_min = diff.
set(9) ;
118 double& diff_radius = diff.
set(10) ;
131 int nz_search =
nzet + 1 ;
134 double precis_secant = 1.e-14 ;
136 double reg_map = 1. ;
140 par_adapt.
add_int(nitermax, 0) ;
145 par_adapt.
add_int(nz_search, 2) ;
147 par_adapt.
add_int(adapt_flag, 3) ;
163 par_adapt.
add_tbl(ent_limit, 0) ;
172 double precis_poisson = 1.e-14 ;
179 par_lapconf.
add_int(mermax_poisson, 0) ;
190 par_confo.
add_int(mermax_poisson, 0) ;
201 par_shift2.
add_int(mermax_poisson, 0) ;
209 Tenseur ssjm1wshift(
mp, 1, CON,
mp.get_bvect_cart()) ;
211 for (
int i=0; i<3; i++) {
227 Vector source_shift(
mp, CON,
mp.get_bvect_cart()) ;
235 for (
int mer_ns=0; mer_ns<mermax_ns; mer_ns++) {
237 cout <<
"-----------------------------------------------" << endl ;
238 cout <<
"step: " << mer_ns << endl ;
239 cout <<
"diff_ent = " << diff_ent << endl ;
248 mermax_potvit, precis_poisson,
265 double lapconf_auto_c =
lapconf_auto.val_grid_point(0,0,0,0) - 0.5 ;
266 double lapconf_comp_c =
lapconf_comp.val_grid_point(0,0,0,0) ;
268 double confo_c =
confo_tot.val_grid_point(0,0,0,0) ;
270 double gam_c =
gam.val_grid_point(0,0,0,0) ;
271 double gam0_c =
gam0.val_grid_point(0,0,0,0) ;
273 double hhh_c =
exp(ent_c) ;
274 double hhh_b =
exp(ent_b) ;
280 double alpha_r2 = 0. ;
282 for (
int k=0; k<mg->
get_np(l_b); k++) {
283 for (
int j=0; j<mg->
get_nt(l_b); j++) {
285 double lapconf_auto_b =
287 double lapconf_comp_b =
290 double confo_b =
confo_tot.val_grid_point(l_b,k,j,i_b) ;
292 double gam_b =
gam.val_grid_point(l_b,k,j,i_b) ;
293 double gam0_b =
gam0.val_grid_point(l_b,k,j,i_b) ;
295 double aaa = (gam0_c*gam_b*hhh_b*confo_c)
296 / (gam0_b*gam_c*hhh_c*confo_b) ;
299 double alpha_r2_jk = (aaa * lapconf_comp_b - lapconf_comp_c
301 / (lapconf_auto_c - aaa * lapconf_auto_b ) ;
303 if (alpha_r2_jk > alpha_r2) {
304 alpha_r2 = alpha_r2_jk ;
311 alpha_r =
sqrt(alpha_r2) ;
313 cout <<
"k_b, j_b, alpha_r: " << k_b <<
" " << j_b <<
" "
321 lapconf_tot_tmp.std_spectral_base() ;
340 double log_lapconf_c =
log(lapconf_tot_tmp.val_grid_point(0,0,0,0)) ;
341 double log_confo_c =
log(
confo_tot.val_grid_point(0,0,0,0)) ;
342 double loggam_c =
loggam.val_grid_point(0,0,0,0) ;
343 double pot_centri_c =
pot_centri.val_grid_point(0,0,0,0) ;
345 ent = (ent_c + log_lapconf_c - log_confo_c + loggam_c + pot_centri_c)
347 ent.std_spectral_base() ;
355 double dentdx =
ent.dsdx().val_grid_point(0,0,0,0) ;
356 double dentdy =
ent.dsdy().val_grid_point(0,0,0,0) ;
358 cout <<
"dH/dx|_center = " << dentdx << endl ;
359 cout <<
"dH/dy|_center = " << dentdy << endl ;
361 double dec_fact_x = 1. ;
362 double dec_fact_y = 1. ;
365 func_in = 1. - dec_fact_x * (dentdx/ent_c) *
mp.x
366 - dec_fact_y * (dentdy/ent_c) *
mp.y ;
378 ent =
ent * (func_in + func_ex) ;
380 (
ent.set_spectral_va()).smooth(
nzet,
ent.set_spectral_va()) ;
382 double dentdx_new =
ent.dsdx().val_grid_point(0,0,0,0) ;
383 double dentdy_new =
ent.dsdy().val_grid_point(0,0,0,0) ;
384 cout <<
"dH/dx|_new = " << dentdx_new << endl ;
385 cout <<
"dH/dy|_new = " << dentdy_new << endl ;
391 double dent_eq =
ent.dsdr().val_point(
ray_eq_pi(),M_PI/2.,M_PI) ;
392 double dent_pole =
ent.dsdr().val_point(
ray_pole(),0.,0.) ;
393 double rap_dent = fabs( dent_eq / dent_pole ) ;
394 cout <<
"| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
395 diff_dHdr = rap_dent ;
397 if ( rap_dent < thres_adapt ) {
399 cout <<
"******* FROZEN MAPPING *********" << endl ;
407 for (
int l=0; l<
nzet; l++) {
408 ent_limit.
set(l) =
ent.val_grid_point(l, k_b, j_b, i_b) ;
410 ent_limit.
set(
nzet-1) = ent_b ;
415 mp.adapt(ent_cmp, par_adapt) ;
421 double rr_in_1 =
mp.val_r(1, -1., M_PI/2., 0.) ;
424 double rr_out_nm2 =
mp.val_r(nz-2, 1., M_PI/2., 0.) ;
425 mp.resize(nz-2, rr_in_1/rr_out_nm2 * fact_resize(1)) ;
428 double rr_out_nm3 =
mp.val_r(nz-3, 1., M_PI/2., 0.) ;
429 mp.resize(nz-3, rr_in_1/rr_out_nm3 * fact_resize(0)) ;
436 double rr_out_1 =
mp.val_r(1, 1., M_PI/2., 0.) ;
437 mp.resize(1, rr_in_1/rr_out_1 * resize_ns) ;
442 double rr_out_nm3_new =
mp.val_r(nz-3, 1., M_PI/2., 0.) ;
444 for (
int i=1; i<nz-4; i++) {
446 double rr_out_i =
mp.val_r(i, 1., M_PI/2., 0.) ;
448 double rr_mid = rr_out_i
449 + (rr_out_nm3_new - rr_out_i) /
double(nz - 3 - i) ;
451 double rr_2timesi = 2. * rr_out_i ;
453 if (rr_2timesi < rr_mid) {
455 double rr_out_ip1 =
mp.val_r(i+1, 1., M_PI/2., 0.) ;
456 mp.resize(i+1, rr_2timesi / rr_out_ip1) ;
461 double rr_out_ip1 =
mp.val_r(i+1, 1., M_PI/2., 0.) ;
462 mp.resize(i+1, rr_mid / rr_out_ip1) ;
481 mp.reevaluate(&mp_prev,
nzet+1, ent_cmp2) ;
484 double ent_s_max = -1 ;
488 for (
int k=0; k<mg->
get_np(l_b); k++) {
489 for (
int j=0; j<mg->
get_nt(l_b); j++) {
490 double xx = fabs(
ent.val_grid_point(l_b, k, j, i_b) ) ;
491 if (xx > ent_s_max) {
498 cout <<
"Max. abs(enthalpy) at the boundary between domains nzet-1"
499 <<
" and nzet : " << endl ;
500 cout <<
" " << ent_s_max <<
" reached for k = " << k_s_max
501 <<
" and j = " << j_s_max << endl ;
523 double rad_chi_min =
radius_p(azimu_min) ;
524 double chi_min =
chi_rp(rad_chi_min, azimu_min) ;
526 cout <<
"| dH/dr_eq / dH/dr_pole | (minimum) = " << chi_min << endl ;
527 cout <<
" phi = " << azimu_min / M_PI <<
" [M_PI]" << endl ;
528 cout <<
" radius = " << rad_chi_min / km <<
" [km]" << endl ;
530 diff_dHdr_min = chi_min ;
531 diff_phi_min = azimu_min ;
532 diff_radius = rad_chi_min ;
554 source_lapconf = sou_lap1 + sou_lap2 ;
560 if (source_lapconf.
get_etat() != ETATZERO) {
561 source_lapconf.
filtre(filter_r) ;
573 source_lapconf.
poisson(par_lapconf, lapconf_m1) ;
581 "Relative error in the resolution of the equation for lapconf_auto : "
583 for (
int l=0; l<nz; l++) {
584 cout << tdiff_lapconf(l) <<
" " ;
587 diff_lapconf =
max(
abs(tdiff_lapconf)) ;
613 source_confo = sou_con1 + sou_con2 ;
619 if (source_confo.
get_etat() != ETATZERO) {
620 source_confo.
filtre(filter_r) ;
632 source_confo.
poisson(par_confo, confo_m1) ;
640 "Relative error in the resolution of the equation for confo_auto : "
642 for (
int l=0; l<nz; l++) {
643 cout << tdiff_confo(l) <<
" " ;
646 diff_confo =
max(
abs(tdiff_confo)) ;
661 Vector sou_shif1(
mp, CON,
mp.get_bvect_cart()) ;
664 for (
int i=1; i<=3; i++) {
665 sou_shif1.
set(i) = 4.*qpig * lapconf_tot_tmp
673 for (
int i=1; i<=3; i++) {
674 (sou_shif1.
set(i)).inc_dzpuis(4) ;
677 Vector sou_shif2(
mp, CON,
mp.get_bvect_cart()) ;
679 for (
int i=1; i<=3; i++) {
680 sou_shif2.
set(i) = 2. *
694 source_shift = sou_shif1 + sou_shif2 ;
704 if (filter_r_s != 0) {
705 for (
int i=1; i<=3; i++) {
706 if (source_shift(i).get_etat() != ETATZERO) {
713 if (filter_p_s != 0) {
714 for (
int i=1; i<=3; i++) {
715 if (source_shift(i).get_etat() != ETATZERO) {
716 (source_shift.
set(i)).filtre_phi(filter_p_s, nz-1) ;
722 for (
int i=1; i<=3; i++) {
723 if(source_shift(i).dz_nonzero()) {
724 assert( source_shift(i).get_dzpuis() == 4 ) ;
727 (source_shift.
set(i)).set_dzpuis(4) ;
731 double lambda = double(1) / double(3) ;
733 Tenseur source_p(
mp, 1, CON,
mp.get_bvect_cart() ) ;
735 for (
int i=0; i<3; i++) {
736 source_p.
set(i) =
Cmp(source_shift(i+1)) ;
739 Tenseur vect_auxi(
mp, 1, CON,
mp.get_bvect_cart()) ;
741 for (
int i=0; i<3 ;i++) {
742 vect_auxi.
set(i) = 0. ;
752 source_p.
poisson_vect(lambda, par_shift2, resu_p, vect_auxi,
755 for (
int i=1; i<=3; i++)
760 for (
int i=0; i<3; i++) {
772 Tbl tdiff_shift_x =
diffrel(lap_shift(1), source_shift(1)) ;
773 Tbl tdiff_shift_y =
diffrel(lap_shift(2), source_shift(2)) ;
774 Tbl tdiff_shift_z =
diffrel(lap_shift(3), source_shift(3)) ;
777 "Relative error in the resolution of the equation for shift_auto : "
779 cout <<
"x component : " ;
780 for (
int l=0; l<nz; l++) {
781 cout << tdiff_shift_x(l) <<
" " ;
784 cout <<
"y component : " ;
785 for (
int l=0; l<nz; l++) {
786 cout << tdiff_shift_y(l) <<
" " ;
789 cout <<
"z component : " ;
790 for (
int l=0; l<nz; l++) {
791 cout << tdiff_shift_z(l) <<
" " ;
795 diff_shift_x =
max(
abs(tdiff_shift_x)) ;
796 diff_shift_y =
max(
abs(tdiff_shift_y)) ;
797 diff_shift_z =
max(
abs(tdiff_shift_z)) ;
805 diff_ent = diff_ent_tbl(0) ;
806 for (
int l=0; l<
nzet; l++) {
807 diff_ent += diff_ent_tbl(l) ;