00001 subroutine iteration_BBH_CF_trpPunc_3mpt(iter_count)
00002 use phys_constant, only : long, nmpt
00003 use grid_parameter
00004 use coordinate_grav_r
00005 use def_metric, only : psi, alph, alps, bvxd, bvyd, bvzd
00006 use def_metric_pBH
00007 use def_bh_parameter, only : bh_bctype, bh_soltype, ome_bh
00008 use def_binary_parameter, only : dis
00009 use copy_array_4dto3d_mpt
00010 use make_array_2d
00011 use make_array_3d
00012 use make_array_4d
00013 use interface_compute_alps2alph
00014 use interface_sourceterm_HaC_CF_pBH
00015 use interface_sourceterm_trG_CF_pBH
00016 use interface_sourceterm_surface_int
00017 use interface_sourceterm_exsurf_binary_COCP_pBH
00018 use interface_sourceterm_outsurf_COCP_from_ARCP_pBH
00019 use interface_sourceterm_insurf_ARCP_from_COCP_pBH
00020 use interface_bh_boundary_CF
00021 use interface_outer_boundary_d_BBH_CF_pBH
00022 use interface_poisson_solver_binary_star_homosol
00023 use interface_poisson_solver_asymptotic_patch_homosol
00024 use interface_interpolation_fillup_binary_COCP
00025 use interface_update_grfield
00026 use interface_error_metric
00027 use interface_error_metric_type0
00028 use interface_error_metric_type2
00029 use interface_compute_wme2psi
00030 implicit none
00031 real(long), pointer :: sou(:,:,:), pot(:,:,:)
00032 real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00033 real(long), pointer :: pot_bak(:,:,:), work(:,:,:)
00034 real(long), pointer :: potx_bak(:,:,:), poty_bak(:,:,:), potz_bak(:,:,:)
00035 real(long), pointer :: souvec(:,:,:,:)
00036 real(long), pointer :: sou_exsurf(:,:), dsou_exsurf(:,:)
00037 real(long), pointer :: sou_bhsurf(:,:), dsou_bhsurf(:,:)
00038 real(long), pointer :: sou_insurf(:,:), dsou_insurf(:,:)
00039 real(long), pointer :: sou_outsurf(:,:), dsou_outsurf(:,:)
00040 real(long), pointer :: fnc_itp(:,:,:)
00041
00042 real(long) :: count, index_r2
00043 real(long) :: error_psi = 0.0d0, error_alph = 0.0d0, error_tmp = 0.0d0,
00044 error_bvxd = 0.0d0, error_bvyd = 0.0d0, error_bvzd = 0.0d0, &
00045 error_ome = 2.0d0
00046 real(long) :: pari, ome_bh_new
00047 integer :: iter_count, iter_extra = 0, istep_niq = -1,
00048 flag_tmp = 0, flag_param = 99, &
00049 flag_psi = 0, flag_alph = 0, &
00050 flag_bvxd = 0, flag_bvyd = 0, flag_bvzd = 0
00051 integer :: irg, itg, ipg, ii
00052 integer :: impt, impt_ex, impt_bin
00053 character(len=2) :: chgreen, chpa, chpB
00054 character(len=4) :: chbe
00055
00056 call set_allocate_size_mpt
00057 call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00058 call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00059 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00060 call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00061 call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00062 call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00063 call alloc_array3d(pot_bak,0,nrg,0,ntg,0,npg)
00064 call alloc_array3d(potx_bak,0,nrg,0,ntg,0,npg)
00065 call alloc_array3d(poty_bak,0,nrg,0,ntg,0,npg)
00066 call alloc_array3d(potz_bak,0,nrg,0,ntg,0,npg)
00067 call alloc_array3d(work,0,nrg,0,ntg,0,npg)
00068 call alloc_array3d(fnc_itp,0,nrg,0,ntg,0,npg)
00069 call alloc_array2d(sou_exsurf,0,ntg,0,npg)
00070 call alloc_array2d(dsou_exsurf,0,ntg,0,npg)
00071 call alloc_array2d(sou_bhsurf,0,ntg,0,npg)
00072 call alloc_array2d(dsou_bhsurf,0,ntg,0,npg)
00073 call alloc_array2d(sou_insurf,0,ntg,0,npg)
00074 call alloc_array2d(dsou_insurf,0,ntg,0,npg)
00075 call alloc_array2d(sou_outsurf,0,ntg,0,npg)
00076 call alloc_array2d(dsou_outsurf,0,ntg,0,npg)
00077
00078 iter_count = 0
00079
00080 do
00081 iter_count = iter_count + 1
00082 iter_extra = iter_extra + 1
00083 count = dble(iter_count)
00084
00085 do impt = 1, nmpt
00086 write(6,'(a10,i2)')" Patch # =", impt
00087 call copy_grid_parameter_from_mpt(impt)
00088 conv_gra = dmin1(conv0_gra,conv_ini*count)
00089 conv_den = dmin1(conv0_den,conv_ini*count)
00090 call copy_grid_parameter_to_mpt(impt)
00091
00092 call copy_from_mpatch_all_BBH_CF(impt)
00093 call copy_def_metric_from_mpt(impt)
00094 call copy_def_metric_pBH_from_mpt(impt)
00095 call calc_vector_x_grav(1)
00096 call calc_vector_phi_grav(1)
00097 call calc_vector_bh(1)
00098
00099
00100 call excurve_TrpBH_mpt(impt)
00101 call compute_alps2wmeN_mpt(impt)
00102 if (impt.eq.nmpt) call calc_mass_asympto('bh')
00103 call copy_to_mpatch_all_BBH_CF(impt)
00104
00105
00106 sou(0:nrg,0:ntg,0:npg) = 0.0d0
00107 sou_exsurf(0:ntg,0:npg) = 0.0d0 ; dsou_exsurf(0:ntg,0:npg) = 0.0d0
00108 sou_bhsurf(0:ntg,0:npg) = 0.0d0 ; dsou_bhsurf(0:ntg,0:npg) = 0.0d0
00109 sou_outsurf(0:ntg,0:npg)= 0.0d0 ; dsou_outsurf(0:ntg,0:npg)= 0.0d0
00110 call sourceterm_HaC_CF_pBH(sou)
00111
00112 if (impt.ne.nmpt) then
00113 call sourceterm_exsurf_binary_COCP_pBH(impt,'logw','ev',sou_exsurf, &
00114 & dsou_exsurf)
00115 call sourceterm_outsurf_COCP_from_ARCP_pBH(impt,'logw','ev', &
00116 & sou_outsurf,dsou_outsurf)
00117 chgreen = 'sd'
00118 call poisson_solver_binary_star_homosol(chgreen,sou, &
00119 & sou_exsurf,dsou_exsurf, &
00120 & sou_outsurf,dsou_outsurf,pot)
00121 else if (impt.eq.nmpt) then
00122 call sourceterm_insurf_ARCP_from_COCP_pBH(impt,'logw','ev', &
00123 & sou_insurf,dsou_insurf)
00124
00125
00126
00127 call outer_boundary_d_BBH_CF_pBH(sou_outsurf,'logw')
00128 call poisson_solver_asymptotic_patch_homosol('dd',sou, &
00129 & sou_insurf,dsou_insurf, &
00130 & sou_outsurf,dsou_outsurf,pot)
00131 end if
00132
00133 if (impt.ne.nmpt) pot(0,0:ntg,0:npg) = -40.0d0
00134 pot(0:nrg,0:ntg,0:npg) = dexp(pot(0:nrg,0:ntg,0:npg))
00135 call compute_wme2psi(pot)
00136
00137 pot_bak(0:nrg,0:ntg,0:npg) = psi(0:nrg,0:ntg,0:npg)
00138 call update_grfield(pot,psi,conv_gra)
00139 call reset_outer_boundary_BBH_CF('psi ')
00140
00141 if (impt.ne.nmpt) call interpolation_fillup_binary_COCP &
00142 & (impt,'psi ','ev',psi)
00143 call error_metric_type0(psi,pot_bak,error_tmp,flag_tmp,'bh')
00144 flag_psi = max ( flag_psi, flag_tmp)
00145 error_psi = dmax1(error_psi,error_tmp)
00146 call printout_error_metric(iter_count,error_psi)
00147
00148 call copy_to_mpatch_all_BBH_CF(impt)
00149 call copy_def_metric_to_mpt(impt)
00150 call compute_alps2wmeN_mpt(impt)
00151 call copy_def_metric_pBH_to_mpt(impt)
00152
00153
00154 sou(0:nrg,0:ntg,0:npg) = 0.0d0
00155 sou_exsurf(0:ntg,0:npg) = 0.0d0 ; dsou_exsurf(0:ntg,0:npg) = 0.0d0
00156 sou_bhsurf(0:ntg,0:npg) = 0.0d0 ; dsou_bhsurf(0:ntg,0:npg) = 0.0d0
00157 sou_outsurf(0:ntg,0:npg)= 0.0d0 ; dsou_outsurf(0:ntg,0:npg)= 0.0d0
00158
00159 call sourceterm_trG_CF_pBH(sou)
00160
00161 if (impt.ne.nmpt) then
00162 call sourceterm_exsurf_binary_COCP_pBH(impt,'logN','ev',sou_exsurf, &
00163 & dsou_exsurf)
00164 call sourceterm_outsurf_COCP_from_ARCP_pBH(impt,'logN','ev', &
00165 & sou_outsurf,dsou_outsurf)
00166 chgreen = 'sd'
00167 call poisson_solver_binary_star_homosol(chgreen,sou, &
00168 & sou_exsurf,dsou_exsurf, &
00169 & sou_outsurf,dsou_outsurf,pot)
00170 else if (impt.eq.nmpt) then
00171 call sourceterm_insurf_ARCP_from_COCP_pBH(impt,'logN','ev', &
00172 & sou_insurf,dsou_insurf)
00173
00174
00175 call outer_boundary_d_BBH_CF_pBH(sou_outsurf,'logN')
00176 call poisson_solver_asymptotic_patch_homosol('dd',sou, &
00177 & sou_insurf,dsou_insurf, &
00178 & sou_outsurf,dsou_outsurf,pot)
00179 end if
00180
00181 if (impt.ne.nmpt) pot(0,0:ntg,0:npg) = -40.0d0
00182 index_r2 = dsqrt(2.0d0)
00183 pot(0:nrg,0:ntg,0:npg) = dexp(pot(0:nrg,0:ntg,0:npg))**index_r2
00184
00185 pot_bak(0:nrg,0:ntg,0:npg) = alph(0:nrg,0:ntg,0:npg)
00186 call update_grfield(pot,alph,conv_gra)
00187 call reset_outer_boundary_BBH_CF('alph')
00188 if (impt.ne.nmpt) call interpolation_fillup_binary_COCP &
00189 & (impt,'alph','ev',alph)
00190 call error_metric_type0(alph,pot_bak,error_tmp,flag_tmp,'bh')
00191 flag_alph = max ( flag_alph, flag_tmp)
00192 error_alph = dmax1(error_alph,error_tmp)
00193 call printout_error_metric(iter_count,error_alph)
00194
00195 alps(0:nrg,0:ntg,0:npg) = alph(0:nrg,0:ntg,0:npg)*psi(0:nrg,0:ntg,0:npg)
00196 call copy_to_mpatch_all_BBH_CF(impt)
00197 call copy_def_metric_to_mpt(impt)
00198 call compute_alps2wmeN_mpt(impt)
00199 call copy_def_metric_pBH_to_mpt(impt)
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 end do
00212
00213
00214 error_tmp = dmax1(error_psi,error_alph,error_bvxd, &
00215 & error_bvyd,error_bvzd)
00216 if ((bh_soltype.eq.'CI'.or.bh_soltype.eq.'SQ').and. &
00217 & error_tmp.le.0.1d0*eps) then
00218
00219
00220 iter_extra = 0
00221 call calc_physical_quantities_BBH_trpPunc_CF_mpt
00222 call adjust_multi_parameter_trpPunc_mpt(flag_param,istep_niq)
00223 call update_coordinates_mpt
00224 end if
00225
00226
00227
00228 if (bh_soltype.ne.'CI'.and.bh_soltype.ne.'SQ') flag_param = 0
00229
00230 if ((flag_param==0).and.(flag_psi==0).and.(flag_alph==0).and. &
00231 & (flag_bvxd==0).and.(flag_bvyd==0).and.(flag_bvzd==0).and. &
00232 & (flag_param==0)) exit
00233 if (iter_count >= iter_max) exit
00234
00235
00236
00237 flag_psi = 0
00238 flag_alph = 0
00239 flag_bvxd = 0
00240 flag_bvyd = 0
00241 flag_bvzd = 0
00242 flag_param= 99
00243 error_psi = 0.0d0
00244 error_alph = 0.0d0
00245 error_bvxd = 0.0d0
00246 error_bvyd = 0.0d0
00247 error_bvzd = 0.0d0
00248 end do
00249
00250 deallocate(souvec)
00251 deallocate(sou)
00252 deallocate(pot)
00253 deallocate(potx)
00254 deallocate(poty)
00255 deallocate(potz)
00256 deallocate(pot_bak)
00257 deallocate(potx_bak)
00258 deallocate(poty_bak)
00259 deallocate(potz_bak)
00260 deallocate(work)
00261 deallocate(fnc_itp)
00262 deallocate(sou_exsurf)
00263 deallocate(dsou_exsurf)
00264 deallocate(sou_bhsurf)
00265 deallocate(dsou_bhsurf)
00266 deallocate(sou_insurf)
00267 deallocate(dsou_insurf)
00268 deallocate(sou_outsurf)
00269 deallocate(dsou_outsurf)
00270 end subroutine iteration_BBH_CF_trpPunc_3mpt