initibm Subroutine

public subroutine initibm()

Uses

  • proc~~initibm~~UsesGraph proc~initibm initibm decomp_2d decomp_2d proc~initibm->decomp_2d module~modglobal modglobal proc~initibm->module~modglobal module~modmpi modmpi proc~initibm->module~modmpi module~modstat_nc modstat_nc proc~initibm->module~modstat_nc mpi mpi module~modmpi->mpi module~modstat_nc->module~modmpi netcdf netcdf module~modstat_nc->netcdf

Arguments

None

Calls

proc~~initibm~~CallsGraph proc~initibm initibm exchange_halo_z exchange_halo_z proc~initibm->exchange_halo_z proc~define_nc define_nc proc~initibm->proc~define_nc proc~initibmnorm initibmnorm proc~initibm->proc~initibmnorm proc~initibmwallfun initibmwallfun proc~initibm->proc~initibmwallfun proc~ncinfo ncinfo proc~initibm->proc~ncinfo proc~open_nc open_nc proc~initibm->proc~open_nc proc~solid solid proc~initibm->proc~solid proc~writestat_dims_nc writestat_dims_nc proc~initibm->proc~writestat_dims_nc nf90_def_var nf90_def_var proc~define_nc->nf90_def_var nf90_enddef nf90_enddef proc~define_nc->nf90_enddef nf90_inq_dimid nf90_inq_dimid proc~define_nc->nf90_inq_dimid nf90_inq_varid nf90_inq_varid proc~define_nc->nf90_inq_varid nf90_put_att nf90_put_att proc~define_nc->nf90_put_att nf90_redef nf90_redef proc~define_nc->nf90_redef proc~nchandle_error nchandle_error proc~define_nc->proc~nchandle_error mpi_bcast mpi_bcast proc~initibmnorm->mpi_bcast zend zend proc~initibmnorm->zend zstart zstart proc~initibmnorm->zstart proc~initibmwallfun->mpi_bcast proc~alignment alignment proc~initibmwallfun->proc~alignment proc~plane_line_intersection plane_line_intersection proc~initibmwallfun->proc~plane_line_intersection proc~initibmwallfun->zend proc~initibmwallfun->zstart nf90_create nf90_create proc~open_nc->nf90_create nf90_def_dim nf90_def_dim proc~open_nc->nf90_def_dim proc~open_nc->nf90_def_var proc~open_nc->nf90_enddef nf90_get_var nf90_get_var proc~open_nc->nf90_get_var proc~open_nc->nf90_inq_dimid proc~open_nc->nf90_inq_varid nf90_inquire nf90_inquire proc~open_nc->nf90_inquire nf90_inquire_dimension nf90_inquire_dimension proc~open_nc->nf90_inquire_dimension nf90_open nf90_open proc~open_nc->nf90_open proc~open_nc->nf90_put_att nf90_sync nf90_sync proc~open_nc->nf90_sync proc~solid->zstart proc~writestat_dims_nc->nf90_inq_varid proc~writestat_dims_nc->nf90_inquire_dimension nf90_put_var nf90_put_var proc~writestat_dims_nc->nf90_put_var proc~is_equal is_equal proc~alignment->proc~is_equal nf90_strerror nf90_strerror proc~nchandle_error->nf90_strerror

Called by

proc~~initibm~~CalledByGraph proc~initibm initibm program~dalesurban DALESURBAN program~dalesurban->proc~initibm

