get_cell_w Subroutine

public subroutine get_cell_w(xp, wc, variable_type)

Arguments

Type IntentOptional Attributes Name
double precision :: xp(1:ndim)
double precision :: wc(1:nw)
character(len=*) :: variable_type

Calls

proc~~get_cell_w~~CallsGraph proc~get_cell_w get_cell_w mpi_bcast mpi_bcast proc~get_cell_w->mpi_bcast phys_to_conserved phys_to_conserved proc~get_cell_w->phys_to_conserved phys_to_primitive phys_to_primitive proc~get_cell_w->phys_to_primitive proc~find_particle_ipe find_particle_ipe proc~get_cell_w->proc~find_particle_ipe proc~mpistop mpistop proc~get_cell_w->proc~mpistop proc~get_igslice get_igslice proc~find_particle_ipe->proc~get_igslice proc~particle_in_domain particle_in_domain proc~find_particle_ipe->proc~particle_in_domain mpi_abort mpi_abort proc~mpistop->mpi_abort proc~get_igslice->proc~mpistop

Source Code

  subroutine get_cell_w(xp,wc,variable_type)
    ! for given point (xp), looking for corresponding cell and then provide
    ! the plasma parameters (wc) of this cell

    double precision :: xp(1:ndim),wc(1:nw)
    character(*) :: variable_type

    double precision :: x3d(3)
    double precision :: dxb1,dxb2,dxb3,xbmin1,xbmin2,xbmin3,xbmax1,xbmax2,&
       xbmax3
    integer :: indomain,ixOmin1,ixOmin2,ixOmin3,ixOmax1,ixOmax2,ixOmax3,ixb1,&
       ixb2,ixb3,ixAmin1,ixAmin2,ixAmin3,ixAmax1,ixAmax2,ixAmax3,ixImin1,&
       ixImin2,ixImin3,ixImax1,ixImax2,ixImax3
    integer :: ipe,igrid,j

    indomain=0
    if (xp(3)>=xprobmin3 .and. xp(3)<xprobmax3) indomain=indomain+1
    if (xp(2)>=xprobmin2 .and. xp(2)<xprobmax2) indomain=indomain+1
    if (xp(1)>=xprobmin1 .and. xp(1)<xprobmax1) indomain=indomain+1
    if (indomain==ndim) then

      ! find pe and igrid
      x3d=0.d0
      do j=1,ndim
        x3d(j)=xp(j)
      enddo
      call find_particle_ipe(x3d,igrid,ipe)

      if (mype==ipe) then
        ! looking for the cell index
        xbmin1=rnode(rpxmin1_,igrid)
        xbmin2=rnode(rpxmin2_,igrid)
        xbmin3=rnode(rpxmin3_,igrid)
        xbmax1=rnode(rpxmax1_,igrid)
        xbmax2=rnode(rpxmax2_,igrid)
        xbmax3=rnode(rpxmax3_,igrid)
        dxb1=rnode(rpdx1_,igrid)
        dxb2=rnode(rpdx2_,igrid)
        dxb3=rnode(rpdx3_,igrid)
        ixOmin1=ixmlo1
        ixOmin2=ixmlo2
        ixOmin3=ixmlo3
        ixImin1=ixglo1
        ixImin2=ixglo2
        ixImin3=ixglo3
        ixImax1=ixghi1
        ixImax2=ixghi2
        ixImax3=ixghi3
        ixb1=floor((xp(1)-xbmin1)/dxb1)+ixOmin1
        ixb2=floor((xp(2)-xbmin2)/dxb2)+ixOmin2
        ixb3=floor((xp(3)-xbmin3)/dxb3)+ixOmin3
        ixAmin1=ixb1
        ixAmin2=ixb2
        ixAmin3=ixb3
        ixAmax1=ixb1
        ixAmax2=ixb2
        ixAmax3=ixb3

        wc=0.d0
        select case(variable_type)
          case('primitive')
            call phys_to_primitive(ixImin1,ixImin2,ixImin3,ixImax1,ixImax2,&
               ixImax3,ixAmin1,ixAmin2,ixAmin3,ixAmax1,ixAmax2,ixAmax3,&
               ps(igrid)%w,ps(igrid)%x)
            do j=1,nw
              wc(j)=ps(igrid)%w(ixb1,ixb2,ixb3,j)
            enddo
            call phys_to_conserved(ixImin1,ixImin2,ixImin3,ixImax1,ixImax2,&
               ixImax3,ixAmin1,ixAmin2,ixAmin3,ixAmax1,ixAmax2,ixAmax3,&
               ps(igrid)%w,ps(igrid)%x)
          case('conserved')
            do j=1,nw
              wc(j)=ps(igrid)%w(ixb1,ixb2,ixb3,j)
            enddo
          case default
            call mpistop("get_point_w: Unknown variable type!")
        end select

        ! for magnetic field
        if(physics_type=='mhd') then
          wc(iw_mag(1):iw_mag(ndir))=0.d0
          do j=1,ndir
            if (b0field) then
              wc(iw_mag(j))=ps(igrid)%w(ixb1,ixb2,ixb3,&
                 iw_mag(j))+ps(igrid)%B0(ixb1,ixb2,ixb3,j,0)
            else
              wc(iw_mag(j))=ps(igrid)%w(ixb1,ixb2,ixb3,iw_mag(j))
            endif
          enddo
        endif
      endif

      call MPI_BCAST(wc,nw,MPI_DOUBLE_PRECISION,ipe,icomm,ierrmpi)
    endif

  end subroutine get_cell_w