Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rfj82982/Incompact3d
Browse files Browse the repository at this point in the history
  • Loading branch information
rfj82982 committed Apr 18, 2024
2 parents 3a8735d + 16ff196 commit 38e0aed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
49 changes: 15 additions & 34 deletions src/mhd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -252,31 +252,16 @@ end subroutine mhd_sta
!| 28-Oct-2022 | Created by J. Fang STFC Daresbury Laboratory |
!+-------------------------------------------------------------------+
subroutine momentum_forcing_mhd(dux1,duy1,duz1,ux1,uy1,uz1)
!
!USE decomp_2d
use mpi
use param, only : dx,dz
use variables, only : ppy
use variables, only : yp,ny,nz
use decomp_2d, only : xstart
use constants, only : pi
use param, only : zero,two,three,dy,yly
!
! arguments
real(mytype),intent(in),dimension(xsize(1),xsize(2),xsize(3)) :: &
ux1,uy1,uz1
real(mytype),intent(inout), &
dimension(xsize(1),xsize(2),xsize(3)) :: dux1,duy1,duz1
!
real(mytype) :: eforce(3),Ebar(3)
real(mytype) :: ub,uball,coeff

! local data
integer :: i,j,k,jloc,code
real(mytype) :: elecur(3),var1(3),var2(3)
!
real(mytype) :: xx(xsize(1)),yy(xsize(2)),zz(xsize(3))
!
!
integer :: i,j,k
real(mytype) :: eforce(3), elecur(3),var1(3),var2(3)

if(mhd_equation) then
Je=del_cross_prod(Bm+Bmean)/Rem
Expand Down Expand Up @@ -354,32 +339,28 @@ function grad_vmesh(phi) result(dphi)
use variables, only: ffxpS,fsxpS,fwxpS,ffypS,fsypS,fwypS,ffzpS, &
fszpS,fwzpS,ppy,sx,sy,sz,derxs,derys,derzs
use param, only: zero
use var, only : ta1,di1,ta2,di2,ta3,di3,td1,td2,td3,tg1
use var, only : ta1,di1,ta2,tb2,di2,ta3,tb3,di3
!
real(mytype) :: dphi(xsize(1),xsize(2),xsize(3),3)
real(mytype),intent(in) :: phi(xsize(1),xsize(2),xsize(3))
!
real(mytype), dimension(xsize(1), xsize(2), xsize(3)) :: dpot1
real(mytype), dimension(ysize(1), ysize(2), ysize(3)) :: pot2, dpot2
real(mytype), dimension(zsize(1), zsize(2), zsize(3)) :: pot3, dpot3
call transpose_x_to_y(phi,ta2)
call transpose_y_to_z(ta2,ta3)
!
call transpose_x_to_y(phi,pot2)
call transpose_y_to_z(pot2,pot3)
call derxS (ta1, phi, di1, sx, ffxpS, fsxpS, fwxpS, xsize(1), xsize(2), xsize(3), 1, zero)
call deryS (tb2, ta2, di2, sy, ffypS, fsypS, fwypS, ppy, ysize(1), ysize(2), ysize(3), 1, zero)
call derzS (tb3, ta3, di3, sz, ffzpS, fszpS, fwzpS, zsize(1), zsize(2), zsize(3), 1, zero)
!
call derxS (dpot1, phi, di1, sx, ffxpS, fsxpS, fwxpS, xsize(1), xsize(2), xsize(3), 1, zero)
call deryS (dpot2, pot2, di2, sy, ffypS, fsypS, fwypS, ppy, ysize(1), ysize(2), ysize(3), 1, zero)
call derzS (dpot3, pot3, di3, sz, ffzpS, fszpS, fwzpS, zsize(1), zsize(2), zsize(3), 1, zero)
dphi(:,:,:,1)=ta1
!
dphi(:,:,:,1)=dpot1
call transpose_y_to_x(tb2,ta1)
!
call transpose_y_to_x(dpot2,dpot1)
dphi(:,:,:,2)=ta1
!
dphi(:,:,:,2)=dpot1
!
call transpose_z_to_y(dpot3,dpot2)
call transpose_y_to_x(dpot2,dpot1)
call transpose_z_to_y(tb3,ta2)
call transpose_y_to_x(ta2,ta1)

dphi(:,:,:,3)=dpot1
dphi(:,:,:,3)=ta1
!
end function grad_vmesh
!+-------------------------------------------------------------------+
Expand Down
38 changes: 31 additions & 7 deletions src/tools.f90
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
use param
use MPI
use navier, only : gradp
use mhd, only : mhd_active,mhd_equation,Bm
use mhd, only : mhd_active,mhd_equation,Bm,dBm

implicit none

Expand Down Expand Up @@ -313,9 +313,17 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
endif

if (mhd_active .and. mhd_equation) then
call decomp_2d_write_one(1,Bm(:,:,:,1),resfile,'bx',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,2),resfile,'by',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,3),resfile,'bz',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,1),resfile,'bx',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,2),resfile,'by',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,Bm(:,:,:,3),resfile,'bz',0,io_restart,reduce_prec=.false.)
if (itimescheme==3) then
call decomp_2d_write_one(1,dBm(:,:,:,1,2),resfile,'dbx-2',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,2,2),resfile,'dby-2',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,3,2),resfile,'dbz-2',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,1,3),resfile,'dbx-3',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,2,3),resfile,'dby-3',0,io_restart,reduce_prec=.false.)
call decomp_2d_write_one(1,dBm(:,:,:,3,3),resfile,'dbz-3',0,io_restart,reduce_prec=.false.)
endif
endif

call decomp_2d_end_io(io_restart, resfile)
Expand Down Expand Up @@ -432,9 +440,17 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
end if

if(mhd_active .and. mhd_equation) then
call decomp_2d_read_one(1,Bm(:,:,:,1),resfile,'bx',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,2),resfile,'by',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,3),resfile,'bz',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,1),resfile,'bx',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,2),resfile,'by',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,Bm(:,:,:,3),resfile,'bz',io_restart,reduce_prec=.false.)
if (itimescheme==3) then
call decomp_2d_read_one(1,dBm(:,:,:,1,2),resfile,'dbx-2',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,2,2),resfile,'dby-2',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,3,2),resfile,'dbz-2',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,1,3),resfile,'dbx-3',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,2,3),resfile,'dby-3',io_restart,reduce_prec=.false.)
call decomp_2d_read_one(1,dBm(:,:,:,3,3),resfile,'dbz-3',io_restart,reduce_prec=.false.)
endif
endif

call decomp_2d_end_io(io_restart, resfile)
Expand Down Expand Up @@ -557,6 +573,14 @@ subroutine init_restart_adios2()
call decomp_2d_register_variable(io_restart, "bx", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "by", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "bz", 1, 0, 0, mytype)
if (itimescheme.eq.3) then
call decomp_2d_register_variable(io_restart, "dbx-2", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dby-2", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dbz-2", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dbx-3", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dby-3", 1, 0, 0, mytype)
call decomp_2d_register_variable(io_restart, "dbz-3", 1, 0, 0, mytype)
endif
end if

end subroutine init_restart_adios2
Expand Down

0 comments on commit 38e0aed

Please sign in to comment.