Source Code

   subroutine initibm
     use modglobal, only : libm, xh, xf, yh, yf, zh, zf, xhat, yhat, zhat, vec0, &
                           ib, ie, ih, ihc, jb, je, jh, jhc, kb, ke, kh, khc, nsv, &
                           iwallmom, lmoist, ltempeq, cexpnr, nfcts, lwritefac
     use decomp_2d, only : exchange_halo_z
     use modmpi,    only : myid
     use modstat_nc,only: open_nc, define_nc, ncinfo, writestat_dims_nc

     real, allocatable :: rhs(:,:,:)

     if (.not. libm) return

     solid_info_u%nsolpts = nsolpts_u
     solid_info_v%nsolpts = nsolpts_v
     solid_info_w%nsolpts = nsolpts_w
     call initibmnorm('solid_u.txt', solid_info_u)
     call initibmnorm('solid_v.txt', solid_info_v)
     call initibmnorm('solid_w.txt', solid_info_w)

     ! Define (real) masks
     ! Hopefully this can be removed eventually if (integer) IIx halos can be communicated
     ! These are only used in modibm, to cancel subgrid term across solid boundaries
     allocate(mask_u(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); mask_u = 1.
     allocate(mask_v(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); mask_v = 1.
     allocate(mask_w(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); mask_w = 1.
     mask_w(:,:,kb) = 0.     ! In future this shouldn't be needed?
     mask_u(:,:,kb-kh) = 0.
     mask_v(:,:,kb-kh) = 0.
     mask_w(:,:,kb-kh) = 0.

     allocate(rhs(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh))
     call solid(solid_info_u, mask_u, rhs, 0., ih, jh, kh)
     call solid(solid_info_v, mask_v, rhs, 0., ih, jh, kh)
     call solid(solid_info_w, mask_w, rhs, 0., ih, jh, kh)
     call exchange_halo_z(mask_u)!, opt_zlevel=(/ih,jh,0/))
     call exchange_halo_z(mask_v)!, opt_zlevel=(/ih,jh,0/))
     call exchange_halo_z(mask_w)!, opt_zlevel=(/ih,jh,0/))

     if (iwallmom > 1) then
       bound_info_u%nbndpts = nbndpts_u
       bound_info_v%nbndpts = nbndpts_v
       bound_info_w%nbndpts = nbndpts_w
       bound_info_u%nfctsecs = nfctsecs_u
       bound_info_v%nfctsecs = nfctsecs_v
       bound_info_w%nfctsecs = nfctsecs_w
       call initibmwallfun('fluid_boundary_u.txt', 'facet_sections_u.txt', xhat, bound_info_u)
       call initibmwallfun('fluid_boundary_v.txt', 'facet_sections_v.txt', yhat, bound_info_v)
       call initibmwallfun('fluid_boundary_w.txt', 'facet_sections_w.txt', zhat, bound_info_w)
     end if

     if (ltempeq .or. lmoist .or. nsv>0 .or. lwritefac) then
       solid_info_c%nsolpts = nsolpts_c
       call initibmnorm('solid_c.txt', solid_info_c)

       bound_info_c%nbndpts = nbndpts_c
       bound_info_c%nfctsecs = nfctsecs_c
       call initibmwallfun('fluid_boundary_c.txt', 'facet_sections_c.txt', vec0, bound_info_c)

       allocate(mask_c(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); mask_c = 1.
       mask_c(:,:,kb-kh) = 0.
       call solid(solid_info_c, mask_c, rhs, 0., ih, jh, kh)
       call exchange_halo_z(mask_c)!, opt_zlevel=(/ih,jh,0/))
     end if

     deallocate(rhs)

     ! write facet stresses and pressure to fac.xxx.nc
     if (lwritefac) then
       allocate(fac_tau_x(1:nfcts))
       allocate(fac_tau_y(1:nfcts))
       allocate(fac_tau_z(1:nfcts))
       allocate(fac_pres(1:nfcts))
       allocate(fac_htc(1:nfcts))
       allocate(fac_cth(1:nfcts))
       fac_tau_x = 0.
       fac_tau_y = 0.
       fac_tau_z = 0.
       fac_pres = 0.
       fac_htc = 0.
       fac_cth = 0.
       allocate(fac_tau_x_av(1:nfcts))
       allocate(fac_tau_y_av(1:nfcts))
       allocate(fac_tau_z_av(1:nfcts))
       allocate(fac_pres_av(1:nfcts))
       allocate(fac_htc_av(1:nfcts))
       allocate(fac_cth_av(1:nfcts))
       fac_tau_x_av = 0.
       fac_tau_y_av = 0.
       fac_tau_z_av = 0.
       fac_pres_av = 0.
       fac_htc_av = 0.
       fac_cth_av = 0.

       facname(5:7) = cexpnr
       allocate(ncstatfac(nstatfac,4))
       call ncinfo(tncstatfac(1,:),'t', 'Time', 's', 'time')
       call ncinfo(ncstatfac( 1,:),'tau_x', 'tau_x', 'Pa','ft')
       call ncinfo(ncstatfac( 2,:),'tau_y', 'tau_y', 'Pa','ft')
       call ncinfo(ncstatfac( 3,:),'tau_z', 'tau_z', 'Pa','ft')
       call ncinfo(ncstatfac( 4,:),'pres', 'pressure', 'Pa','ft')
       call ncinfo(ncstatfac( 5,:),'htc', 'heat transfer coefficient', '','ft')
       call ncinfo(ncstatfac( 6,:),'cth', 'heat transfer coefficient (Ivo)', '','ft')

       if (myid==0) then
         call open_nc(facname, ncidfac, nrecfac, nfcts=nfcts)
         if (nrecfac==0) then
           call define_nc(ncidfac, 1, tncstatfac)
           call writestat_dims_nc(ncidfac)
         end if
         call define_nc(ncidfac, nstatfac, ncstatfac)
       end if
     end if

   end subroutine initibm