Skip to content

Commit

Permalink
1. Change source scheme in SA model for better stability
Browse files Browse the repository at this point in the history
2. Improve code style in linear solver
3. Update config files and regression cases using new SA scheme
  • Loading branch information
sdhzhs committed Aug 4, 2024
1 parent 8d77963 commit 66a525e
Show file tree
Hide file tree
Showing 9 changed files with 546 additions and 442 deletions.
14 changes: 7 additions & 7 deletions golden/GA_W-1_xyz/Aeroreport.dat
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
Momentum relaxation factor: 0.69999999999999996
Pressure relaxation factor: 0.29999999999999999
Energy relaxation factor: 0.69999999999999996
Turbulence relaxation factor: 0.29999999999999999
Turbulence relaxation factor: 0.69999999999999996
----------------------------------------------
The aerodynamic parameters of this airfoil are:
Reynolds number: 6299464.8818376791
Mach number: 0.14998745754354983
Angle of attack: 8.0199999999999996
Average Y+: 1.5579863636600684
Lift coefficient: 1.3640385649754456
Drag coefficient: 1.6766657671030003E-002
Friction coefficient: 7.2381231995622304E-003
Pitching moment coefficient (1/4 chord): -0.11941174370394404
Pressure center (unit chord): 0.33830851629984465 0.0000000000000000
Average Y+: 1.5606593225907688
Lift coefficient: 1.3901667997163747
Drag coefficient: 2.3945495925011551E-002
Friction coefficient: 7.3117030594817937E-003
Pitching moment coefficient (1/4 chord): -0.12966965234853237
Pressure center (unit chord): 0.34444751086672099 0.0000000000000000
400 changes: 200 additions & 200 deletions golden/GA_W-1_xyz/Wallsol.dat

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions golden/whitcomb_xyz/Aeroreport.dat
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
File name for initialization: whitcomb_xyz/Autosave.dat
Momentum relaxation factor: 0.69999999999999996
Pressure relaxation factor: 0.29999999999999999
Energy relaxation factor: 0.29999999999999999
Turbulence relaxation factor: 0.29999999999999999
Energy relaxation factor: 0.50000000000000000
Turbulence relaxation factor: 0.50000000000000000
----------------------------------------------
The aerodynamic parameters of this airfoil are:
Reynolds number: 21424850.880931877
Mach number: 0.80000001017181221
Angle of attack: 4.0000000000000000
Average Y+: 3.1520771017051521
Lift coefficient: 0.90053174359364629
Drag coefficient: 8.1114867402126034E-002
Friction coefficient: 4.6402805939410154E-003
Pitching moment coefficient (1/4 chord): -0.18142912397183758
Pressure center (unit chord): 0.45068485635312516 0.0000000000000000
Average Y+: 3.1739477363947470
Lift coefficient: 0.93160678736992930
Drag coefficient: 8.4862216940434887E-002
Friction coefficient: 4.7804834372808195E-003
Pitching moment coefficient (1/4 chord): -0.19267957651040574
Pressure center (unit chord): 0.45599798863429603 0.0000000000000000
400 changes: 200 additions & 200 deletions golden/whitcomb_xyz/Wallsol.dat

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions lib/Condiff.f03
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Subroutine Condiff(scalar)
else
aP=aP+2*Ds(i,j)
end if
!if(scalar=='Tn') aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
if(scalar=='Tn'.and.fw1(i,j)>=0) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
if(scalar=='Tk') aP=aP+rho(i,j)*betastar(i,j)*Tw(i,j)*Jg(i,j)*dx*dy
if(scalar=='T'.and.Tmptype=='flux') aP=aP-2*Ds(i,j)
else if(Turmod=='sa'.and.Walltreat=='wf'.or.(Turmod=='sst'.and.Walltreat=='wf').or.Turmod=='ke') then
Expand All @@ -273,8 +273,8 @@ Subroutine Condiff(scalar)
if(Tmptype=='fixed'.and.Tmin>=0) aP=aP+rho(i,j)*ustar(i)*DR(i)/Tplus(i)
else if(scalar=='Tn') then
aP=aP+2*Ds(i,j)
!if(Ymax>10) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/(kapa*d(i,j))**2*Jg(i,j)*dx*dy
!if(Ymax<=10) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
if(Ymax>10.and.fw1(i,j)>=0) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/(kapa*d(i,j))**2*Jg(i,j)*dx*dy
if(Ymax<=10.and.fw1(i,j)>=0) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
else if(Turmod=='sst'.and.scalar=='Tk') then
if(wallfunktype=='genlaw') then
aP=aP+rho(i,j)*ustar(i)**3*Uplus(i)*Jg(i,j)*dx*dy/(Tk(i,j)*Yp(i))
Expand All @@ -301,11 +301,11 @@ Subroutine Condiff(scalar)
!aP=aP+DF
if(scalar=='Tk'.and.Turmod=='ke') aP=aP+rho(i,j)*Te(i,j)*Jg(i,j)*dx*dy/Tk(i,j)
if(scalar=='Te'.and.Turmod=='ke') aP=aP+C2e*rho(i,j)*Te(i,j)*Jg(i,j)*dx*dy/Tk(i,j)
!if(scalar=='Tn'.and.Walltreat=='lr') aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
!if(scalar=='Tn'.and.Walltreat=='wf') then
! if(Ymax>10) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/(kapa*d(i,j))**2*Jg(i,j)*dx*dy
! if(Ymax<=10) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
!end if
if(scalar=='Tn'.and.Walltreat=='lr'.and.fw1(i,j)>=0) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
if(scalar=='Tn'.and.Walltreat=='wf'.and.fw1(i,j)>=0) then
if(Ymax>10) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/(kapa*d(i,j))**2*Jg(i,j)*dx*dy
if(Ymax<=10) aP=aP+rho(i,j)*Cw1*fw1(i,j)*Tn(i,j)/d(i,j)**2*Jg(i,j)*dx*dy
end if
if(scalar=='Tk'.and.Turmod=='sst') aP=aP+rho(i,j)*betastar(i,j)*Tw(i,j)*Jg(i,j)*dx*dy
if(scalar=='Tw'.and.Turmod=='sst') aP=aP+rho(i,j)*beta(i,j)*Tw(i,j)*Jg(i,j)*dx*dy
end if
Expand Down Expand Up @@ -415,10 +415,12 @@ Subroutine Condiff(scalar)
end if
else if(scalar=='Tn') then
b(i,j)=Cb2*rho(i,j)*(Tnx(i,j)**2+Tny(i,j)**2)*Jg(i,j)*dx*dy/sigman+rho(i,j)*Cb1*Sm(i,j)*Tn(i,j)*Jg(i,j)*dx*dy
if(Walltreat=='wf'.and.Ymax>10) then
b(i,j)=b(i,j)-rho(i,j)*Cw1*fw1(i,j)*(Tn(i,j)/(kapa*d(i,j)))**2*Jg(i,j)*dx*dy
else
b(i,j)=b(i,j)-rho(i,j)*Cw1*fw1(i,j)*(Tn(i,j)/d(i,j))**2*Jg(i,j)*dx*dy
if(fw1(i,j)<0) then
if(Walltreat=='wf'.and.Ymax>10) then
b(i,j)=b(i,j)-rho(i,j)*Cw1*fw1(i,j)*(Tn(i,j)/(kapa*d(i,j)))**2*Jg(i,j)*dx*dy
else
b(i,j)=b(i,j)-rho(i,j)*Cw1*fw1(i,j)*(Tn(i,j)/d(i,j))**2*Jg(i,j)*dx*dy
end if
end if
else if(scalar=='Tk'.and.Turmod=='ke') then
if(j==1.and.(i>=Ib1.and.i<=Ib2)) then
Expand Down
124 changes: 113 additions & 11 deletions lib/Linearsolver.f03
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Subroutine sor(aM,b,F,F0,a,Ic,Jc,Ib1,Ib2,scalar)
!$OMP WORKSHARE
Fo=F
!$OMP END WORKSHARE
if(scalar=='Te'.or.scalar=='Tw') then
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
Expand All @@ -28,16 +29,29 @@ Subroutine sor(aM,b,F,F0,a,Ic,Jc,Ib1,Ib2,scalar)
F(i,j)=omega*(a*(aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(Ic+1-i,j)+aM(5,i,j)*F(i,j+1)+b(i,j))/aM(1,i,j)+(1-a)*F0(i,j))+&
(1-omega)*F(i,j)
else
if(scalar=='Te'.or.scalar=='Tw') then
cycle
else
F(i,j)=omega*(a*(aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(i,j)+aM(5,i,j)*F(i,j+1)+b(i,j))/aM(1,i,j)+(1-a)*F0(i,j))+&
(1-omega)*F(i,j)
end if
cycle
end if
end DO
end DO
!$OMP END DO
else
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
if(j>1) then
F(i,j)=omega*(a*(aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(i,j-1)+aM(5,i,j)*F(i,j+1)+b(i,j))/aM(1,i,j)+(1-a)*F0(i,j))+&
(1-omega)*F(i,j)
else if(j==1.and.(i>Ib2.or.i<Ib1)) then
F(i,j)=omega*(a*(aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(Ic+1-i,j)+aM(5,i,j)*F(i,j+1)+b(i,j))/aM(1,i,j)+(1-a)*F0(i,j))+&
(1-omega)*F(i,j)
else
F(i,j)=omega*(a*(aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(i,j)+aM(5,i,j)*F(i,j+1)+b(i,j))/aM(1,i,j)+(1-a)*F0(i,j))+&
(1-omega)*F(i,j)
end if
end DO
end DO
!$OMP END DO
end if
!$OMP SINGLE
rms=0
!$OMP END SINGLE
Expand Down Expand Up @@ -204,6 +218,7 @@ Subroutine SSorpcond(vt,vt0)

