00001 subroutine poisson_solver_binary_bhex_homosol(char_bc,sou, &
00002            &                                      sou_exsurf,dsou_exsurf, &
00003            &                                      sou_insurf,dsou_insurf, &
00004            &                                     sou_outsurf,dsou_outsurf,pot)
00005   use phys_constant,  only : long
00006   use grid_parameter, only : nrg, npg, ntg, npgxzm, npgxzp, ntgeq
00007   use def_metric, only : psi, alph, bvxd, bvyd
00008   use make_array_3d
00009   use interface_poisson_solver_binary_vol_int
00010   use interface_poisson_solver_binary_surf_int
00011   use interface_poisson_solver_bhex_surf_int
00012   use interface_sourceterm_surface_int_homosol
00013   use interface_copy_to_hgfn_and_gfnsf
00014   use radial_green_fn_grav_bhex_dd
00015   use radial_green_fn_grav_bhex_nd
00016   use radial_green_fn_grav_bhex_rd
00017   use radial_green_fn_grav_bhex_nb
00018   use radial_green_fn_grav_bhex_dh
00019   use radial_green_fn_grav_bhex_nh
00020   implicit none
00021 
00022   real(long), pointer :: pot(:,:,:), sou(:,:,:)
00023   real(long), pointer :: sou_exsurf(:,:), dsou_exsurf(:,:)
00024   real(long), pointer :: sou_insurf(:,:), dsou_insurf(:,:)
00025   real(long), pointer :: sou_outsurf(:,:), dsou_outsurf(:,:)
00026   real(long), pointer :: sou_iosurf(:,:,:)
00027   real(long), pointer :: pot_vol(:,:,:), pot_exsurf(:,:,:)
00028   real(long), pointer :: pot_insurf(:,:,:), pot_outsurf(:,:,:)
00029   real(long), pointer :: pot_integrals(:,:,:)
00030   character(len=2)    :: char_bc
00031   integer :: irg
00032 
00033   call alloc_array3d(pot_vol,0,nrg,0,ntg,0,npg)
00034   call alloc_array3d(pot_exsurf,0,nrg,0,ntg,0,npg)
00035   call alloc_array3d(pot_insurf,0,nrg,0,ntg,0,npg)
00036   call alloc_array3d(pot_outsurf,0,nrg,0,ntg,0,npg)
00037   call alloc_array3d(pot_integrals,0,nrg,0,ntg,0,npg)
00038   call alloc_array3d(sou_iosurf,0,ntg,0,npg,1,4)
00039 
00040   call calc_hgfn_bhex_nb
00041   call copy_to_hgfn_and_gfnsf(hgfn_nb,gfnsf_nb)
00042   call poisson_solver_binary_vol_int(sou,pot_vol)
00043 
00044   call poisson_solver_binary_surf_int(sou_exsurf,dsou_exsurf,pot_exsurf)
00045 
00046   pot_integrals(0:nrg,0:ntg,0:npg) = pot_vol(0:nrg,0:ntg,0:npg) &
00047                                  & + pot_exsurf(0:nrg,0:ntg,0:npg)
00048 
00049   if (char_bc.eq.'nd') then
00050     call calc_hgfn_bhex_nd
00051     call copy_to_hgfn_and_gfnsf(hgfn_nd,gfnsf_nd)
00052   end if
00053   if (char_bc.eq.'dd') then
00054     call calc_hgfn_bhex_dd
00055     call copy_to_hgfn_and_gfnsf(hgfn_dd,gfnsf_dd)
00056   end if
00057   if (char_bc.eq.'rd') then
00058     call calc_hgfn_bhex_rd
00059     call copy_to_hgfn_and_gfnsf(hgfn_rd,gfnsf_rd)
00060   end if
00061 
00062   call sourceterm_surface_int_homosol(pot_integrals,0,sou_insurf,dsou_insurf)
00063   sou_iosurf(1:ntg,1:npg,1) = dsou_insurf(1:ntg,1:npg)
00064   sou_iosurf(1:ntg,1:npg,2) = sou_insurf(1:ntg,1:npg)
00065   call poisson_solver_bhex_surf_int('in',sou_iosurf,pot_insurf)
00066 
00067   call sourceterm_surface_int_homosol(pot_integrals,nrg,sou_outsurf,dsou_outsurf)
00068   sou_iosurf(1:ntg,1:npg,3) = dsou_outsurf(1:ntg,1:npg)
00069   sou_iosurf(1:ntg,1:npg,4) = sou_outsurf(1:ntg,1:npg)
00070   call poisson_solver_bhex_surf_int('ou',sou_iosurf,pot_outsurf)
00071 
00072   pot(0:nrg,0:ntg,0:npg) = pot_integrals(0:nrg,0:ntg,0:npg) &
00073                        & + pot_insurf(0:nrg,0:ntg,0:npg)    &
00074                        & + pot_outsurf(0:nrg,0:ntg,0:npg)
00075 
00076   deallocate(pot_vol)
00077   deallocate(pot_exsurf)
00078   deallocate(pot_insurf)
00079   deallocate(pot_outsurf)
00080   deallocate(pot_integrals)
00081   deallocate(sou_iosurf)
00082 
00083 end subroutine poisson_solver_binary_bhex_homosol