-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCS-FEM.f90
440 lines (363 loc) · 13.4 KB
/
CS-FEM.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
SUBROUTINE UEL (RHS, AMATRX, SVARS, ENERGY, NDOFEL, NRHS, NSVARS,PROPS, NPROPS, COORDS, MCRD, NNODE, U, DU, V, A, JTYPE, TIME,DTIME, KSTEP, KINC, JELEM, PARAMS, NDLOAD, JDLTYP, ADLMAG,PREDEF, NPREDF, LFLAGS, MLVARX, DDLMAG, MDLOAD, PNEWDT, JPROPS,NJPRO, PERIOD)
INCLUDE 'ABA_PARAM.INC'
DIMENSION RHS(MLVARX,*), AMATRX(NDOFEL,NDOFEL), PROPS(2),SVARS(*), ENERGY(8), COORDS(MCRD, NNODE), U(NDOFEL),DU(MLVARX,*), V(NDOFEL), A(NDOFEL), TIME(2), PARAMS(*), JDLTYP(MDLOAD,*), ADLMAG(MDLOAD,*), DDLMAG(MDLOAD,*),PREDEF(2, NPREDF, NNODE), LFLAGS(*), JPROPS(*)
PARAMETER (NEG=-1.D0, ZERO=0.D0, HALF=0.5D0,ONE=1.D0, TWO=2.D0,PI=4.D0*DATAN(1.D0))
REAL(8) BX,BY,D(3,3),X(4),Y(4),XX(4),YY(4),XY(9,2),SC_CONNECT(4,4),SHAPE_FUNC_VALUE(9,4),B(12,8),BT(8,12),POINTS(4),SCXY(2,4),NX(4),NY(4),EDGESC(4),K(8,8),ANGLE(4),ENSNA(7,4),BSC(12,2),EDGE(4),PI,AREA1,AREA2,COSA1,COSA2,COSB1,COSB2,COSC1,COSC2,COSD1,COSD2,SSD(4)
REAL(8) BX1,BX2,BX3,BX4,BY1,BY2,BY3,BY4,AKMAT(2,2),B1SD(3,8),B2SD(3,8), B3SD(3,8), B4SD(3,8)
INTEGER P1,P2,RR,CC
!!!CSFEM Q4 =>> 4 SUBCELL
NNODE=NDOFEL/2
NSC=4
!REAL(8)
THICK=PROPS(1)
E=PROPS(2)
PR=PROPS(3)
CALL INITIALIZE(D,3,3)
CALL INITIALIZE(XY,9,2)
CALL INITIALIZE(K,NDOFEL,NDOFEL)
call INITIALIZE(ENSNA,7,4)
call INITIALIZE(B1SD,3,8)
call INITIALIZE(B2SD,3,8)
call INITIALIZE(B3SD,3,8)
call INITIALIZE(B4SD,3,8)
!!! CONSTITUTIVE MATRIX ===>PLANE STRESS
THICK=PROPS(1)
E=PROPS(2)
EMU=PROPS(3)
D(1,1)=E*(1.0-EMU)/((1.0+EMU)*(1.0-2*EMU))
D(1,2)=E*EMU/((1.0+EMU)*(1.0-2*EMU))
D(1,3)=0.0
D(2,1)=E*EMU/((1.0+EMU)*(1.0-2*EMU))
D(2,2)=E*(1.0-EMU)/((1.0+EMU)*(1.0-2*EMU))
D(2,3)=0.0
D(3,1)=0.0
D(3,2)=0.0
D(3,3)=E*(1.0-2*EMU)/(2*(1.0+EMU)*(1.0-2*EMU))
!WRITE (*,*) "D DONE"
!!! GETTING COORDINATES OF THE Q4 ==>>> X=(X1,X2,X3,X4) Y=(Y1,Y2,Y3,Y4)
X=COORDS(1,:)
Y=COORDS(2,:)
!WRITE (*,*) "X AND Y"
!WRITE (*,*) X,Y
!!! STORING POINTS OF P1....P9
!WRITE (*,*) "COORDINATES COLLECTED"
XY(1,:)=(/X(1),Y(1)/)
XY(2,:)=(/X(2),Y(2)/)
XY(3,:)=(/X(3),Y(3)/)
XY(4,:)=(/X(4),Y(4)/)
XY(5,:)=(/HALF*(X(1)+X(2)),HALF*(Y(1)+Y(2))/)
XY(6,:)=(/HALF*(X(3)+X(2)),HALF*(Y(3)+Y(2))/)
XY(7,:)=(/HALF*(X(3)+X(4)),HALF*(Y(3)+Y(4))/)
XY(8,:)=(/HALF*(X(4)+X(1)),HALF*(Y(1)+Y(4))/)
XY(9,:)=(/HALF*HALF*(X(4)+X(1)+X(3)+X(2)),HALF*HALF*(Y(1)+Y(4)+Y(3)+Y(2))/)
!WRITE (*,*) "XY"
!WRITE (*,*) XY
!WRITE (*,*) "COORDINATES COLLECTED DONE"
!!SUBCELL POINT CONNECTIVITY
CALL INITIALIZE(SC_CONNECT,4,4)
SC_CONNECT(1,:)=(/1,5,9,8/)
SC_CONNECT(2,:)=(/5,2,6,9/)
SC_CONNECT(3,:)=(/9,6,3,7/)
SC_CONNECT(4,:)=(/8,9,7,4/)
!WRITE (*,*) "SC_CONNECT COLLECTED"
!!!SHAPE FUNCTION VALUES==>>(N1,N2,N3,N4) AT 9 POINTS
CALL INITIALIZE(SHAPE_FUNC_VALUE,9,4)
SHAPE_FUNC_VALUE(1,:)=(/1,0,0,0/)
SHAPE_FUNC_VALUE(2,:)=(/0,1,0,0/)
SHAPE_FUNC_VALUE(3,:)=(/0,0,1,0/)
SHAPE_FUNC_VALUE(4,:)=(/0,0,0,1/)
SHAPE_FUNC_VALUE(5,:)=(/0.5,0.5,0.0,0.0/)
SHAPE_FUNC_VALUE(6,:)=(/0.0,0.5,0.5,0.0/)
SHAPE_FUNC_VALUE(7,:)=(/0.0,0.0,0.5,0.5/)
SHAPE_FUNC_VALUE(8,:)=(/0.5,0.0,0.0,0.5/)
SHAPE_FUNC_VALUE(9,:)=(/HALF*HALF,HALF*HALF,HALF*HALF,HALF*HALF/)
!!!! ITERATING OVER EACH SUBCELL
!!! MAIN
CALL INITIALIZE(B,3,8)
CALL INITIALIZE(BT,8,3)
DO S=1,NSC
!WRITE (*,*) "SUBCELL" , S
!! DERIV OF SHAPE FUNCTION ===>>>> {N1X,N1Y}.....
POINTS=SC_CONNECT(S,:)
CALL INITIALIZE(SCXY,2,4)
!WRITE (*,*) POINTS
!!!! COORDINATES OF NSCth SUBCELL IN SCXY===>>>(X1,Y1)....
!WRITE (*,*) "******SPPP"
DO SP=1,4
!WRITE (*,*) POINTS(SP)
SCXY(1,SP)=XY(POINTS(SP),1)
!WRITE (*,*) XY(POINTS(SP),1)
SCXY(2,SP)=XY(POINTS(SP),2)
!WRITE (*,*) XY(POINTS(SP),2)
END DO
!WRITE (*,*) "SC XY CREATED"
!WRITE (*,*) SCXY
CALL GET_AREA(SCXY(1,:),SCXY(2,:),AREASC,EDGESC)
!WRITE (*,*) "AREA COLLECTED" , S , AREASC
!CALL GET_EDGE(EDGESC,SCXY(1,:),SCXY(2,:))
!WRITE (*,*) "EDGE", S , EDGESC
CALL GET_OUTWARD_NORMAL(NX,NY,SCXY(1,:),SCXY(2,:),EDGESC)
SSD(S)=AREASC
!!!! DERIVATIVE OF EACH SHAPE FUNCTION
CALL INITIALIZE(DN,4,2)
!!! SUMMATION OF NX*SHAPE*LE/AREA USING BX AND BY
BX1=((SHAPE_FUNC_VALUE(POINTS(1),1)+SHAPE_FUNC_VALUE(POINTS(2),1))*(HALF)*NX(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),1)+SHAPE_FUNC_VALUE(POINTS(3),1))*(HALF)*NX(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),1)+SHAPE_FUNC_VALUE(POINTS(4),1))*(HALF)*NX(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),1)+SHAPE_FUNC_VALUE(POINTS(1),1))*(HALF)*NX(4)*EDGESC(4))*(1/AREASC)
BY1=((SHAPE_FUNC_VALUE(POINTS(1),1)+SHAPE_FUNC_VALUE(POINTS(2),1))*(HALF)*NY(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),1)+SHAPE_FUNC_VALUE(POINTS(3),1))*(HALF)*NY(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),1)+SHAPE_FUNC_VALUE(POINTS(4),1))*(HALF)*NY(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),1)+SHAPE_FUNC_VALUE(POINTS(1),1))*(HALF)*NY(4)*EDGESC(4))*(1/AREASC)
BX2=((SHAPE_FUNC_VALUE(POINTS(1),2)+SHAPE_FUNC_VALUE(POINTS(2),2))*(HALF)*NX(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),2)+SHAPE_FUNC_VALUE(POINTS(3),2))*(HALF)*NX(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),2)+SHAPE_FUNC_VALUE(POINTS(4),2))*(HALF)*NX(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),2)+SHAPE_FUNC_VALUE(POINTS(1),2))*(HALF)*NX(4)*EDGESC(4))*(1/AREASC)
BY2=((SHAPE_FUNC_VALUE(POINTS(1),2)+SHAPE_FUNC_VALUE(POINTS(2),2))*(HALF)*NY(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),2)+SHAPE_FUNC_VALUE(POINTS(3),2))*(HALF)*NY(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),2)+SHAPE_FUNC_VALUE(POINTS(4),2))*(HALF)*NY(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),2)+SHAPE_FUNC_VALUE(POINTS(1),2))*(HALF)*NY(4)*EDGESC(4))*(1/AREASC)
BX3=((SHAPE_FUNC_VALUE(POINTS(1),3)+SHAPE_FUNC_VALUE(POINTS(2),3))*(HALF)*NX(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),3)+SHAPE_FUNC_VALUE(POINTS(3),3))*(HALF)*NX(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),3)+SHAPE_FUNC_VALUE(POINTS(4),3))*(HALF)*NX(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),3)+SHAPE_FUNC_VALUE(POINTS(1),3))*(HALF)*NX(4)*EDGESC(4))*(1/AREASC)
BY3=((SHAPE_FUNC_VALUE(POINTS(1),3)+SHAPE_FUNC_VALUE(POINTS(2),3))*(HALF)*NY(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),3)+SHAPE_FUNC_VALUE(POINTS(3),3))*(HALF)*NY(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),3)+SHAPE_FUNC_VALUE(POINTS(4),3))*(HALF)*NY(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),3)+SHAPE_FUNC_VALUE(POINTS(1),3))*(HALF)*NY(4)*EDGESC(4))*(1/AREASC)
BX4=((SHAPE_FUNC_VALUE(POINTS(1),4)+SHAPE_FUNC_VALUE(POINTS(2),4))*(HALF)*NX(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),4)+SHAPE_FUNC_VALUE(POINTS(3),4))*(HALF)*NX(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),4)+SHAPE_FUNC_VALUE(POINTS(4),4))*(HALF)*NX(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),4)+SHAPE_FUNC_VALUE(POINTS(1),4))*(HALF)*NX(4)*EDGESC(4))*(1/AREASC)
BY4=((SHAPE_FUNC_VALUE(POINTS(1),4)+SHAPE_FUNC_VALUE(POINTS(2),4))*(HALF)*NY(1)*EDGESC(1)+(SHAPE_FUNC_VALUE(POINTS(2),4)+SHAPE_FUNC_VALUE(POINTS(3),4))*(HALF)*NY(2)*EDGESC(2)+(SHAPE_FUNC_VALUE(POINTS(3),4)+SHAPE_FUNC_VALUE(POINTS(4),4))*(HALF)*NY(3)*EDGESC(3)+(SHAPE_FUNC_VALUE(POINTS(4),4)+SHAPE_FUNC_VALUE(POINTS(1),4))*(HALF)*NY(4)*EDGESC(4))*(1/AREASC)
CALL INITIALIZE(BSC,12,2)
BSC(1,1)=BX1
BSC(4,1)=BX2
BSC(7,1)=BX3
BSC(10,1)=BX4
BSC(2,2)=BY1
BSC(5,2)=BY2
BSC(8,2)=BY3
BSC(11,2)=BY4
BSC(3,1)=BY1
BSC(3,2)=BX1
BSC(6,1)=BY2
BSC(6,2)=BX2
BSC(9,1)=BY3
BSC(9,2)=BX3
BSC(12,1)=BY4
BSC(12,2)=BX4
RR=2*S-1
CC=2*S
B(:,RR:CC)=BSC
!!!! PUTTING VALUES OF BX AND BY OF THE "SUBCELL" IN THE B MATRIX OF THE "ELEMENT"
END DO
!!! MAIN END
call INITIALIZE(BT,8,12)
BT(1:2,1:3)=TRANSPOSE(B(1:3,1:2))
BT(1:2,4:6)=TRANSPOSE(B(1:3,3:4))
BT(1:2,7:9)=TRANSPOSE(B(1:3,5:6))
BT(1:2,10:12)=TRANSPOSE(B(1:3,7:8))
BT(3:4,1:3)=TRANSPOSE(B(4:6,1:2))
BT(3:4,4:6)=TRANSPOSE(B(4:6,3:4))
BT(3:4,7:9)=TRANSPOSE(B(4:6,5:6))
BT(3:4,10:12)=TRANSPOSE(B(4:6,7:8))
BT(5:6,1:3)=TRANSPOSE(B(7:9,1:2))
BT(5:6,4:6)=TRANSPOSE(B(7:9,3:4))
BT(5:6,7:9)=TRANSPOSE(B(7:9,5:6))
BT(5:6,10:12)=TRANSPOSE(B(7:9,7:8))
BT(7:8,1:3)=TRANSPOSE(B(10:12,1:2))
BT(7:8,4:6)=TRANSPOSE(B(10:12,3:4))
BT(7:8,7:9)=TRANSPOSE(B(10:12,5:6))
BT(7:8,10:12)=TRANSPOSE(B(10:12,7:8))
IF (JELEM.EQ.94)THEN
WRITE (*,*) "B OF ELEMENT :", JELEM
WRITE (*,*) B
WRITE (*,*) "BT OF ELEMENT :", JELEM
WRITE (*,*) BT
END IF
do ii = 1, 4
do jj = 1, 4
do m = 1, 4
call get_kmat(BT((2*ii-1):2*ii,(3*m-2):3*m),D,B((3*jj-2):3*jj,(2*m-1):2*m),2,3,3,2,SSD(m),AKMAT)
AMATRX((2*ii-1):2*ii,(2*jj-1):2*jj)=AMATRX((2*ii-1):2*ii,(2*jj-1):2*jj)+AKMAT(1:2,1:2)
enddo
enddo
enddo
IF (JELEM.EQ.94)THEN
WRITE (*,*) "amatrx :", JELEM
WRITE (*,*) AMATRX
do i = 1,4
B1SD(1:3,(2*i-1):2*i)=B((3*i-2):3*i,1:2)
enddo
IF (JELEM.EQ.94) THEN
!WRITE (*,*) JELEM ,"BI MAT" , AMATRX
WRITE (*,*) "B1SD",B1SD
END IF
do i = 1,3
do j = 1,8
ENSNA(i,1)=B1SD(i,j)*U(j)
enddo
enddo
do i = 1,3
do j = 1,3
ENSNA(i+3,1)=D(i,j)*ENSNA(j,1)
enddo
enddo
do i = 1,4
B2SD(1:3,(2*i-1):2*i)=B((3*i-2):3*i,3:4)
enddo
do i = 1,3
do j = 1,8
ENSNA(i,2)=B2SD(i,j)*U(j)
enddo
enddo
do i = 1,3
do j = 1,3
ENSNA(i+3,2)=D(i,j)*ENSNA(j,2)
enddo
enddo
do i = 1,4
B3SD(1:3,(2*i-1):2*i)=B((3*i-2):3*i,5:6)
enddo
do i = 1,3
do j = 1,8
ENSNA(i,3)=B3SD(i,j)*U(j)
enddo
enddo
do i = 1,3
do j = 1,3
ENSNA(i+3,3)=D(i,j)*ENSNA(j,3)
enddo
enddo
do i = 1,4
B4SD(1:3,(2*i-1):2*i)=B((3*i-2):3*i,7:8)
enddo
do i = 1,3
do j = 1,8
ENSNA(i,4)=B4SD(i,j)*U(j)
enddo
enddo
do i = 1,3
do j = 1,3
ENSNA(i+3,4)=D(i,j)*ENSNA(j,4)
enddo
enddo
do i = 1,4
ENSNA(7,i)=SSD(i)
SVARS(i)=SSD(i)
enddo
do k1 = 1, NDOFEL
do KRHS = 1, NRHS
RHS(K1,KRHS) = ZERO
enddo
enddo
END IF
do I=1,8
do J=1,8
RHS(I,1)=RHS(I,1)-AMATRX(I,J)*U(J)*THICK
enddo
enddo
!!!!! Output the saved results
!WRITE (*,*) JELEM
!DO I=1,4
!DO J=1,7
!WRITE (*,*) E_S_A(J,I)
!END DO
!END DO
RETURN
END
SUBROUTINE INITIALIZE(MATRIX,ROW,COLUMN)
INCLUDE 'ABA_PARAM.INC'
REAL(8) MATRIX(ROW,COLUMN)
DO RR =1,ROW
DO JJ =1,COLUMN
MATRIX(RR,JJ)=0.D0
END DO
END DO
END
SUBROUTINE GET_AREA(XX,YY,AREASC,EDGESC)
INCLUDE 'ABA_PARAM.INC'
!!! AREA OF 4 SUBCELL
REAL(8) AREASC,ANGLE(4),XX(4),YY(4),EDGESC(4),PI,AREA1,AREA2
PI = 4*ATAN(1.d0)
!WRITE (*,*) "VALUE OF PI" ,PI
!WRITE (*,*) "IN AREA SUB"
CALL GET_EDGE(XX,YY,EDGESC)
!WRITE (*,*) "IN EDGE SUB"
CALL GET_ANGLE(XX,YY,EDGESC,ANGLE)
!WRITE (*,*) "ANGLE ===>>>" , ANGLE
IF ((ANGLE(1).GE.PI) .OR. (ANGLE(3).GE.PI)) THEN
AREA1=(0.5D0)*(XX(1)*YY(2)+XX(2)*YY(3)+XX(3)*YY(1)-XX(1)*YY(3)-XX(2)*YY(1)-XX(3)*YY(2))
AREA2=(0.5D0)*(XX(1)*YY(3)+XX(3)*YY(4)+XX(4)*YY(1)-XX(1)*YY(4)-XX(3)*YY(1)-XX(4)*YY(3))
AREASC=ABS(AREA1)+ABS(AREA2)
ELSE IF ((ANGLE(2).GE.PI) .OR. (ANGLE(4).GE.PI)) THEN
AREA1=0.5*(XX(1)*YY(2)+XX(2)*YY(4)+XX(4)*YY(1)-XX(1)*YY(4)-XX(2)*YY(1)-XX(4)*YY(2))
AREA2=0.5*(XX(2)*YY(3)+XX(3)*YY(4)+XX(4)*YY(2)-XX(2)*YY(4)-XX(3)*YY(2)-XX(4)*YY(3))
AREASC=ABS(AREA1)+ABS(AREA2)
ELSE IF ((ANGLE(1).LT.PI) .AND. (ANGLE(3).LT.PI) .AND. (ANGLE(2).LT.PI) .AND. (ANGLE(4).LT.PI) .AND. (D1.LE.D2) ) THEN
AREA1=(0.5D0)*(XX(1)*YY(2)+XX(2)*YY(3)+XX(3)*YY(1)-XX(1)*YY(3)-XX(2)*YY(1)-XX(3)*YY(2))
AREA2=(0.5D0)*(XX(1)*YY(3)+XX(3)*YY(4)+XX(4)*YY(1)-XX(1)*YY(4)-XX(3)*YY(1)-XX(4)*YY(3))
AREASC=ABS(AREA1)+ABS(AREA2)
ELSE IF ( (ANGLE(1).LT.PI) .AND. (ANGLE(3).LT.PI) .AND. (ANGLE(2).LT.PI) .AND. (ANGLE(4).LT.PI) .AND. (D1.GT.D2) )THEN
AREA1=0.5*(XX(1)*YY(2)+XX(2)*YY(4)+XX(4)*YY(1)-XX(1)*YY(4)-XX(2)*YY(1)-XX(4)*YY(2))
AREA2=0.5*(XX(2)*YY(3)+XX(3)*YY(4)+XX(4)*YY(2)-XX(2)*YY(4)-XX(3)*YY(2)-XX(4)*YY(3))
AREASC=ABS(AREA1)+ABS(AREA2)
END IF
END
SUBROUTINE GET_ANGLE(XX,YY,EDGESC,ANGLE)
INCLUDE 'ABA_PARAM.INC'
REAL(8) ANGLE(4),EDGESC(4),D1,D2,XX(4),YY(4),EDGE(4),COSA1,COSA2,COSB1,COSB2,COSC1,COSC2,COSD1,COSD2
!CALL GET_EDGE(EDGE,XX,YY)
EDGE=EDGESC
D1=SQRT((XX(1)-XX(3))**2+(YY(1)-YY(3))**2)
D2=SQRT((XX(4)-XX(2))**2+(YY(4)-YY(2))**2)
COSA1=(EDGE(4)*EDGE(4)+D2*D2-EDGE(3)*EDGE(3))/(2.0*EDGE(4)*D2)
COSA2=(EDGE(1)**2+D2**2-EDGE(2)**2)/(2.0*EDGE(1)*D2)
!WRITE (*,*) COSA1 ,COSA2
COSB1=(EDGE(1)**2+D1**2-EDGE(4)**2)/(2.0*EDGE(1)*D1)
COSB2=(EDGE(2)**2+D1**2-EDGE(3)**2)/(2.0*EDGE(2)*D1)
!WRITE (*,*) COSB1 ,COSB2
COSC1=(EDGE(2)**2+D2**2-EDGE(1)**2)/(2.0*EDGE(2)*D2)
COSC2=(EDGE(3)**2+D2**2-EDGE(4)**2)/(2.0*EDGE(3)*D2)
!WRITE (*,*) COSC1 ,COSC2
COSD1=(EDGE(3)**2+D1**2-EDGE(2)**2)/(2.0*EDGE(3)*D1)
COSD2=(EDGE(4)**2+D1**2-EDGE(1)**2)/(2.0*EDGE(4)*D1)
!WRITE (*,*) COSD1 ,COSD2
ANGLE(1)=ACOS(COSA1)+ACOS(COSA2)
!WRITE (*,*) , ANGLE(1)
ANGLE(2)=ACOS(COSB1)+ACOS(COSB2)
!WRITE (*,*) , ANGLE(2)
ANGLE(3)=ACOS(COSC1)+ACOS(COSC2)
!WRITE (*,*) , ANGLE(3)
ANGLE(4)=ACOS(COSD1)+ACOS(COSD2)
!WRITE (*,*) , ANGLE(4)
END
!! SUBROUTINE TO CALCULATE EDGE FOR 4 SIDES
SUBROUTINE GET_EDGE(XX,YY,EDGE)
INCLUDE 'ABA_PARAM.INC'
REAL*8 EDGE(4),XX(4),YY(4)
!WRITE (*,*) "INSIDE EDGE SUB"
!WRITE (*,*) XX , YY
DO L=1,4
IF (L.NE.4) THEN
EDGE(L)=SQRT((XX(L)-XX(L+1))**2+(YY(L)-YY(L+1))**2)
!WRITE (*,*) EDGE(L)
ELSE
EDGE(L)=SQRT((XX(L)-XX(1))**2+(YY(L)-YY(1))**2)
!WRITE (*,*) EDGE(L)
END IF
END DO
END
!!!OUTWARD LORMAL ====(N1X,N1Y)
SUBROUTINE GET_OUTWARD_NORMAL(NX,NY,XX,YY,EDGE)
INCLUDE 'ABA_PARAM.INC'
REAL(8) NX(4),NY(4),XX(4),YY(4),EDGE(4)
!WRITE (*,*) "INSIDE NXNY =="
DO P=1,4
IF (P.NE.4) THEN
NX(P)=(0.5)*(YY(P+1)-YY(P))/(EDGE(P)*(0.5D0))
NY(P)=-(0.5)*(XX(P+1)-XX(P))/(EDGE(P)*(0.5D0))
!WRITE (*,*) NX,NY
ELSE
NX(P)=(0.5)*(YY(1)-YY(P))/(EDGE(P)*(0.5D0))
NY(P)=-(0.5)*(XX(1)-XX(P))/(EDGE(P)*(0.5))
!WRITE (*,*) NX,NY
END IF
END DO
END
SUBROUTINE get_kmat(A,B,C,k,l,m,n,area,D)
INCLUDE 'ABA_PARAM.INC'
REAL(8) A(k,l),B(l,m),C(m,n)
REAL(8) D(k,n),E(k,m)
REAL(8) area
call INITIALIZE(D,k,n)
call INITIALIZE(E,k,m)
E=MATMUL(A,B)
D=MATMUL(E,C)
DO i=1,k
DO j=1,n
D(i,j)=D(i,j)*area
ENDDO
ENDDO
return
end