cond(1)=(npt==0)
cond(2)=(nt>1.and.tid>0)
if(scalar=='Te'.or.scalar=='Tw') then
!$OMP DO
!!$OMP SINGLE
DO j=1,Jc-1
Expand All @@ -218,7 +233,7 @@ Subroutine SSorpcond(vt,vt0)
!$ end if
else if(j==1.and.i>Ib2) then
vt(i,j)=a*omega*(vt(i,j)+aM(2,i,j)*vt(i-1,j)+aM(4,i,j)*vt(Ic+1-i,j))/aD(i,j)
else if(i>=Ib1.and.(scalar=='Te'.or.scalar=='Tw')) then
else if(i>=Ib1) then
vt(i,j)=omega*vt(i,j)
else
vt(i,j)=a*omega*(vt(i,j)+aM(2,i,j)*vt(i-1,j))/aD(i,j)
Expand All @@ -227,20 +242,53 @@ Subroutine SSorpcond(vt,vt0)
end DO
!!$OMP END SINGLE
!$OMP END DO
else
!$OMP DO
!!$OMP SINGLE
DO j=1,Jc-1
DO i=2,Ic-1
if(j>1) then
!$ cond(3)=(tid<rpt.and.mod(j,npt+1)==1)
!$ cond(4)=(tid>=rpt.and.(npt==1.or.mod(j-rpt*(npt+1),npt)==1))
!$ if(cond(1).or.cond(2).and.(cond(3).or.cond(4))) then
!$ vt(i,j)=a*omega*(vt(i,j)+aM(2,i,j)*vt(i-1,j)+aM(4,i,j)*vt0(i,j-1))/aD(i,j)
!$ else
vt(i,j)=a*omega*(vt(i,j)+aM(2,i,j)*vt(i-1,j)+aM(4,i,j)*vt(i,j-1))/aD(i,j)
!$ end if
else if(j==1.and.i>Ib2) then
vt(i,j)=a*omega*(vt(i,j)+aM(2,i,j)*vt(i-1,j)+aM(4,i,j)*vt(Ic+1-i,j))/aD(i,j)
else
vt(i,j)=a*omega*(vt(i,j)+aM(2,i,j)*vt(i-1,j))/aD(i,j)
end if
end DO
end DO
!!$OMP END SINGLE
!$OMP END DO
end if

