00001 subroutine sourceterm_Bfun(sou,Bfun,potx,poty,potz)
00002 use phys_constant, only : long
00003 use grid_parameter, only : nrg, ntg, npg
00004 use def_metric
00005 use make_array_3d
00006 use interface_grgrad_midpoint
00007 use interface_grgrad_midpoint_r3rd_type0
00008 use interface_grgrad_midpoint_r4th_type0
00009 implicit none
00010 integer :: irg, itg, ipg
00011 real(long) :: gradB2, divG
00012 real(long) :: dfdx, dfdy, dfdz
00013 real(long), pointer :: sou(:,:,:), Bfun(:,:,:), potx(:,:,:), poty(:,:,:), potz(:,:,:)
00014 real(long),pointer :: dBdx(:,:,:), dBdy(:,:,:), dBdz(:,:,:)
00015 real(long),pointer :: dpotxdx(:,:,:), dpotxdy(:,:,:), dpotxdz(:,:,:)
00016 real(long),pointer :: dpotydx(:,:,:), dpotydy(:,:,:), dpotydz(:,:,:)
00017 real(long),pointer :: dpotzdx(:,:,:), dpotzdy(:,:,:), dpotzdz(:,:,:)
00018
00019 call alloc_array3d(dpotxdx, 0, nrg, 0, ntg, 0, npg)
00020 call alloc_array3d(dpotxdy, 0, nrg, 0, ntg, 0, npg)
00021 call alloc_array3d(dpotxdz, 0, nrg, 0, ntg, 0, npg)
00022 call alloc_array3d(dpotydx, 0, nrg, 0, ntg, 0, npg)
00023 call alloc_array3d(dpotydy, 0, nrg, 0, ntg, 0, npg)
00024 call alloc_array3d(dpotydz, 0, nrg, 0, ntg, 0, npg)
00025 call alloc_array3d(dpotzdx, 0, nrg, 0, ntg, 0, npg)
00026 call alloc_array3d(dpotzdy, 0, nrg, 0, ntg, 0, npg)
00027 call alloc_array3d(dpotzdz, 0, nrg, 0, ntg, 0, npg)
00028 call alloc_array3d(dBdx, 0, nrg, 0, ntg, 0, npg)
00029 call alloc_array3d(dBdy, 0, nrg, 0, ntg, 0, npg)
00030 call alloc_array3d(dBdz, 0, nrg, 0, ntg, 0, npg)
00031
00032
00033
00034
00035
00036
00037 do ipg = 1, npg
00038 do itg = 1, ntg
00039 do irg = 1, nrg
00040 call grgrad_midpoint_r4th_type0(potx,dfdx,dfdy,dfdz,irg,itg,ipg,'bh')
00041 dpotxdx(irg,itg,ipg) = dfdx
00042 dpotxdy(irg,itg,ipg) = dfdy
00043 dpotxdz(irg,itg,ipg) = dfdz
00044 call grgrad_midpoint_r4th_type0(poty,dfdx,dfdy,dfdz,irg,itg,ipg,'bh')
00045 dpotydx(irg,itg,ipg) = dfdx
00046 dpotydy(irg,itg,ipg) = dfdy
00047 dpotydz(irg,itg,ipg) = dfdz
00048 call grgrad_midpoint_r4th_type0(potz,dfdx,dfdy,dfdz,irg,itg,ipg,'bh')
00049 dpotzdx(irg,itg,ipg) = dfdx
00050 dpotzdy(irg,itg,ipg) = dfdy
00051 dpotzdz(irg,itg,ipg) = dfdz
00052 call grgrad_midpoint_r4th_type0(Bfun,dfdx,dfdy,dfdz,irg,itg,ipg,'bh')
00053 dBdx(irg,itg,ipg) = dfdx
00054 dBdy(irg,itg,ipg) = dfdy
00055 dBdz(irg,itg,ipg) = dfdz
00056
00057 sou(irg,itg,ipg) = dpotxdx(irg,itg,ipg) + dpotydy(irg,itg,ipg) + dpotzdz(irg,itg,ipg)
00058
00059
00060
00061
00062 end do
00063 end do
00064 end do
00065
00066 deallocate(dpotxdx)
00067 deallocate(dpotxdy)
00068 deallocate(dpotxdz)
00069 deallocate(dpotydx)
00070 deallocate(dpotydy)
00071 deallocate(dpotydz)
00072 deallocate(dpotzdx)
00073 deallocate(dpotzdy)
00074 deallocate(dpotzdz)
00075 deallocate(dBdx)
00076 deallocate(dBdy)
00077 deallocate(dBdz)
00078 end subroutine sourceterm_Bfun