00001 module grid_points_binary_excision
00002 use phys_constant, only : long
00003 implicit none
00004 integer, pointer :: irg_exin(:,:), itg_exin(:,:), ipg_exin(:,:)
00005 integer, pointer :: irg_exout(:,:), itg_exout(:,:), ipg_exout(:,:)
00006 real(long), pointer :: rg_exin(:,:), thg_exin(:,:), phig_exin(:,:)
00007 real(long), pointer :: rg_exout(:,:), thg_exout(:,:), phig_exout(:,:)
00008 integer, pointer :: ihrg_exin(:,:), ihtg_exin(:,:), ihpg_exin(:,:)
00009 integer, pointer :: ihrg_exout(:,:), ihtg_exout(:,:), ihpg_exout(:,:)
00010 real(long), pointer :: hrg_exin(:,:), hthg_exin(:,:), hphig_exin(:,:)
00011 real(long), pointer :: hrg_exout(:,:), hthg_exout(:,:), hphig_exout(:,:)
00012
00013 real(long), pointer :: rb(:,:,:), thb(:,:,:), phib(:,:,:)
00014 real(long), pointer :: hrb(:,:,:), hthb(:,:,:), hphib(:,:,:)
00015 integer :: ntg_exin_min, ntg_exout_max, npg_exin_max, npg_exout_min
00016
00017 contains
00018
00019 subroutine allocate_grid_points_binary_excision
00020 use phys_constant, only : long, pi
00021 use grid_parameter, only : nrg, ntg, npg
00022 use make_array_2d
00023 use make_array_3d
00024 use make_int_array_2d
00025 implicit none
00026
00027 call alloc_int_array2d(irg_exin, 0,ntg,0,npg)
00028 call alloc_int_array2d(irg_exout,0,ntg,0,npg)
00029 call alloc_int_array2d(itg_exin, 0,nrg,0,npg)
00030 call alloc_int_array2d(itg_exout,0,nrg,0,npg)
00031 call alloc_int_array2d(ipg_exin, 0,nrg,0,ntg)
00032 call alloc_int_array2d(ipg_exout,0,nrg,0,ntg)
00033 call alloc_array2d(rg_exin, 0,ntg,0,npg)
00034 call alloc_array2d(rg_exout,0,ntg,0,npg)
00035 call alloc_array2d(thg_exin, 0,nrg,0,npg)
00036 call alloc_array2d(thg_exout,0,nrg,0,npg)
00037 call alloc_array2d(phig_exin, 0,nrg,0,ntg)
00038 call alloc_array2d(phig_exout,0,nrg,0,ntg)
00039
00040 call alloc_int_array2d(ihrg_exin, 0,ntg,0,npg)
00041 call alloc_int_array2d(ihrg_exout,0,ntg,0,npg)
00042 call alloc_int_array2d(ihtg_exin, 0,nrg,0,npg)
00043 call alloc_int_array2d(ihtg_exout,0,nrg,0,npg)
00044 call alloc_int_array2d(ihpg_exin, 0,nrg,0,ntg)
00045 call alloc_int_array2d(ihpg_exout,0,nrg,0,ntg)
00046 call alloc_array2d(hrg_exin, 0,ntg,0,npg)
00047 call alloc_array2d(hrg_exout,0,ntg,0,npg)
00048 call alloc_array2d(hthg_exin, 0,nrg,0,npg)
00049 call alloc_array2d(hthg_exout,0,nrg,0,npg)
00050 call alloc_array2d(hphig_exin, 0,nrg,0,ntg)
00051 call alloc_array2d(hphig_exout,0,nrg,0,ntg)
00052
00053 call alloc_array3d(rb,0,nrg,0,ntg,0,npg)
00054 call alloc_array3d(thb,0,nrg,0,ntg,0,npg)
00055 call alloc_array3d(phib,0,nrg,0,ntg,0,npg)
00056 call alloc_array3d(hrb,1,nrg,1,ntg,1,npg)
00057 call alloc_array3d(hthb,1,nrg,1,ntg,1,npg)
00058 call alloc_array3d(hphib,1,nrg,1,ntg,1,npg)
00059
00060 irg_exin( 0:ntg,0:npg) = 0
00061 irg_exout(0:ntg,0:npg) = 0
00062 itg_exin( 0:nrg,0:npg) = 0
00063 itg_exout(0:nrg,0:npg) = 0
00064 ipg_exin( 0:nrg,0:ntg) = 0
00065 ipg_exout(0:nrg,0:ntg) = 0
00066 rg_exin( 0:ntg,0:npg) = 0.0d0
00067 rg_exout(0:ntg,0:npg) = 0.0d0
00068 thg_exin( 0:nrg,0:npg) = 0.0d0
00069 thg_exout(0:nrg,0:npg) = 0.0d0
00070 phig_exin( 0:nrg,0:ntg) = 0.0d0
00071 phig_exout(0:nrg,0:ntg) = 0.0d0
00072
00073 ihrg_exin( 0:ntg,0:npg) = 0
00074 ihrg_exout(0:ntg,0:npg) = 0
00075 ihtg_exin( 0:nrg,0:npg) = 0
00076 ihtg_exout(0:nrg,0:npg) = 0
00077 ihpg_exin( 0:nrg,0:ntg) = 0
00078 ihpg_exout(0:nrg,0:ntg) = 0
00079 hrg_exin( 0:ntg,0:npg) = 0.0d0
00080 hrg_exout(0:ntg,0:npg) = 0.0d0
00081 hthg_exin( 0:nrg,0:npg) = 0.0d0
00082 hthg_exout(0:nrg,0:npg) = 0.0d0
00083 hphig_exin( 0:nrg,0:ntg) = 0.0d0
00084 hphig_exout(0:nrg,0:ntg) = 0.0d0
00085
00086 rb(0:nrg,0:ntg,0:npg) = 0.0d0
00087 thb(0:nrg,0:ntg,0:npg) = 0.0d0
00088 phib(0:nrg,0:ntg,0:npg) = 0.0d0
00089 hrb(1:nrg,1:ntg,1:npg) = 0.0d0
00090 hthb(1:nrg,1:ntg,1:npg) = 0.0d0
00091 hphib(1:nrg,1:ntg,1:npg) = 0.0d0
00092
00093 end subroutine allocate_grid_points_binary_excision
00094
00095
00096
00097 subroutine calc_grid_points_binary_excision
00098 use phys_constant, only : long, pi
00099 use coordinate_grav_r, only : rg, hrg
00100 use coordinate_grav_theta, only : thg
00101 use coordinate_grav_phi, only : phig, dphig
00102 use grid_parameter, only : nrg, ntg, npg, ntgxy, npgxzp, npgxzm
00103 use def_binary_parameter, only : sepa
00104 use grid_parameter_binary_excision, only : ex_radius
00105 use trigonometry_grav_theta, only : sinthg, costhg, hsinthg, hcosthg
00106 use trigonometry_grav_phi, only : sinphig, cosphig, hsinphig, hcosphig
00107 implicit none
00108
00109 real(long) :: small = 1.0d-10
00110 real(long) :: rrgg, sth, cth, sphi, cphi
00111 real(long) :: point_line_dis2, root_det
00112 real(long) :: x0, y0, z0, rg_exc_dis2, xxyy2
00113 integer :: irg, itg, ipg
00114
00115
00116
00117 do ipg = 0, npg
00118 do itg = 0, ntg
00119
00120 irg_exin(itg,ipg) = 0
00121 irg_exout(itg,ipg) = 0
00122 rg_exin(itg,ipg) = 0.0d0
00123 rg_exout(itg,ipg) = 0.0d0
00124
00125 sth = sinthg(itg)
00126 cphi = cosphig(ipg)
00127 point_line_dis2 = sepa**2*(1.0 - sth**2*cphi**2)
00128
00129 if (point_line_dis2.lt.ex_radius**2) then
00130
00131 root_det = sqrt(ex_radius**2 - point_line_dis2)
00132 rg_exin(itg,ipg) = sepa*sth*cphi - root_det
00133 rg_exout(itg,ipg) = sepa*sth*cphi + root_det
00134
00135 do irg = 0, nrg - 1
00136 if (rg_exin(itg,ipg).ge.rg(irg)-small.and. &
00137 & rg_exin(itg,ipg).lt.rg(irg+1)-small) irg_exin(itg,ipg)=irg
00138 if (rg_exout(itg,ipg).gt.rg(irg)+small.and. &
00139 & rg_exout(itg,ipg).le.rg(irg+1)+small) irg_exout(itg,ipg)=irg+1
00140 end do
00141 end if
00142
00143 if (itg.eq.0.or.ipg.eq.0) cycle
00144
00145 ihrg_exin(itg,ipg) = 1
00146 ihrg_exout(itg,ipg) = 1
00147 hrg_exin(itg,ipg) = 0.0d0
00148 hrg_exout(itg,ipg) = 0.0d0
00149
00150 sth = hsinthg(itg)
00151 cphi = hcosphig(ipg)
00152 point_line_dis2 = sepa**2*(1.0 - sth**2*cphi**2)
00153
00154 if (point_line_dis2.lt.ex_radius**2) then
00155
00156 root_det = sqrt(ex_radius**2 - point_line_dis2)
00157 hrg_exin(itg,ipg) = sepa*sth*cphi - root_det
00158 hrg_exout(itg,ipg) = sepa*sth*cphi + root_det
00159
00160 do irg = 0, nrg - 1
00161 if (hrg_exin(itg,ipg).ge.rg(irg).and. &
00162 & hrg_exin(itg,ipg).lt.rg(irg+1)) ihrg_exin(itg,ipg)=irg+1
00163 if (hrg_exout(itg,ipg).gt.rg(irg).and. &
00164 & hrg_exout(itg,ipg).le.rg(irg+1))ihrg_exout(itg,ipg)=irg+1
00165 end do
00166 end if
00167 end do
00168 end do
00169
00170
00171
00172 do ipg = 0, npg
00173 do irg = 0, nrg
00174 itg_exin(irg,ipg) = 0
00175 itg_exout(irg,ipg) = 0
00176 thg_exin(irg,ipg) = 0.0d0
00177 thg_exout(irg,ipg) = 0.0d0
00178
00179 if (irg.eq.0) cycle
00180 if (ipg.ge.npgxzp.and.ipg.le.npgxzm) cycle
00181
00182 rrgg = rg(irg)
00183 cphi = cosphig(ipg)
00184
00185 sth = (rrgg**2 + sepa**2 - ex_radius**2)/(2.0d0*sepa*rrgg*cphi)
00186 if (sth.le.1.0d0) then
00187 thg_exin(irg,ipg) = dasin(sth)
00188 thg_exout(irg,ipg) = pi - dasin(sth)
00189
00190 do itg = 0, ntg-1
00191 if (thg_exin(irg,ipg).ge.thg(itg).and. &
00192 & thg_exin(irg,ipg).lt.thg(itg+1)) itg_exin(irg,ipg) = itg
00193 end do
00194 itg_exout(irg,ipg) = ntg - itg_exin(irg,ipg)
00195 end if
00196 end do
00197 end do
00198
00199
00200 do ipg = 1, npg
00201 do irg = 1, nrg
00202 ihtg_exin(irg,ipg) = 1
00203 ihtg_exout(irg,ipg) = 1
00204 hthg_exin(irg,ipg) = 0.0d0
00205 hthg_exout(irg,ipg) = 0.0d0
00206
00207 rrgg = hrg(irg)
00208 cphi = hcosphig(ipg)
00209
00210 sth = (rrgg**2 + sepa**2 - ex_radius**2)/(2.0d0*sepa*rrgg*cphi)
00211 if (sth.le.1.0d0) then
00212 hthg_exin(irg,ipg) = dasin(sth)
00213 hthg_exout(irg,ipg) = pi - dasin(sth)
00214
00215 do itg = 0, ntg-1
00216 if (hthg_exin(irg,ipg).ge.thg(itg).and. &
00217 & hthg_exin(irg,ipg).lt.thg(itg+1)) ihtg_exin(irg,ipg) = itg+1
00218 if (hthg_exout(irg,ipg).ge.thg(itg).and. &
00219 & hthg_exout(irg,ipg).lt.thg(itg+1)) ihtg_exout(irg,ipg)=itg+1
00220 end do
00221 end if
00222 end do
00223 end do
00224
00225
00226
00227 do itg = 0, ntg
00228 do irg = 0, nrg
00229 ipg_exin(irg,itg) = 0
00230 ipg_exout(irg,itg) = npg
00231 phig_exin(irg,itg) = 0.0d0
00232 phig_exout(irg,itg) = 2.0d0*pi
00233
00234 if (irg.eq.0.or.itg.eq.0.or.itg.eq.ntg) cycle
00235
00236 rrgg = rg(irg)
00237 sth = sinthg(itg)
00238
00239 cphi = (rrgg**2 + sepa**2 - ex_radius**2)/(2.0d0*sepa*rrgg*sth)
00240 if (cphi.lt.1.0d0) then
00241 phig_exin(irg,itg) = dacos(cphi)
00242 phig_exout(irg,itg) = 2.0d0*pi - dacos(cphi)
00243 do ipg = 0, npg-1
00244 if (phig_exin(irg,itg).gt.phig(ipg).and. &
00245 & phig_exin(irg,itg).le.phig(ipg+1)) ipg_exin(irg,itg)=ipg+1
00246 if (phig_exout(irg,itg).ge.phig(ipg).and. &
00247 & phig_exout(irg,itg).lt.phig(ipg+1)) ipg_exout(irg,itg)=ipg
00248 end do
00249 end if
00250 end do
00251 end do
00252
00253
00254 do itg = 1, ntg
00255 do irg = 1, nrg
00256 ihpg_exin(irg,itg) = 1
00257 ihpg_exout(irg,itg) = npg
00258 hphig_exin(irg,itg) = 0.0d0
00259 hphig_exout(irg,itg) = 0.0d0
00260
00261
00262
00263
00264 rrgg = hrg(irg)
00265 sth = hsinthg(itg)
00266
00267 cphi = (rrgg**2 + sepa**2 - ex_radius**2)/(2.0d0*sepa*rrgg*sth)
00268 if (cphi.lt.1.0d0) then
00269 hphig_exin(irg,itg) = dacos(cphi)
00270 hphig_exout(irg,itg) = 2.0d0*pi- dacos(cphi)
00271 do ipg = 0, npg-1
00272 if (hphig_exin(irg,itg).gt.phig(ipg).and. &
00273 & hphig_exin(irg,itg).le.phig(ipg+1)) ihpg_exin(irg,itg)=ipg+1
00274 if (hphig_exout(irg,itg).ge.phig(ipg).and. &
00275 & hphig_exout(irg,itg).lt.phig(ipg+1)) ihpg_exout(irg,itg)=ipg+1
00276 end do
00277 end if
00278 end do
00279 end do
00280
00281
00282
00283 do ipg = 0, npg
00284 do itg = 0, ntg
00285 do irg = 0, nrg
00286 rb(irg,itg,ipg) = 0.0d0
00287 thb(irg,itg,ipg) = 0.0d0
00288 phib(irg,itg,ipg) = 0.0d0
00289
00290 rrgg = rg(irg)
00291 sth = sinthg(itg)
00292 cth = costhg(itg)
00293 sphi = sinphig(ipg)
00294 cphi = cosphig(ipg)
00295 x0 = rrgg*sth*cphi
00296 y0 = rrgg*sth*sphi
00297 z0 = rrgg*cth
00298
00299
00300 rg_exc_dis2 = (x0 - sepa)**2 + y0**2 + z0**2
00301 xxyy2 = (x0 - sepa)**2 + y0**2
00302
00303 if (rg_exc_dis2.gt.0.0d0) &
00304 & rb(irg,itg,ipg) = sqrt(rg_exc_dis2)
00305 thb(irg,itg,ipg) = atan2(sqrt(xxyy2),z0)
00306 phib(irg,itg,ipg) = dmod(2.0d0*pi+datan2(y0,x0-sepa),2.0d0*pi)
00307
00308 end do
00309 end do
00310 end do
00311
00312
00313
00314 do ipg = 1, npg
00315 do itg = 1, ntg
00316 do irg = 1, nrg
00317 hrb(irg,itg,ipg) = 0.0d0
00318 hthb(irg,itg,ipg) = 0.0d0
00319 hphib(irg,itg,ipg) = 0.0d0
00320
00321 rrgg = hrg(irg)
00322 sth = hsinthg(itg)
00323 cth = hcosthg(itg)
00324 sphi = hsinphig(ipg)
00325 cphi = hcosphig(ipg)
00326 x0 = rrgg*sth*cphi
00327 y0 = rrgg*sth*sphi
00328 z0 = rrgg*cth
00329
00330 rg_exc_dis2 = (x0 - sepa)**2 + y0**2 + z0**2
00331 xxyy2 = (x0 - sepa)**2 + y0**2
00332
00333 if (rg_exc_dis2.gt.0.0d0) &
00334 & hrb(irg,itg,ipg) = sqrt(rg_exc_dis2)
00335 hthb(irg,itg,ipg) = atan2(sqrt(xxyy2),z0)
00336 hphib(irg,itg,ipg) = dmod(2.0d0*pi+datan2(y0,x0-sepa),2.0d0*pi)
00337
00338 end do
00339 end do
00340 end do
00341
00342 ntg_exin_min = ntg
00343 ntg_exout_max = 0
00344 do irg = 0, nrg
00345 if (itg_exin(irg,npgxzp).gt.0) &
00346 & ntg_exin_min = min0(itg_exin(irg,npgxzp),ntg_exin_min)
00347 if (itg_exout(irg,npgxzp).gt.0) &
00348 & ntg_exout_max = max0(itg_exout(irg,npgxzp),ntg_exout_max)
00349 end do
00350 npg_exin_max = 0
00351 npg_exout_min = npg
00352 do irg = 0, nrg
00353 if (ipg_exin(irg,ntgxy).gt.0) &
00354 & npg_exin_max = max0(ipg_exin(irg,ntgxy),npg_exin_max)
00355 if (ipg_exout(irg,ntgxy).lt.npg) &
00356 & npg_exout_min = min0(ipg_exout(irg,ntgxy),npg_exout_min)
00357 end do
00358
00359 write(6,*) 'ntg_exin_min = ' , ntg_exin_min, &
00360 & ', ntg_exout_max = ', ntg_exout_max
00361 write(6,*) 'npg_exin_max = ' , npg_exin_max, &
00362 & ', npg_exout_min = ', npg_exout_min
00363
00364 end subroutine calc_grid_points_binary_excision
00365 end module grid_points_binary_excision