!$OMP WORKSHARE
vt=(2-omega)*vt/omega
!$OMP END WORKSHARE

if(scalar=='Te'.or.scalar=='Tw') then
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
if(.not.(j==1.and.i>=Ib1.and.i<=Ib2.and.(scalar=='Te'.or.scalar=='Tw'))) then
if(.not.(j==1.and.i>=Ib1.and.i<=Ib2)) then
vt(i,j)=aD(i,j)*vt(i,j)/a
end if
end DO
end DO
!$OMP END DO
else
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
vt(i,j)=aD(i,j)*vt(i,j)/a
end DO
end DO
!$OMP END DO
end if

!$OMP WORKSHARE
vt(1,:)=omega*vt(1,:)
Expand All @@ -249,6 +297,7 @@ Subroutine SSorpcond(vt,vt0)
!$ vt0=vt
!$OMP END WORKSHARE

if(scalar=='Te'.or.scalar=='Tw') then
!$OMP DO
!!$OMP SINGLE
DO j=Jc-1,1,-1
Expand All @@ -259,7 +308,7 @@ Subroutine SSorpcond(vt,vt0)
!$ else
vt(i,j)=a*omega*(vt(i,j)+aM(3,i,j)*vt(i+1,j)+aM(5,i,j)*vt(i,j+1)+aM(4,i,j)*vt(Ic+1-i,j))/aD(i,j)
!$ end if
else if(j==1.and.i>=Ib1.and.i<=Ib2.and.(scalar=='Te'.or.scalar=='Tw')) then
else if(j==1.and.i>=Ib1.and.i<=Ib2) then
vt(i,j)=omega*vt(i,j)
else
!$ cond(3)=(tid<rpt.and.mod(Jc-j,npt+1)==1)
Expand All @@ -274,6 +323,31 @@ Subroutine SSorpcond(vt,vt0)
end DO
!!$OMP END SINGLE
!$OMP END DO
else
!$OMP DO
!!$OMP SINGLE
DO j=Jc-1,1,-1
DO i=Ic-1,2,-1
if(j==1.and.i<Ib1) then
!$ if(npt==0.or.npt==1) then
!$ vt(i,j)=a*omega*(vt(i,j)+aM(3,i,j)*vt(i+1,j)+aM(5,i,j)*vt0(i,j+1)+aM(4,i,j)*vt(Ic+1-i,j))/aD(i,j)
!$ else
vt(i,j)=a*omega*(vt(i,j)+aM(3,i,j)*vt(i+1,j)+aM(5,i,j)*vt(i,j+1)+aM(4,i,j)*vt(Ic+1-i,j))/aD(i,j)
!$ end if
else
!$ cond(3)=(tid<rpt.and.mod(Jc-j,npt+1)==1)
!$ cond(4)=(tid>=rpt.and.(npt==1.or.mod(Jc-j-rpt*(npt+1),npt)==1))
!$ if(cond(1).or.cond(2).and.(cond(3).or.cond(4))) then
!$ vt(i,j)=a*omega*(vt(i,j)+aM(3,i,j)*vt(i+1,j)+aM(5,i,j)*vt0(i,j+1))/aD(i,j)
!$ else
vt(i,j)=a*omega*(vt(i,j)+aM(3,i,j)*vt(i+1,j)+aM(5,i,j)*vt(i,j+1))/aD(i,j)
!$ end if
end if
end DO
end DO
!!$OMP END SINGLE
!$OMP END DO
end if
end Subroutine SSorpcond

