PROGRAM BEM8CON C====================================================================== C BOUNDARY ELEMENT METHOD C APPLIED TO C LAPLACE EQUATION (STEADY HEAT EQUATION ) C ELEMENT TYPE: CONSTANT ELEMENT C PROGRAMMED BY EIJI FUKUMORI // SUNY AT BUFFALO // 1984 SPRING C====================================================================== IMPLICIT REAL*8 ( A-H , O-Z ) PARAMETER (MXE=60,MXI=20,INTEPT=4, ND=2) DIMENSION XE(ND),YE(ND), * SAI(INTEPT),W(INTEPT), * G(MXE,MXE),F(MXE,MXE),A(MXE,MXE), * C(MXE), * X(MXE),Y(MXE), * NODEX(MXE,ND), * IELTYPE(MXE),BV(MXE),QN(MXE),H(MXE),RHS(MXE), * XI(MXI),YI(MXI), HI(MXI), CI(MXI) C========================= INITIAL SET-UPS ============================ C C1 = - 1./ ( 8.* DATAN( 1.D0) ) CALL GRULE ( INTEPT, SAI, W ) C========================= READING IN DATA ============================ C CALL INPUT (ND,MXE,MXI,NE,NODEX,IELTYPE,BV,X,Y,NIPT,XI,YI) C ...TYPE(I)=1 ---> TEMPERATURE PRESCRIBED C ...TYPE(I)=2 ---> HEAT FLUX PRESCRIBED C============ BOUNDARY VALUE ARRANGEMENT ============================== C CALL BVARRANG ( MXE, NE, IELTYPE, BV, H, QN ) C=============== FORMATION OF MATRIX G,F AND VECTOR C ============== C CALL MATRIX ( ND,MXE,C1,INTEPT,SAI,W,NE,NODEX,X,Y,XE,YE,G,F,C) C=============== FORMATION OF MATRIX A AND VECTOR RHS ============== C CALL FORM ( MXE, G,F,C,NE,IELTYPE,RHS,H,QN, A ) C===================== READY TO SOLVE A . X = C =================== C CALL SYSTEM ( MXE , NE, A , RHS ) C====================== SORTING SOLUTION ============================== C CALL SORTSOLN ( MXE, NE, IELTYPE, RHS, H, QN ) C================== INTERNAL POINTS ================================= C CALL DOMAIN ( INTEPT,ND,MXE,MXI,C1,NIPT,NE,SAI,W, * XI,YI, NODEX, X,Y, H,QN, HI, CI, XE, YE ) C================= PRINTING RESULTS ================================= CALL ECHOSOLN( MXE,MXI,NE,ND,NIPT,NODEX,X,Y,IELTYPE,H,QN, * XI,YI,HI,CI, C) STOP 'NORMAL TERMINATION' END C C SUBROUTINE SORTSOLN ( MXE, NE, IELTYPE, RHS, H, QN ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION IELTYPE(MXE),RHS(MXE),QN(MXE),H(MXE) DO I = 1 , NE IF ( IELTYPE(I) .EQ. 1 ) QN(I) = RHS(I) IF ( IELTYPE(I) .EQ. 2 ) H(I) = RHS(I) END DO RETURN END C C SUBROUTINE BVARRANG ( MXE, NE, IELTYPE, BV, H, QN ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION IELTYPE(MXE),BV(MXE),QN(MXE),H(MXE) DO I = 1 , NE IF ( IELTYPE(I) .EQ. 1 ) H(I) = BV(I) IF ( IELTYPE(I) .EQ. 2 ) QN(I) = BV(I) END DO RETURN END C C SUBROUTINE FORM ( MXE, G,F,C,NE,IELTYPE,RHS,H,QN, A ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION G(MXE,MXE),F(MXE,MXE),A(MXE,MXE),C(MXE), * IELTYPE(MXE),QN(MXE),H(MXE),RHS(MXE) C DO I = 1 , NE F(I,I) = F(I,I) - C(I) RHS(I) = 0.D0 END DO C DO J = 1 , NE IF ( IELTYPE(J) .EQ. 1 ) THEN DO I = 1 , NE A(I,J) = G(I,J) RHS(I) = RHS(I) + F(I,J) * H(J) END DO END IF IF ( IELTYPE(J) .EQ. 2 ) THEN DO I = 1 , NE A(I,J) = - F(I,J) RHS(I) = RHS(I) - G(I,J) * QN(J) END DO END IF END DO RETURN END C C SUBROUTINE MATRIX (ND,MXE,C1,INTEPT,SAI,W,NE,NODEX,X,Y,XE,YE, * G,F,C) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION G(MXE,MXE),F(MXE,MXE),C(MXE),X(MXE),Y(MXE), * XE(ND),YE(ND),SAI(INTEPT),W(INTEPT) , NODEX(MXE,ND) C---------- CLEAR MATRIX G(I,J) AND F(I,J) AND C(I) DO I = 1 , NE C(I) = 0.D0 DO J = 1 , NE G(I,J) = 0.D0 F(I,J) = 0.D0 END DO END DO C ....... (XP,YP) = COORDINATES OF SOURCE POINT. DO ISOURCE = 1 , NE XP = ( X(NODEX(ISOURCE,1)) + X(NODEX(ISOURCE,2)) ) / 2. YP = ( Y(NODEX(ISOURCE,1)) + Y(NODEX(ISOURCE,2)) ) / 2. DO ICURREN = 1 , NE DO I = 1 , ND XE(I) = X(NODEX(ICURREN,I)) YE(I) = Y(NODEX(ICURREN,I)) END DO C------------------ INTEGRAL ON AN ELEMENT IF ( ISOURCE .EQ. ICURREN ) THEN CALL FINE ( ND, C1, XE, YE, GE, FE ) ELSE CALL INTE ( INTEPT,ND, XP, YP, C1, XE, YE, SAI, W, GE, FE ) END IF C------------------ MATRIX FORMATION G(ISOURCE,ICURREN) = GE F(ISOURCE,ICURREN) = FE C------------------ FREE TERM EVALUATION C(ISOURCE) = C(ISOURCE) + FE END DO END DO RETURN END C C SUBROUTINE INPUT (ND,MXE,MXI,NE,NODEX,IELTYPE,BV,X,Y, * NIPT,XI,YI) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION X(MXE),Y(MXE),IELTYPE(MXE),BV(MXE),NODEX(MXE,ND), * XI(MXI),YI(MXI) OPEN ( 1, FILE='BEM0.DAT', STATUS='OLD' ) READ (1,*) NE DO IEL = 1 , NE READ (1,*) I,(NODEX(I,J),J=1,ND),IELTYPE(I), BV(I) END DO DO I = 1 , NE READ (1,*) NODE, X(NODE), Y(NODE) END DO READ (1,*) NIPT IF ( NIPT .GE. 1 ) THEN DO J = 1 , NIPT READ (1,*) I, XI(I), YI(I) END DO END IF CLOSE (1) RETURN END C C SUBROUTINE FINE ( ND, C1, XE, YE, GE, FE ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION XE(ND), YE(ND) FE = 0.D0 DX = XE(2) - XE(1) DY = YE(2) - YE(1) DS = DSQRT ( DX*DX + DY*DY ) GE = DS*C1 * ( DLOG(DS/2.D0) - 1.D0 ) RETURN END C C SUBROUTINE INTE (INTEPT, ND, XP, YP, C1, XE, YE, SAI,W, GE,FE ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION XE(ND), YE(ND), SAI(INTEPT), W(INTEPT) GE = 0.D0 FE = 0.D0 DX = XE(2) - XE(1) DY = YE(2) - YE(1) DS = DSQRT ( DX*DX + DY*DY ) DETJ = DS/2.D0 XM = ( XE(2) + XE(1) ) /2.D0 YM = ( YE(2) + YE(1) ) /2.D0 C DO IGAUSS = 1 , INTEPT XGAUSS = DX/2.D0*SAI(IGAUSS) + XM YGAUSS = DY/2.D0*SAI(IGAUSS) + YM RX = XGAUSS - XP RY = YGAUSS - YP R = DSQRT ( RX*RX + RY*RY ) C-------- INTEGRATION OF G(R) GE = GE + DLOG(R) * W(IGAUSS) C-------- INTEGRATION OF F(R) FE = FE + ( RX*DY - RY*DX ) / (R*R) * W(IGAUSS) END DO GE = C1 * DETJ * GE FE = -C1 * DETJ /DS * FE RETURN END C C SUBROUTINE DOMAIN ( INTEPT,ND,MXE,MXI,C1,NIPT,NE, * SAI,W,XI,YI,NODEX,X,Y,H,QN,HI, CI, XE, YE ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION NODEX(MXE,ND), SAI(INTEPT), W(INTEPT), * XI(MXI),YI(MXI), X(MXE),Y(MXE),H(MXE),QN(MXE), * XE(ND),YE(ND),HI(MXI), CI(MXI) C IF ( NIPT .EQ. 0 ) RETURN C DO INSIDE = 1 , NIPT XP = XI(INSIDE) YP = YI(INSIDE) SUM = 0.D0 C = 0.D0 DO IEL = 1 , NE DO I = 1 , ND XE(I) = X( NODEX(IEL,I) ) YE(I) = Y( NODEX(IEL,I) ) END DO CALL INTE (INTEPT,ND,XP,YP,C1,XE,YE,SAI,W, G,F ) C = C + F SUM = SUM + F*H(IEL) - G*QN(IEL) END DO CI(INSIDE) = C HI(INSIDE) = SUM END DO RETURN END C C SUBROUTINE ECHOSOLN( MXE,MXI,NE,ND,NIPT,NODEX,X,Y,IELTYPE,H,QN, * XI, YI, HI,CI, C ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION X(MXE), Y(MXE), XI(MXI), YI(MXI), HI(MXI),CI(MXI), * NODEX(MXE,ND), IELTYPE(MXE), H(MXE), QN(MXE), C(MXE) CHARACTER*9 BC OPEN ( 1, FILE='SOLUTION.BEM', STATUS='UNKNOWN' ) WRITE(1,*)' ========== STEADY HEAT TRANSFER ANALYSIS ==========' WRITE(1,*)' ========== BY BEM USING CONSTANT ELEMENT ==========' WRITE(1,*)' == CONVENTIONAL METHOD: [C]{H}+[G]{Q}-[F]{H}={0} ==' WRITE(1,*) WRITE(1,*) WRITE(1,*) C---------INPUT COORDINATES AND B.C. WRITE (1,*) ' = ELEMENT EGDE COORDINATES AND BOUDARY CONDITIONS =' WRITE (1,101) 101 FORMAT (/ 3X,"EL#",7X,"X1",14X,"Y1",14X,"X2",14X,"Y2",14X,"BC"/ * 1X, 79("-") ) DO IEL = 1 , NE X1 = X(NODEX(IEL,1)) Y1 = Y(NODEX(IEL,1)) X2 = X(NODEX(IEL,2)) Y2 = Y(NODEX(IEL,2)) IF ( IELTYPE(IEL) .EQ. 1 ) THEN BC ='DIRICHLET' ELSE BC ='NUEMANN' END IF WRITE (1,100) IEL, X1, Y1, X2, Y2, BC 100 FORMAT ( 1X, I5, 4G16.7,1X, A9 ) END DO C--------- SOLUTIONS ON BOUNADRY WRITE(1,*) WRITE(1,*) WRITE(1,*) WRITE(1,*)' ==== SOLUTIONS AND PRESCRIBED BOUNDARY BALUES ====' WRITE (1,201) 201 FORMAT (/ 3X,"EL#",7X," H",14X,"Qn" ,14X," C" / 1X, 53("-") ) DO IEL = 1 , NE WRITE(1,200) IEL, H(IEL), QN(IEL), C(IEL) 200 FORMAT ( 1X, I5, 3G16.7 ) END DO C--------- INTERNAL VALUES WRITE(1,*) WRITE(1,*) WRITE(1,*) WRITE(1,*) ' === POTENTIAL VALUES AT INTERNAL POINTS ====' WRITE (1,301) 301 FORMAT (/ 5X,"I",7X,"XI",14X,"YI",11X,"CI*HI",14X,"CI"/1X,69("-")) DO I = 1 , NIPT WRITE(1,300) I, XI(I), YI(I), HI(I), CI(I) 300 FORMAT ( 1X, I5, 4G16.7 ) END DO CLOSE (1) RETURN END C C SUBROUTINE GRULE ( N , SAI , W ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION SAI(N) , W(N) IF ( N .LT. 2 ) STOP'N<2' IF ( N .GT. 6 ) STOP'N>6' GO TO ( 99, 20, 30, 40, 50, 60 ) , N 99 STOP 20 SAI(1) = DSQRT(3.D0)/3.D0 W(1) = 1.D0 GO TO 88 30 SAI(1) = DSQRT(15.D0)/5.D0 SAI(2) = 0.D0 W(1) = 5.D0/ 9.D0 W(2) = 8.D0/ 9.D0 GO TO 88 40 SAI(1) = 0.33998104358485D0 SAI(2) = 0.86113631159405D0 W(1) = 0.65214515486254D0 W(2) = 0.34785484513745D0 GO TO 88 50 SAI(1) = 0.90617984593866D0 SAI(2) = 0.53846931010568D0 SAI(3) = 0.D0 W(1) = 0.23692688505619D0 W(2) = 0.47862867049937D0 W(3) = 5.12D0 / 9.D0 GO TO 88 60 SAI(1) = 0.23861918608320D0 SAI(2) = 0.66120938646626D0 SAI(3) = 0.93246951420315D0 W(1) = 0.46791393457269D0 W(2) = 0.36076157304814D0 W(3) = 0.17132449237917D0 88 NN = N / 2 DO 11 I = 1 , NN J = N - I + 1 SAI(J) = - SAI(I) W(J) = W(I) 11 CONTINUE RETURN END C C SUBROUTINE SYSTEM ( MXN , N , A , C ) IMPLICIT REAL*8 ( A-H , O-Z ) DIMENSION A (MXN , MXN ) , C (MXN) N1 = N - 1 DO 40 K = 1, N1 L = K + 1 DO 20 I = L , N P = A (I,K) / A (K,K) DO 30 J = L , N 30 A (I,J) = A (I,J) - P * A ( K , J ) C ( I ) = C ( I) - P * C ( K ) 20 CONTINUE 40 CONTINUE C---- BACK SUBSTITUTION C (N) = C (N) / A (N,N) DO 60 K = 1 , N1 I = N - K L = I + 1 P = C ( I ) DO 50 J = L , N 50 P = P - C (J) * A (I,J) C ( I ) = P / A (I,I) 60 CONTINUE RETURN END