00001 subroutine iteration_poisson_BHNS_test_mpt(iter_count)
00002 use phys_constant, only : long, nnrg, nntg, nnpg, nmpt
00003 use grid_parameter
00004 use coordinate_grav_r
00005 use coordinate_grav_phi
00006 use coordinate_grav_theta
00007 use weight_midpoint_grav
00008 use def_metric, only : psi
00009 use def_matter, only : emd, emdg
00010 use make_array_2d
00011 use make_array_3d
00012 use radial_green_fn_grav
00013 use radial_green_fn_grav_bhex_di
00014 use radial_green_fn_grav_bhex_nb
00015 use radial_green_fn_grav_bhex_nh
00016 use radial_green_fn_grav_bhex_dh
00017 use interface_poisson_solver
00018 use interface_update_grfield
00019 use interface_error_metric
00020 use interface_interpo_fl2gr
00021 use interface_sourceterm_poisson_solver_test
00022 use interface_sourceterm_exsurf_eqm_binary
00023 use interface_copy_to_hgfn_and_gfnsf
00024 use interface_error_metric_type0
00025 use interface_poisson_solver_binary
00026 use interface_sourceterm_surface_int
00027 use interface_poisson_solver_binary_bhex_homosol
00028
00029 use interface_bh_boundary_BHNS_test_mpt
00030
00031 implicit none
00032 real(long), pointer :: sou(:,:,:), pot(:,:,:), psi_bak(:,:,:)
00033 real(long), pointer :: sou_exsurf(:,:), dsou_exsurf(:,:)
00034 real(long), pointer :: sou_bhsurf(:,:), dsou_bhsurf(:,:)
00035 real(long), pointer :: sou_outsurf(:,:), dsou_outsurf(:,:)
00036 real(long) :: error_psi, count
00037 integer :: iter_count, flag = 0
00038 integer :: irf, itf, ipf, irg, itg, ipg, ihy, impt, impt_ex
00039
00040 call set_allocate_size_mpt
00041 call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00042 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00043 call alloc_array3d(psi_bak,0,nrg,0,ntg,0,npg)
00044 call alloc_array2d(sou_exsurf,0,ntg,0,npg)
00045 call alloc_array2d(dsou_exsurf,0,ntg,0,npg)
00046 call alloc_array2d(sou_bhsurf,0,ntg,0,npg)
00047 call alloc_array2d(dsou_bhsurf,0,ntg,0,npg)
00048 call alloc_array2d(sou_outsurf,0,ntg,0,npg)
00049 call alloc_array2d(dsou_outsurf,0,ntg,0,npg)
00050
00051 iter_count = 0
00052 do
00053 iter_count = iter_count + 1
00054 count = dble(iter_count)
00055
00056 do impt = 1, nmpt
00057 call copy_grid_parameter_from_mpt(impt)
00058 conv_gra = dmin1(conv0_gra,conv_ini*count)
00059 conv_den = dmin1(conv0_den,conv_ini*count)
00060 call copy_grid_parameter_to_mpt(impt)
00061
00062 call copy_from_mpatch_all_test(impt)
00063 call calc_vector_x_grav(0)
00064 call calc_vector_x_matter(0)
00065 call calc_vector_phi_grav(0)
00066 call calc_vector_phi_matter(0)
00067 call copy_to_mpatch_all_test(impt)
00068
00069 if(impt.eq.1) impt_ex = 2
00070 if(impt.eq.2) impt_ex = 1
00071 call copy_from_mpatch_all_test(impt_ex)
00072 call copy_metric_and_matter_BHNS_test_from_mpt(impt_ex)
00073 call sourceterm_exsurf_eqm_binary(psi,sou_exsurf,dsou_exsurf)
00074 call copy_from_mpatch_all_test(impt)
00075 call copy_metric_and_matter_BHNS_test_from_mpt(impt)
00076
00077 if(impt.eq.1) then
00078 sou(0:nrg,0:ntg,0:npg) = 0.0d0
00079 call reset_bh_boundary('d')
00080 call sourceterm_surface_int(psi,0,sou_bhsurf,dsou_bhsurf)
00081 call sourceterm_surface_int(psi,nrg,sou_outsurf,dsou_outsurf)
00082 call bh_boundary_BHNS_test_mpt('dh',sou_exsurf,dsou_exsurf)
00083 call poisson_solver_binary_bhex_homosol('dh',sou, &
00084 & sou_exsurf,dsou_exsurf, &
00085 & sou_bhsurf,dsou_bhsurf, &
00086 & sou_outsurf,dsou_outsurf,pot)
00087
00088 end if
00089
00090 if(impt.eq.2) then
00091 emdg = 0.0d0
00092 call interpo_fl2gr(emd, emdg)
00093 call sourceterm_poisson_solver_test(sou)
00094 call calc_hgfn_bhex_nb
00095 call copy_to_hgfn_and_gfnsf(hgfn_nb,gfnsf_nb)
00096 call poisson_solver_binary(sou,sou_exsurf,dsou_exsurf,pot)
00097 end if
00098
00099 psi_bak(0:nrg,0:ntg,0:npg) = psi(0:nrg,0:ntg,0:npg)
00100 call update_grfield(pot,psi,conv_gra)
00101 call error_metric_type0(psi,psi_bak,error_psi,flag,'bh')
00102 call printout_error_metric(iter_count,error_psi)
00103 if(impt.eq.1) call reset_bh_boundary('d')
00104 call copy_to_mpatch_all_test(impt)
00105 call copy_metric_and_matter_BHNS_test_to_mpt(impt)
00106 end do
00107
00108 if (flag == 0) exit
00109 if (iter_count >= iter_max) exit
00110 if (iter_count >= 10 .and. error_psi > 1.5d0) exit
00111 flag = 0
00112 end do
00113
00114 deallocate(sou)
00115 deallocate(pot)
00116 deallocate(psi_bak)
00117 deallocate(sou_exsurf)
00118 deallocate(dsou_exsurf)
00119 deallocate(sou_bhsurf)
00120 deallocate(dsou_bhsurf)
00121 deallocate(sou_outsurf)
00122 deallocate(dsou_outsurf)
00123 end subroutine iteration_poisson_BHNS_test_mpt