Skip to content

Commit

Permalink
1. Improve memory in subroutine invMatrix
Browse files Browse the repository at this point in the history
2. Add support for reading 2D C-type mesh from plot3d grid file
  • Loading branch information
sdhzhs committed Nov 23, 2023
1 parent da8da08 commit 0453bee
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 16 deletions.
19 changes: 9 additions & 10 deletions lib/BlockTDMA.f03
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ Subroutine invMatrix(invA,A,N)
implicit none
integer i,j,k,N,kp,iq
real(8) R,maxa,swap
real(8) invA(N,N),A(N,N),B(N,N)
real(8) invA(N,N),A(N,N)

B=0
invA=0
DO i=1,N
B(i,i)=1
invA(i,i)=1
end DO
DO k=1,N-1
maxa=0
Expand All @@ -50,9 +50,9 @@ Subroutine invMatrix(invA,A,N)
A(kp,j)=swap
end DO
DO j=1,N
swap=B(k,j)
B(k,j)=B(kp,j)
B(kp,j)=swap
swap=invA(k,j)
invA(k,j)=invA(kp,j)
invA(kp,j)=swap
end DO
end if
kp=k+1
Expand All @@ -62,14 +62,13 @@ Subroutine invMatrix(invA,A,N)
A(i,j)=A(i,j)-R*A(k,j)
end DO
DO j=1,N
B(i,j)=B(i,j)-R*B(k,j)
invA(i,j)=invA(i,j)-R*invA(k,j)
end DO
end DO
end DO
DO k=1,N
invA(N,k)=B(N,k)/A(N,N)
invA(N,k)=invA(N,k)/A(N,N)
DO i=N-1,1,-1
invA(i,k)=B(i,k)
iq=i+1
DO j=iq,N
invA(i,k)=invA(i,k)-A(i,j)*invA(j,k)
Expand All @@ -94,4 +93,4 @@ Subroutine Matrixmultiply(A,B,C,N,M)
end DO
end DO

end subroutine Matrixmultiply
end subroutine Matrixmultiply
26 changes: 26 additions & 0 deletions lib/Genmesh.f03
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Subroutine Genmesh(libmod)
opentrail=.false.
if(libmod=='S'.or.libmod=='I') then
Call Readfoil
else if(libmod=='M') then
Call Readmesh(libmod)
return
else if(libmod=='C') then
if(Pntctrl=='N') then
allocate(Xwd(Iwd),Ywd(Iwd))
Expand Down Expand Up @@ -146,3 +149,26 @@ Subroutine Readfoil
end if

end Subroutine Readfoil

Subroutine Readmesh(libmod)
use Aero2DCOM
implicit none
integer blocks,i,j,stat
character(128) ioerrmsg
character(*) libmod

open(unit=1,file=filename(1),status='old',IOSTAT=stat,IOMSG=ioerrmsg)
if(stat>0) stop ioerrmsg
read(1,*,IOSTAT=stat,IOMSG=ioerrmsg) blocks
read(1,*,IOSTAT=stat,IOMSG=ioerrmsg) Ip,Jp,Ib1,Ib2
if(stat>0) stop filename(1)//ioerrmsg
Ic=Ip-1
Jc=Jp-1
Call Allocarray(libmod)
read(1,*,IOSTAT=stat,IOMSG=ioerrmsg) ((Xg(i,j),i=1,Ip),j=1,Jp)
read(1,*,IOSTAT=stat,IOMSG=ioerrmsg) ((Yg(i,j),i=1,Ip),j=1,Jp)
if(stat>0) stop filename(1)//ioerrmsg
close(1)
print *,'Read airfoil 2D C-type mesh completed!'

end Subroutine Readmesh
10 changes: 5 additions & 5 deletions lib/Libaero2d.F03
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Subroutine Aero2D(libmod,prtl,scptname)
integer(1) solid
#endif