end Subroutine CGSTAB
Expand All @@ -288,19 +362,33 @@ Subroutine Residual(aM,b,F,F0,rms,a,Ic,Jc,Ib1,Ib2,scalar)
!$OMP WORKSHARE
rms=0
!$OMP END WORKSHARE
if(scalar=='Te'.or.scalar=='Tw') then
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
if(j>1) then
rms(i,j)=aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(i,j-1)+aM(5,i,j)*F(i,j+1)+b(i,j)+(1-a)*aM(1,i,j)*F0(i,j)/a-aM(1,i,j)*F(i,j)/a
else if(j==1.and.(i>Ib2.or.i<Ib1)) then
rms(i,j)=aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(Ic+1-i,j)+aM(5,i,j)*F(i,j+1)+b(i,j)+(1-a)*aM(1,i,j)*F0(i,j)/a-aM(1,i,j)*F(i,j)/a
end if
end DO
end DO
!$OMP END DO
else
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
if(j>1) then
rms(i,j)=aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(i,j-1)+aM(5,i,j)*F(i,j+1)+b(i,j)+(1-a)*aM(1,i,j)*F0(i,j)/a-aM(1,i,j)*F(i,j)/a
else if(j==1.and.(i>Ib2.or.i<Ib1)) then
rms(i,j)=aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(Ic+1-i,j)+aM(5,i,j)*F(i,j+1)+b(i,j)+(1-a)*aM(1,i,j)*F0(i,j)/a-aM(1,i,j)*F(i,j)/a
else if(scalar/='Te'.and.scalar/='Tw') then
else
rms(i,j)=aM(3,i,j)*F(i+1,j)+aM(2,i,j)*F(i-1,j)+aM(4,i,j)*F(i,j)+aM(5,i,j)*F(i,j+1)+b(i,j)+(1-a)*aM(1,i,j)*F0(i,j)/a-aM(1,i,j)*F(i,j)/a
end if
end DO
end DO
!$OMP END DO
end if
end Subroutine Residual

