Skip to content

Commit

Permalink
Minor change on weno solver to improve efficiency: elements marked as…
Browse files Browse the repository at this point in the history
… upwind should use a less limiting CFL condition. Minor changes on the 2nd option of NWM's post_couple_omp.F90 (add center element to Tier n) and rename the script to combine_sink_source.F90
  • Loading branch information
feiye-vims committed Feb 14, 2020
1 parent a1f96d8 commit c46c7bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/Hydro/transport_TVD_imp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ subroutine do_transport_tvd_imp(it,ltvd,ntr,difnum_max_l) !,nvrt1,npa1,dfh1)
vj=area(i)*(ze(k,i)-ze(k-1,i))

if(psumtr(1)/=0) then
tmp=vj/psumtr(1)*courant_weno*(1-1.e-6) !safety factor 1.e-6 included
if (iupwind_e(i)==1) then !upwind
tmp=vj/psumtr(1)*(1-1.e-6) !safety factor included
else !weno
tmp=vj/psumtr(1)*courant_weno*(1-1.e-6) !safety factor 1.e-6 included
endif

if(tmp<dtbl2) then
dtbl2=tmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
!Output files
! source_sink.in.1, msource.th.1, vsource.th.1, vsink.th.1
!
!ifort -CB -O2 -qopenmp -o post_couple_omp post_couple_omp.f90
!pgf90 -O2 -mp -o post_couple_omp post_couple_omp.f90
!serial:
!ifort -CB -O2 -o combine_sink_source combine_sink_source.F90
!pgf90 -O2 -o combine_sink_source combine_sink_source.F90
!
!openmp:
!ifort -CB -O2 -qopenmp -o combine_sink_source combine_sink_source.F90
!pgf90 -O2 -mp -o combine_sink_source combine_sink_source.F90
!export OMP_NUM_TREADS=8
!setenv OMP_NUM_TREADS 8

Expand All @@ -35,7 +40,7 @@ program coupling_nwm
real(8) :: tmp,distance,dist,max_dist
real(8), allocatable :: temp(:),xx(:),yy(:),xel(:),yel(:)
integer, allocatable :: elnode(:,:),i34(:),indel(:,:),n_sink_source(:), &
& i_sink_source(:,:),ntier1(:),ele_source(:),ele_sink(:),is_source_ele(:), &
& i_sink_source(:,:),ntier1(:),ele_source(:),ele_sink(:),imap_ele2source(:), &
& tier1(:,:),tier_n(:,:),ntier_n(:),nne(:),nxq(:,:,:),ic3(:,:),isbnd(:), &
& ncount(:),nlbnd(:),lbnd(:,:),nobnd(:),obnd(:,:),i_island(:)
integer :: mnei,inbr,i,j,k,nsource,nsink,itmp,nt,istat,nd,ntracer,n_tier_dist
Expand Down Expand Up @@ -378,11 +383,11 @@ program coupling_nwm
tier_n=0; ntier_n=0

!mark sources
allocate(is_source_ele(ne),stat=istat)
if (istat/=0) stop 'Failed to alloc. is_source_ele'
is_source_ele=0
allocate(imap_ele2source(ne),stat=istat)
if (istat/=0) stop 'Failed to alloc. imap_ele2source'
imap_ele2source=0
do i=1,nsource
is_source_ele(ele_source(i))=i
imap_ele2source(ele_source(i))=i
enddo

!$omp parallel do private (i,ie,ntmp)
Expand All @@ -394,6 +399,10 @@ program coupling_nwm
stop
else
tier_n(0,i)=ie !self
if (imap_ele2source(ie)>0) then !self has both sink and source
n_sink_source(i)=n_sink_source(i)+1
i_sink_source(n_sink_source(i),i)=imap_ele2source(ie)
endif
call mark_bnd_neighbors(i,ie,0,n_tier_dist)
endif
enddo
Expand Down Expand Up @@ -445,11 +454,11 @@ program coupling_nwm
print*, ncount

!mark sources
allocate(is_source_ele(ne),stat=istat)
if (istat/=0) stop 'Failed to alloc. is_source_ele'
is_source_ele=0
allocate(imap_ele2source(ne),stat=istat)
if (istat/=0) stop 'Failed to alloc. imap_ele2source'
imap_ele2source=0
do i=1,nsource
is_source_ele(ele_source(i))=i
imap_ele2source(ele_source(i))=i
enddo

tier_n=0; ntier_n=0
Expand Down Expand Up @@ -635,9 +644,9 @@ recursive subroutine mark_bnd_neighbors(isink,ie_ctr,i_depth,n_tier_dist)
!debug
!write(*,*) 'ie_ctr,i_depth,ntier_n(isink),ie000:',ie_ctr,i_depth,ntier_n(isink),ie000

if (is_source_ele(ie000)>0) then
if (imap_ele2source(ie000)>0) then
n_sink_source(isink)=n_sink_source(isink)+1
i_sink_source(n_sink_source(isink),isink)=is_source_ele(ie000)
i_sink_source(n_sink_source(isink),isink)=imap_ele2source(ie000)
endif
endif

Expand Down Expand Up @@ -678,9 +687,9 @@ recursive subroutine mark_neighbors(isink,ie_ctr,i_depth,n_tier_dist)
!debug
!write(*,*) 'ie_ctr,i_depth,ntier_n(isink),ie000:',ie_ctr,i_depth,ntier_n(isink),ie000

if (is_source_ele(ie000)>0) then
if (imap_ele2source(ie000)>0) then
n_sink_source(isink)=n_sink_source(isink)+1
i_sink_source(n_sink_source(isink),isink)=is_source_ele(ie000)
i_sink_source(n_sink_source(isink),isink)=imap_ele2source(ie000)
endif
endif

Expand Down

0 comments on commit c46c7bd

Please sign in to comment.