|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
这是先前需要自己编程序作网格时写的代码。它主要是将物理空间的面(2D)或体(3D)转换到参数空间后进行超限插值计算,得到中间各个点的坐标值,其中U,V,W表示网格点的X,Y,Z数组。
实际应用时,必须先生成网格的边界。该程序的理论依据好像是Soni(?)提出的,具体的公式嘛,哈哈,忘了,能查到的(就是太麻烦-_-!)。
SUBROUTINE SONITFI ( U,V,IM,JM,IERR )
IMPLICIT NONE
INTEGER IM,JM,I,II,J,JJ,IERR
REAL ETA,XSI,PLM,SX,SY,S1,S2,SM1,SM2,SL1,SL2
REAL,DIMENSION(IM,JM):: U,V,ALM,BLM,CLM,DLM
REAL,DIMENSION(IM):: GLM1,GLM2
REAL,DIMENSION(JM):: HL1M,HL2M
IERR = 0
SM1 = 0.0
SM2 = 0.0
SL1 = 0.0
SL2 = 0.0
DO I = 2, IM
SX = U(I,1) - U(I-1,1)
SY = V(I,1) - V(I-1,1)
SM1 = SQRT( SX * SX + SY * SY ) + SM1
SX = U(I,JM) - U(I-1,JM)
SY = V(I,JM) - V(I-1,JM)
SM2 = SQRT( SX * SX + SY * SY ) + SM2
ENDDO
DO J = 2, JM
SX = U(1,J) - U(1,J-1)
SY = V(1,J) - V(1,J-1)
SL1 = SQRT( SX * SX + SY * SY ) + SL1
SX = U(IM,J) - U(IM,J-1)
SY = V(IM,J) - V(IM,J-1)
SL2 = SQRT( SX * SX + SY * SY ) + SL2
ENDDO
IF ( SM1 <= 0.0 .OR. SM2 <= 0.0 .OR. &
SL1 <= 0.0 .OR. SL2 <= 0.0 ) GOTO 999
DO I = 1, IM
S1 = 0.0
S2 = 0.0
DO II = 2, I
SX = U(II,1) - U(II-1,1)
SY = V(II,1) - V(II-1,1)
S1 = SQRT( SX * SX + SY * SY ) + S1
SX = U(II,JM) - U(II-1,JM)
SY = V(II,JM) - V(II-1,JM)
S2 = SQRT( SX * SX + SY * SY ) + S2
ENDDO
GLM1(I) = S1 / SM1
GLM2(I) = S2 / SM2
ENDDO
DO J = 1, JM
S1 = 0.0
S2 = 0.0
DO JJ = 2, J
SX = U(1,JJ) - U(1,JJ-1)
SY = V(1,JJ) - V(1,JJ-1)
S1 = SQRT( SX * SX + SY * SY ) + S1
SX = U(IM,JJ) - U(IM,JJ-1)
SY = V(IM,JJ) - V(IM,JJ-1)
S2 = SQRT( SX * SX + SY * SY ) + S2
ENDDO
HL1M(J) = S1 / SL1
HL2M(J) = S2 / SL2
ENDDO
DO I = 1, IM
DO J = 1, JM
PLM = 1 - ( GLM2(I) - GLM1(I) ) * ( HL2M(J) - HL1M(J) )
IF ( PLM == 0.0 ) GOTO 999
XSI = ( GLM1(I) + HL1M(J) * ( GLM2(I) - GLM1(I) ) ) / PLM
ETA = ( HL1M(J) + GLM1(I) * ( HL2M(J) - HL1M(J) ) ) / PLM
ALM(I,J) = 1.0 - ETA
BLM(I,J) = ETA
CLM(I,J) = 1.0 - XSI
DLM(I,J) = XSI
ENDDO
ENDDO
DO I = 1, IM
DO J = 1, JM
U(I,J) = ALM(I,J) * U(I,1) + BLM(I,J) * U(I,JM) + &
CLM(I,J) * U(1,J) + DLM(I,J) * U(IM,J) - &
ALM(I,J) * CLM(I,J) * U(1,1) - &
BLM(I,J) * CLM(I,J) * U(1,JM) - &
ALM(I,J) * DLM(I,J) * U(IM,1) - &
BLM(I,J) * DLM(I,J) * U(IM,JM)
V(I,J) = ALM(I,J) * V(I,1) + BLM(I,J) * V(I,JM) + &
CLM(I,J) * V(1,J) + DLM(I,J) * V(IM,J) - &
ALM(I,J) * CLM(I,J) * V(1,1) - &
BLM(I,J) * CLM(I,J) * V(1,JM) - &
ALM(I,J) * DLM(I,J) * V(IM,1) - &
BLM(I,J) * DLM(I,J) * V(IM,JM)
ENDDO
ENDDO
GOTO 1000
999 IERR = 1
WRITE(*,*)'ZERO VALUE ERROR!'
1000 RETURN
END SUBROUTINE SONITFI
SUBROUTINE SONITFI2 ( U,V,W,IM,JM,IERR )
IMPLICIT NONE
INTEGER IM,JM,I,II,J,JJ,IERR
REAL ETA,XSI,PLM,SX,SY,SZ,S1,S2,SM1,SM2,SL1,SL2
REAL,DIMENSION(IM,JM):: U,V,W,ALM,BLM,CLM,DLM
REAL,DIMENSION(IM):: GLM1,GLM2
REAL,DIMENSION(JM):: HL1M,HL2M
IERR = 0
SM1 = 0.0
SM2 = 0.0
SL1 = 0.0
SL2 = 0.0
DO I = 2, IM
SX = U(I,1) - U(I-1,1)
SY = V(I,1) - V(I-1,1)
SZ = W(I,1) - W(I-1,1)
SM1 = SQRT( SX * SX + SY * SY + SZ * SZ ) + SM1
SX = U(I,JM) - U(I-1,JM)
SY = V(I,JM) - V(I-1,JM)
SZ = W(I,JM) - W(I-1,JM)
SM2 = SQRT( SX * SX + SY * SY + SZ * SZ ) + SM2
ENDDO
DO J = 2, JM
SX = U(1,J) - U(1,J-1)
SY = V(1,J) - V(1,J-1)
SZ = W(1,J) - W(1,J-1)
SL1 = SQRT( SX * SX + SY * SY + SZ * SZ ) + SL1
SX = U(IM,J) - U(IM,J-1)
SY = V(IM,J) - V(IM,J-1)
SZ = W(IM,J) - W(IM,J-1)
SL2 = SQRT( SX * SX + SY * SY + SZ * SZ ) + SL2
ENDDO
IF ( SM1 <= 0.0 .OR. SM2 <= 0.0 .OR. &
SL1 <= 0.0 .OR. SL2 <= 0.0 ) GOTO 999
DO I = 1, IM
S1 = 0.0
S2 = 0.0
DO II = 2, I
SX = U(II,1) - U(II-1,1)
SY = V(II,1) - V(II-1,1)
SZ = W(II,1) - W(II-1,1)
S1 = SQRT( SX * SX + SY * SY + SZ * SZ ) + S1
SX = U(II,JM) - U(II-1,JM)
SY = V(II,JM) - V(II-1,JM)
SZ = W(II,JM) - W(II-1,JM)
S2 = SQRT( SX * SX + SY * SY + SZ * SZ ) + S2
ENDDO
GLM1(I) = S1 / SM1
GLM2(I) = S2 / SM2
ENDDO
DO J = 1, JM
S1 = 0.0
S2 = 0.0
DO JJ = 2, J
SX = U(1,JJ) - U(1,JJ-1)
SY = V(1,JJ) - V(1,JJ-1)
SZ = W(1,JJ) - W(1,JJ-1)
S1 = SQRT( SX * SX + SY * SY + SZ * SZ ) + S1
SX = U(IM,JJ) - U(IM,JJ-1)
SY = V(IM,JJ) - V(IM,JJ-1)
SZ = W(IM,JJ) - W(IM,JJ-1)
S2 = SQRT( SX * SX + SY * SY + SZ * SZ ) + S2
ENDDO
HL1M(J) = S1 / SL1
HL2M(J) = S2 / SL2
ENDDO
DO I = 1, IM
DO J = 1, JM
PLM = 1 - ( GLM2(I) - GLM1(I) ) * ( HL2M(J) - HL1M(J) )
IF ( PLM == 0.0 ) GOTO 999
XSI = ( GLM1(I) + HL1M(J) * ( GLM2(I) - GLM1(I) ) ) / PLM
ETA = ( HL1M(J) + GLM1(I) * ( HL2M(J) - HL1M(J) ) ) / PLM
ALM(I,J) = 1.0 - ETA
BLM(I,J) = ETA
CLM(I,J) = 1.0 - XSI
DLM(I,J) = XSI
ENDDO
ENDDO
DO I = 1, IM
DO J = 1, JM
U(I,J) = ALM(I,J) * U(I,1) + BLM(I,J) * U(I,JM) + &
CLM(I,J) * U(1,J) + DLM(I,J) * U(IM,J) - &
ALM(I,J) * CLM(I,J) * U(1,1) - &
BLM(I,J) * CLM(I,J) * U(1,JM) - &
ALM(I,J) * DLM(I,J) * U(IM,1) - &
BLM(I,J) * DLM(I,J) * U(IM,JM)
V(I,J) = ALM(I,J) * V(I,1) + BLM(I,J) * V(I,JM) + &
CLM(I,J) * V(1,J) + DLM(I,J) * V(IM,J) - &
ALM(I,J) * CLM(I,J) * V(1,1) - &
BLM(I,J) * CLM(I,J) * V(1,JM) - &
ALM(I,J) * DLM(I,J) * V(IM,1) - &
BLM(I,J) * DLM(I,J) * V(IM,JM)
W(I,J) = ALM(I,J) * W(I,1) + BLM(I,J) * W(I,JM) + &
CLM(I,J) * W(1,J) + DLM(I,J) * W(IM,J) - &
ALM(I,J) * CLM(I,J) * W(1,1) - &
BLM(I,J) * CLM(I,J) * W(1,JM) - &
ALM(I,J) * DLM(I,J) * W(IM,1) - &
BLM(I,J) * DLM(I,J) * W(IM,JM)
ENDDO
ENDDO
GOTO 1000
999 IERR = 1
WRITE(*,*)'ZERO VALUE ERROR!'
1000 RETURN
END SUBROUTINE SONITFI2
|
|