Skip to content

Commit

Permalink
Use boundp to impose normals bcs.
Browse files Browse the repository at this point in the history
  • Loading branch information
p-costa committed Nov 8, 2024
1 parent 4082727 commit 6ca118b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 66 deletions.
65 changes: 2 additions & 63 deletions src/bound.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module mod_bound
use mod_types
implicit none
private
public bounduvw,boundnor,boundp,updt_rhs_b
public boundp,bounduvw,updt_rhs_b
contains
subroutine bounduvw(cbc,n,bc,nb,is_bound,is_correc,dl,dzc,dzf,u,v,w)
!
Expand Down Expand Up @@ -78,70 +78,9 @@ subroutine bounduvw(cbc,n,bc,nb,is_bound,is_correc,dl,dzc,dzf,u,v,w)
end if
end subroutine bounduvw
!
subroutine boundnor(cbc,n,bc,nb,is_bound,dl,dzc,nx,ny,nz)
!
! imposes boundary conditions on cell-centered vector fields (e.g. inteface normal)
!
implicit none
character(len=1), intent(in), dimension(0:1,3,3) :: cbc
integer , intent(in), dimension(3) :: n
real(rp), intent(in), dimension(0:1,3,3) :: bc
integer , intent(in), dimension(0:1,3 ) :: nb
logical , intent(in), dimension(0:1,3 ) :: is_bound
real(rp), intent(in), dimension(3 ) :: dl
real(rp), intent(in), dimension(0:) :: dzc
real(rp), intent(inout), dimension(0:,0:,0:) :: nx,ny,nz
integer :: idir,nh
!
nh = 1
!
#if !defined(_OPENACC)
do idir = 1,3
call updthalo(nh,halo(idir),nb(:,idir),idir,nx)
call updthalo(nh,halo(idir),nb(:,idir),idir,ny)
call updthalo(nh,halo(idir),nb(:,idir),idir,nz)
end do
#else
call updthalo_gpu(nh,cbc(0,:,1)//cbc(1,:,1)==['PP','PP','PP'],nx)
call updthalo_gpu(nh,cbc(0,:,2)//cbc(1,:,2)==['PP','PP','PP'],ny)
call updthalo_gpu(nh,cbc(0,:,3)//cbc(1,:,3)==['PP','PP','PP'],nz)
#endif
!
if(is_bound(0,1)) then
call set_bc(cbc(0,1,1),0,1,nh,.true.,bc(0,1,1),dl(1),nx)
call set_bc(cbc(0,1,2),0,1,nh,.true.,bc(0,1,2),dl(1),ny)
call set_bc(cbc(0,1,3),0,1,nh,.true.,bc(0,1,3),dl(1),nz)
end if
if(is_bound(1,1)) then
call set_bc(cbc(1,1,1),1,1,nh,.true.,bc(1,1,1),dl(1),nx)
call set_bc(cbc(1,1,2),1,1,nh,.true.,bc(1,1,2),dl(1),ny)
call set_bc(cbc(1,1,3),1,1,nh,.true.,bc(1,1,3),dl(1),nz)
end if
if(is_bound(0,2)) then
call set_bc(cbc(0,2,1),0,2,nh,.true.,bc(0,2,1),dl(2),nx)
call set_bc(cbc(0,2,2),0,2,nh,.true.,bc(0,2,2),dl(2),ny)
call set_bc(cbc(0,2,3),0,2,nh,.true.,bc(0,2,3),dl(2),nz)
end if
if(is_bound(1,2)) then
call set_bc(cbc(1,2,1),1,2,nh,.true.,bc(1,2,1),dl(2),nx)
call set_bc(cbc(1,2,2),1,2,nh,.true.,bc(1,2,2),dl(2),ny)
call set_bc(cbc(1,2,3),1,2,nh,.true.,bc(1,2,3),dl(2),nz)
end if
if(is_bound(0,3)) then
call set_bc(cbc(0,3,1),0,3,nh,.true.,bc(0,3,1),dzc(0) ,nx)
call set_bc(cbc(0,3,2),0,3,nh,.true.,bc(0,3,2),dzc(0) ,ny)
call set_bc(cbc(0,3,3),0,3,nh,.true.,bc(0,3,3),dzc(0) ,nz)
end if
if(is_bound(1,3)) then
call set_bc(cbc(1,3,1),1,3,nh,.true.,bc(1,3,1),dzc(n(3)),nx)
call set_bc(cbc(1,3,2),1,3,nh,.true.,bc(1,3,2),dzc(n(3)),ny)
call set_bc(cbc(1,3,3),1,3,nh,.true.,bc(1,3,3),dzc(n(3)),nz)
end if
end subroutine boundnor
!
subroutine boundp(cbc,n,bc,nb,is_bound,dl,dzc,p)
!
! imposes pressure and scalar boundary conditions
! imposes boundary conditions for a scalar field
!
implicit none
character(len=1), intent(in), dimension(0:1,3) :: cbc
Expand Down
10 changes: 7 additions & 3 deletions src/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ program cans
use, intrinsic :: ieee_arithmetic, only: is_nan => ieee_is_nan
use mpi
use decomp_2d
use mod_bound , only: boundp,bounduvw,boundnor,updt_rhs_b
use mod_bound , only: boundp,bounduvw,updt_rhs_b
use mod_chkdiv , only: chkdiv
use mod_chkdt , only: chkdt
use mod_common_mpi , only: myid,ierr
Expand Down Expand Up @@ -327,7 +327,9 @@ program cans
call acdi_cmpt_phi(n,seps,psi,phi)
call cmpt_norm_curv(n,dli,dzci,dzfi,phi,normx,normy,normz,kappa)
call boundp(cbcpsi,n,bcpsi,nb,is_bound,dl,dzc,kappa)
call boundnor(cbcnor,n,bcnor,nb,is_bound,dl,dzc,normx,normy,normz)
call boundp(cbcnor(:,:,1),n,bcnor(:,:,1),nb,is_bound,dl,dzc,normx)
call boundp(cbcnor(:,:,2),n,bcnor(:,:,2),nb,is_bound,dl,dzc,normy)
call boundp(cbcnor(:,:,3),n,bcnor(:,:,3),nb,is_bound,dl,dzc,normz)
!
#if defined(_CONSERVATIVE_MOMENTUM)
!$acc kernels default(present) async(1)
Expand Down Expand Up @@ -389,7 +391,9 @@ program cans
call acdi_cmpt_phi(n,seps,psi,phi)
call cmpt_norm_curv(n,dli,dzci,dzfi,phi,normx,normy,normz,kappa)
call boundp(cbcpsi,n,bcpre,nb,is_bound,dl,dzc,kappa)
call boundnor(cbcnor,n,bcnor,nb,is_bound,dl,dzc,normx,normy,normz)
call boundp(cbcnor(:,:,1),n,bcnor(:,:,1),nb,is_bound,dl,dzc,normx)
call boundp(cbcnor(:,:,2),n,bcnor(:,:,2),nb,is_bound,dl,dzc,normy)
call boundp(cbcnor(:,:,3),n,bcnor(:,:,3),nb,is_bound,dl,dzc,normz)
end if
#if defined(_SCALAR)
call tm_scal(tm_coeff,n,dli,dzci,dzfi,dt,ssource,rho12,ka12,cp12,psi,u,v,w,s)
Expand Down

0 comments on commit 6ca118b

Please sign in to comment.