if(libmod=='S'.or.libmod=='I') then
if(libmod=='S'.or.libmod=='I'.or.libmod=='M') then
Call Readpara(libmod,scptname)
else if(libmod=='C') then
Call ConfigparaC2F
Expand All @@ -22,7 +22,7 @@ Subroutine Aero2D(libmod,prtl,scptname)
Call Jacobi
Call Initial
Call Densityinterp
if(libmod=='S'.or.libmod=='I') then
if(libmod=='S'.or.libmod=='I'.or.libmod=='M') then
filename(2)=trim(dir)//'/iteration.txt'
open(unit=2,file=filename(2),status='replace')
write(2,*) 'Residual of RANS equations:'
Expand Down Expand Up @@ -180,7 +180,7 @@ Subroutine Aero2D(libmod,prtl,scptname)
end if
Call Turvis
Call Postprocess(s)
if((libmod=='S'.or.libmod=='I').and.(s==1.or.mod(s,100)==0)) then
if((libmod=='S'.or.libmod=='I'.or.libmod=='M').and.(s==1.or.mod(s,100)==0)) then
Call Saveresults
print *,'Output results completed!'
end if
Expand All @@ -200,7 +200,7 @@ Subroutine Aero2D(libmod,prtl,scptname)
print *,'mass residual:'
print *,rmsm,s
end if
if(libmod=='S'.or.libmod=='I') then
if(libmod=='S'.or.libmod=='I'.or.libmod=='M') then
if(Turmod=='sa') then
write(2,'(5(ES11.4,2X),I5)') rmsu,rmsv,rmst,rmsn,rmsm,s
else if(Turmod=='ke') then
Expand Down Expand Up @@ -258,7 +258,7 @@ Subroutine Aero2D(libmod,prtl,scptname)
Call AverageSol
end if
end if
if(libmod=='S'.or.libmod=='I') then
if(libmod=='S'.or.libmod=='I'.or.libmod=='M') then
close(2)
Call Saveresults
print *,'Save results successfully!'
Expand Down
2 changes: 1 addition & 1 deletion lib/Readpara.f03
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subroutine Readpara(libmod,scptname)
character(*) libmod,scptname
character(128) ioerrmsg
integer stat
if(libmod=='S') then
if(libmod=='S'.or.libmod=='M') then
open(unit=10,file=scptname,status='old')
read(10,*) ch
read(10,*) filename(1)
Expand Down
9 changes: 9 additions & 0 deletions src/console.f03
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Program RANSFOIL
print *,"Options:"
print *,"--stdin interactive mode, read parameters from standard input"
print *,"--script batch mode, read parameters from a configuration file"
print *,"--mesh batch mode, read parameters from a configuration file, then read mesh from an existed plot3d mesh file"
print *,"--version show the current version"
print *,"-h, --help show this message"
else if(argc==1) then
Expand All @@ -32,6 +33,9 @@ Program RANSFOIL
else if(trim(argv(2))=="--script") then
print *,"should input a name of the configuration file."
print *,"usage: ",trim(argv(1))," [options] [configuration file]"
else if(trim(argv(2))=="--mesh") then
print *,"should input a name of the configuration file."
print *,"usage: ",trim(argv(1))," [options] [configuration file]"
else if(trim(argv(2))=="--version") then
print *,"ransfoil version 2.2.16"
print *,"Copyright (c) 2012-2023, Hou Shuo"
Expand All @@ -45,6 +49,7 @@ Program RANSFOIL
print *,"Options:"
print *,"--stdin interactive mode, read parameters from standard input"
print *,"--script batch mode, read parameters from a configuration file"
print *,"--mesh batch mode, read parameters from a configuration file, then read mesh from an existed plot3d mesh file"
print *,"--version show the current version"
print *,"-h, --help show this message"
else
Expand All @@ -57,6 +62,10 @@ Program RANSFOIL
mode='S'
scptname=trim(argv(3))
Call Aero2D(mode,1,scptname)
else if(trim(argv(2))=="--mesh") then
mode='M'
scptname=trim(argv(3))
Call Aero2D(mode,1,scptname)
else
print *,"This option does not exist."
end if
Expand Down

0 comments on commit 0453bee

Please sign in to comment.