Subroutine DILU(aM,aD,Ic,Jc,Ib2)
Expand Down Expand Up @@ -335,19 +423,33 @@ Subroutine Multmatrixvector(aM,u,v,a,Ic,Jc,Ib1,Ib2,scalar)
!$OMP WORKSHARE
v=u
!$OMP END WORKSHARE
if(scalar=='Te'.or.scalar=='Tw') then
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
if(j>1) then
v(i,j)=aM(1,i,j)*u(i,j)/a-aM(3,i,j)*u(i+1,j)-aM(2,i,j)*u(i-1,j)-aM(4,i,j)*u(i,j-1)-aM(5,i,j)*u(i,j+1)
else if(j==1.and.(i>Ib2.or.i<Ib1)) then
v(i,j)=aM(1,i,j)*u(i,j)/a-aM(3,i,j)*u(i+1,j)-aM(2,i,j)*u(i-1,j)-aM(4,i,j)*u(Ic+1-i,j)-aM(5,i,j)*u(i,j+1)
end if
end DO
end DO
!$OMP END DO
else
!$OMP DO
DO j=1,Jc-1
DO i=2,Ic-1
if(j>1) then
v(i,j)=aM(1,i,j)*u(i,j)/a-aM(3,i,j)*u(i+1,j)-aM(2,i,j)*u(i-1,j)-aM(4,i,j)*u(i,j-1)-aM(5,i,j)*u(i,j+1)
else if(j==1.and.(i>Ib2.or.i<Ib1)) then
v(i,j)=aM(1,i,j)*u(i,j)/a-aM(3,i,j)*u(i+1,j)-aM(2,i,j)*u(i-1,j)-aM(4,i,j)*u(Ic+1-i,j)-aM(5,i,j)*u(i,j+1)
else if(scalar/='Te'.and.scalar/='Tw') then
else
v(i,j)=aM(1,i,j)*u(i,j)/a-aM(3,i,j)*u(i+1,j)-aM(2,i,j)*u(i-1,j)-aM(4,i,j)*u(i,j)-aM(5,i,j)*u(i,j+1)
end if
end DO
end DO
!$OMP END DO
end if
end Subroutine Multmatrixvector

Subroutine Sorprecond(aM,aD,b,b0,a,Ic,Jc,Ib1,Ib2,scalar,pretype)
Expand Down
2 changes: 1 addition & 1 deletion ransfoil.configxyz
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Input relaxation factor of pressure:
Input relaxation factor of temperature:
7e-1
Input relaxation factor of turbulence:
3e-1
7e-1
Input dimensionless near wall mesh spacing:
1e-3
Input layers of uniform near wall mesh:
Expand Down
2 changes: 1 addition & 1 deletion test/ransfoil.config.GA_W-1.xyz
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Input relaxation factor of pressure:
Input relaxation factor of temperature:
7e-1
Input relaxation factor of turbulence:
3e-1
7e-1
Input dimensionless near wall mesh spacing:
1e-5
Input layers of uniform near wall mesh:
Expand Down
4 changes: 2 additions & 2 deletions test/ransfoil.config.whitcomb.xyz.2
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Input relaxation factor of velocity:
Input relaxation factor of pressure:
3e-1
Input relaxation factor of temperature:
3e-1
5e-1
Input relaxation factor of turbulence:
3e-1
5e-1
Input dimensionless near wall mesh spacing:
1e-5
Input layers of uniform near wall mesh:
Expand Down

0 comments on commit 66a525e

Please sign in to comment.