-
Notifications
You must be signed in to change notification settings - Fork 0
/
3d-seepage-analysis
1469 lines (1446 loc) · 42.8 KB
/
3d-seepage-analysis
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
! Last change: DV 03 Feb 2015 7:26 pm
! Last edit by: Mohammad Reza Nabizadeh
! Code subrutines source:
! Smith, Ian Moffat, Denwood Vaughan Griffiths, and Lee Margetts.
! Programming the finite element method. John Wiley & Sons, 2013.
PROGRAM p74
!-------------------------------------------------------------------------
! Program 7.4 General two- (plane) or three-dimensional analysis of steady
! seepage.
! With this program the example number 7.4 has been solved in three dimensional space.
!-------------------------------------------------------------------------
IMPLICIT NONE
INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
INTEGER::fixed_freedoms,i,iel,k,loaded_nodes,nci,ndim,nels,neq,nip,nod, &
nn,np_types
REAL(iwp)::det,penalty=1.0e20_iwp,zero=0.0_iwp
CHARACTER(LEN=15)::element
!-----------------------dynamic arrays------------------------------------
INTEGER,ALLOCATABLE::etype(:),g_num(:,:),kdiag(:),node(:),num(:)
REAL(iwp),ALLOCATABLE::coord(:,:),der(:,:),deriv(:,:),disps(:), &
g_coord(:,:),jac(:,:),kay(:,:),kc(:,:),kv(:),kvh(:),loads(:), &
points(:,:),prop(:,:),value(:),weights(:)
!-----------------------input and initialisation--------------------------
OPEN(10,FILE='fe95.dat')
OPEN(11,FILE='fe95.res')
READ(10,*)element,nod,nels,nn,nip,ndim,np_types
neq=nn
ALLOCATE(points(nip,ndim),g_coord(ndim,nn),coord(nod,ndim),etype(nels), &
jac(ndim,ndim),weights(nip),num(nod),g_num(nod,nels),der(ndim,nod), &
deriv(ndim,nod),kc(nod,nod),kay(ndim,ndim),prop(ndim,np_types), &
kdiag(neq),loads(0:neq),disps(0:neq))
READ(10,*)prop
etype=1
IF(np_types>1)READ(10,*)etype
READ(10,*)g_coord
READ(10,*)g_num
IF(ndim==2)CALL mesh(g_coord,g_num,12)
!-----------------------loop the elements to find global arrays sizes-----
kdiag=0
elements_1: DO iel =1,nels
num=g_num(:,iel)
CALL fkdiag(kdiag,num)
END DO elements_1
DO i=2,neq
kdiag(i)=kdiag(i)+kdiag(i-1)
END DO
WRITE(11,'(2(A,I5))') &
" There are",neq," equations and the skyline storage is",kdiag(neq)
ALLOCATE(kv(kdiag(neq)),kvh(kdiag(neq)))
kv=zero
CALL sample(element,points,weights)
!-----------------------global conductivity matrix assembly---------------
elements_2: DO iel=1,nels
kay=zero
DO i=1,ndim
kay(i,i)=prop(i,etype(iel))
END DO
num=g_num(:,iel)
coord=TRANSPOSE(g_coord(:,num))
kc=zero
gauss_pts_1: DO i=1,nip
CALL shape_der(der,points,i)
jac=MATMUL(der,coord)
det=determinant(jac)
CALL invert(jac)
deriv=MATMUL(jac,der)
kc=kc+MATMUL(MATMUL(TRANSPOSE(deriv),kay),deriv)*det*weights(i)
END DO gauss_pts_1
CALL fsparv(kv,kc,num,kdiag)
END DO elements_2
kvh=kv
!-----------------------specify boundary values---------------------------
loads=zero
READ(10,*)loaded_nodes,(k,loads(k),i=1,loaded_nodes)
READ(10,*)fixed_freedoms
IF(fixed_freedoms/=0)THEN
ALLOCATE(node(fixed_freedoms),value(fixed_freedoms))
READ(10,*)(node(i),value(i),i=1,fixed_freedoms)
kv(kdiag(node))=kv(kdiag(node))+penalty
loads(node)=kv(kdiag(node))*value
END IF
!-----------------------equation solution---------------------------------
CALL sparin(kv,kdiag)
CALL spabac(kv,loads,kdiag)
!-----------------------retrieve nodal net flow rates---------------------
CALL linmul_sky(kvh,loads,disps,kdiag)
WRITE(11,'(/A)')" Node Total Head Net Flow"
DO k=1,nn
WRITE(11,'(I5,2E12.4)')k,loads(k),disps(k)
END DO
disps(0)=zero
WRITE(11,'(/A)')" Inflow Outflow"
WRITE(11,'(5X,2E12.4)') &
SUM(disps,MASK=disps>zero),SUM(disps,MASK=disps<zero)
IF(ndim==2.AND.nod==4)THEN
READ(10,*)nci
CALL contour(loads,g_coord,g_num,nci,13)
END IF
STOP
CONTAINS
!-------------------------------------Functions--------------
FUNCTION determinant(jac)RESULT(det)
!
! This function returns the determinant of a 1x1, 2x2 or 3x3
! Jacobian matrix.
!
IMPLICIT NONE
INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
REAL(iwp),INTENT(IN)::jac(:,:)
REAL(iwp)::det
INTEGER::it
it=UBOUND(jac,1)
SELECT CASE(it)
CASE(1)
det=1.0_iwp
CASE(2)
det=jac(1,1)*jac(2,2)-jac(1,2)*jac(2,1)
CASE(3)
det=jac(1,1)*(jac(2,2)*jac(3,3)-jac(3,2)*jac(2,3))
det=det-jac(1,2)*(jac(2,1)*jac(3,3)-jac(3,1)*jac(2,3))
det=det+jac(1,3)*(jac(2,1)*jac(3,2)-jac(3,1)*jac(2,2))
CASE DEFAULT
WRITE(*,*)' wrong dimension for Jacobian matrix'
END SELECT
RETURN
END FUNCTION determinant
!------------------------------------Subrutines-----------------
SUBROUTINE mesh(g_coord,g_num,ips)
!
! This subroutine produces a PostScript output file "*.msh" displaying
! the undeformed finite element mesh.
!
IMPLICIT NONE
INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
REAL(iwp),INTENT(IN)::g_coord(:,:)
INTEGER,INTENT(IN)::g_num(:,:),ips
REAL(iwp)::xmin,xmax,ymin,ymax,width,height,scale=72,sxy,xo,yo,x,y, &
pt5=0.5_iwp,opt5=1.5_iwp,fpt5=5.5_iwp,d8=8.0_iwp,ept5=8.5_iwp, &
d11=11.0_iwp
INTEGER::i,ii,j,jj,nn,nod,nel
OPEN(ips,FILE='fe95.msh')
!
! compute size of mesh
!
nn=UBOUND(g_coord,2)
xmin=g_coord(1,1)
xmax=g_coord(1,1)
ymin=g_coord(2,1)
ymax=g_coord(2,1)
DO i=2,nn
IF(g_coord(1,i)<xmin)xmin=g_coord(1,i)
IF(g_coord(1,i)>xmax)xmax=g_coord(1,i)
IF(g_coord(2,i)<ymin)ymin=g_coord(2,i)
IF(g_coord(2,i)>ymax)ymax=g_coord(2,i)
END DO
width =xmax-xmin
height=ymax-ymin
!
! allow 1.5" margin minimum on each side of figure
!
IF(height.GE.d11/ept5*width)THEN
!
! height governs the scale
!
sxy=scale*d8/height
xo=scale*pt5*(ept5-d8*width/height)
yo=scale*opt5
ELSE
!
! width governs the scale
!
sxy=scale*fpt5/width
xo=scale*opt5
yo=scale*pt5*(d11-fpt5*height/width)
END IF
!
! start PostScript output
!
WRITE(ips,'(a)')'%!PS-Adobe-1.0'
WRITE(ips,'(a)')'%%DocumentFonts: none'
WRITE(ips,'(a)')'%%Pages: 1'
WRITE(ips,'(a)')'%%EndComments'
WRITE(ips,'(a)')'/m {moveto} def'
WRITE(ips,'(a)')'/l {lineto} def'
WRITE(ips,'(a)')'/s {stroke} def'
WRITE(ips,'(a)')'/c {closepath} def'
WRITE(ips,'(a)')'%%EndProlog'
WRITE(ips,'(a)')'%%Page: 0 1'
WRITE(ips,'(a)')'gsave'
WRITE(ips,'(2f9.2,a)') xo, yo, ' translate'
WRITE(ips,'(f9.2,a)') 0.5, ' setlinewidth'
!
! draw the mesh
!
nod=UBOUND(g_num,1)
nel=UBOUND(g_num,2)
IF(nod==9)nod=8
IF(nod==10)nod=9
IF(nod==15)nod=12
DO i=1,nel
ii=g_num(1,i)
IF(ii==0)CYCLE
x=sxy*(g_coord(1,ii)-xmin)
y=sxy*(g_coord(2,ii)-ymin)
WRITE(ips,'(2f9.2,a)')x,y,' m'
DO j=2,nod
jj=g_num(j,i)
x=sxy*(g_coord(1,jj)-xmin)
y=sxy*(g_coord(2,jj)-ymin)
WRITE(ips,'(2f9.2,a)') x, y,' l'
END DO
WRITE(ips,'(a)')'c s'
END DO
!
! close output file
!
WRITE(ips,'(a)')'grestore'
WRITE(ips,'(a)')'showpage'
CLOSE(ips)
!
RETURN
END SUBROUTINE mesh
SUBROUTINE fkdiag(kdiag,g)
!
! This subroutine computes the skyline profile.
!
IMPLICIT NONE
INTEGER,INTENT(IN)::g(:)
INTEGER,INTENT(OUT)::kdiag(:)
INTEGER::idof,i,iwp1,j,im,k
idof=SIZE(g)
DO i=1,idof
iwp1=1
IF(g(i)/=0)THEN
DO j=1,idof
IF(g(j)/=0)THEN
im=g(i)-g(j)+1
IF(im>iwp1)iwp1=im
END IF
END DO
k=g(i)
IF(iwp1>kdiag(k))kdiag(k)=iwp1
END IF
END DO
RETURN
END SUBROUTINE fkdiag
SUBROUTINE sample(element,s,wt)
!
! This subroutine returns the local coordinates and weighting coefficients
! of the integrating points.
!
IMPLICIT NONE
INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
REAL(iwp),INTENT(OUT)::s(:,:)
REAL(iwp),INTENT(OUT),OPTIONAL::wt(:)
CHARACTER(*),INTENT(IN)::element
INTEGER::nip
REAL(iwp)::root3,r15,w(3),v(9),b,c
root3=1.0_iwp/SQRT(3.0_iwp)
r15=0.2_iwp*SQRT(15.0_iwp)
nip=UBOUND(s,1)
w=(/5.0_iwp/9.0_iwp,8.0_iwp/9.0_iwp,5.0_iwp/9.0_iwp/)
v=(/5.0_iwp/9.0_iwp*w,8.0_iwp/9.0_iwp*w,5.0_iwp/9.0_iwp*w/)
SELECT CASE(element)
CASE('line')
SELECT CASE(nip)
CASE(1)
s(1,1)=0.0_iwp
wt(1) =2.0_iwp
CASE(2)
s(1,1)=-0.577350269189626_iwp
s(2,1)= 0.577350269189626_iwp
wt(1) = 1.000000000000000_iwp
wt(2) = 1.000000000000000_iwp
CASE(3)
s(1,1)=-0.774596669241484_iwp
s(2,1)= 0.000000000000000_iwp
s(3,1)= 0.774596669241484_iwp
wt(1) = 0.555555555555556_iwp
wt(2) = 0.888888888888889_iwp
wt(3) = 0.555555555555556_iwp
CASE(4)
s(1,1)=-0.861136311594053_iwp
s(2,1)=-0.339981043584856_iwp
s(3,1)= 0.339981043584856_iwp
s(4,1)= 0.861136311594053_iwp
wt(1) = 0.347854845137454_iwp
wt(2) = 0.652145154862546_iwp
wt(3) = 0.652145154862546_iwp
wt(4) = 0.347854845137454_iwp
CASE(5)
s(1,1)=-0.906179845938664_iwp
s(2,1)=-0.538469310105683_iwp
s(3,1)= 0.000000000000000_iwp
s(4,1)= 0.538469310105683_iwp
s(5,1)= 0.906179845938664_iwp
wt(1) = 0.236926885056189_iwp
wt(2) = 0.478628670499366_iwp
wt(3) = 0.568888888888889_iwp
wt(4) = 0.478628670499366_iwp
wt(5) = 0.236926885056189_iwp
CASE(6)
s(1,1)=-0.932469514203152_iwp
s(2,1)=-0.661209386466265_iwp
s(3,1)=-0.238619186083197_iwp
s(4,1)= 0.238619186083197_iwp
s(5,1)= 0.661209386466265_iwp
s(6,1)= 0.932469514203152_iwp
wt(1) = 0.171324492379170_iwp
wt(2) = 0.360761573048139_iwp
wt(3) = 0.467913934572691_iwp
wt(4) = 0.467913934572691_iwp
wt(5) = 0.360761573048139_iwp
wt(6) = 0.171324492379170_iwp
CASE DEFAULT
WRITE(*,*)"Wrong number of integrating points for a line"
END SELECT
CASE('triangle')
SELECT CASE(nip)
CASE(1)
s(1,1)= 0.333333333333333_iwp
s(1,2)= 0.333333333333333_iwp
wt(1) = 0.500000000000000_iwp
CASE(3)
s(1,1)= 0.500000000000000_iwp
s(1,2)= 0.500000000000000_iwp
s(2,1)= 0.500000000000000_iwp
s(2,2)= 0.000000000000000_iwp
s(3,1)= 0.000000000000000_iwp
s(3,2)= 0.500000000000000_iwp
wt(1:3)=0.333333333333333_iwp
wt=0.5_iwp*wt
CASE(4)
s(1,1)= 0.6_iwp
s(1,2)= 0.2_iwp
s(2,1)= 0.2_iwp
s(2,2)= 0.6_iwp
s(3,1)= 0.2_iwp
s(3,2)= 0.2_iwp
s(4,1)= 0.333333333333333_iwp
s(4,2)= 0.333333333333333_iwp
wt(1:3)= -0.520833333333333_iwp
wt(4)=-0.5625_iwp
wt=0.5_iwp*wt
CASE(6)
s(1,1)= 0.816847572980459_iwp
s(1,2)= 0.091576213509771_iwp
s(2,1)= 0.091576213509771_iwp
s(2,2)= 0.816847572980459_iwp
s(3,1)= 0.091576213509771_iwp
s(3,2)= 0.091576213509771_iwp
s(4,1)= 0.108103018168070_iwp
s(4,2)= 0.445948490915965_iwp
s(5,1)= 0.445948490915965_iwp
s(5,2)= 0.108103018168070_iwp
s(6,1)= 0.445948490915965_iwp
s(6,2)= 0.445948490915965_iwp
wt(1:3)=0.109951743655322_iwp
wt(4:6)=0.223381589678011_iwp
wt=0.5_iwp*wt
CASE(7)
s(1,1)= 0.333333333333333_iwp
s(1,2)= 0.333333333333333_iwp
s(2,1)= 0.797426985353087_iwp
s(2,2)= 0.101286507323456_iwp
s(3,1)= 0.101286507323456_iwp
s(3,2)= 0.797426985353087_iwp
s(4,1)= 0.101286507323456_iwp
s(4,2)= 0.101286507323456_iwp
s(5,1)= 0.470142064105115_iwp
s(5,2)= 0.059715871789770_iwp
s(6,1)= 0.059715871789770_iwp
s(6,2)= 0.470142064105115_iwp
s(7,1)= 0.470142064105115_iwp
s(7,2)= 0.470142064105115_iwp
wt(1) = 0.225000000000000_iwp
wt(2:4)=0.125939180544827_iwp
wt(5:7)=0.132394152788506_iwp
wt=0.5_iwp*wt
CASE(12)
s(1,1)= 0.873821971016996_iwp
s(1,2)= 0.063089014491502_iwp
s(2,1)= 0.063089014491502_iwp
s(2,2)= 0.873821971016996_iwp
s(3,1)= 0.063089014491502_iwp
s(3,2)= 0.063089014491502_iwp
s(4,1)= 0.501426509658179_iwp
s(4,2)= 0.249286745170910_iwp
s(5,1)= 0.249286745170910_iwp
s(5,2)= 0.501426509658179_iwp
s(6,1)= 0.249286745170910_iwp
s(6,2)= 0.249286745170910_iwp
s(7,1) =0.053145049844817_iwp
s(7,2) =0.310352451033784_iwp
s(8,1) =0.310352451033784_iwp
s(8,2) =0.053145049844817_iwp
s(9,1) =0.053145049844817_iwp
s(9,2) =0.636502499121398_iwp
s(10,1)=0.310352451033784_iwp
s(10,2)=0.636502499121398_iwp
s(11,1)=0.636502499121398_iwp
s(11,2)=0.053145049844817_iwp
s(12,1)=0.636502499121398_iwp
s(12,2)=0.310352451033784_iwp
wt(1:3)=0.050844906370207_iwp
wt(4:6)=0.116786275726379_iwp
wt(7:12)=0.082851075618374_iwp
wt=0.5_iwp*wt
CASE(16)
s(1,1)=0.333333333333333_iwp
s(1,2)=0.333333333333333_iwp
s(2,1)=0.658861384496478_iwp
s(2,2)=0.170569307751761_iwp
s(3,1)=0.170569307751761_iwp
s(3,2)=0.658861384496478_iwp
s(4,1)=0.170569307751761_iwp
s(4,2)=0.170569307751761_iwp
s(5,1)=0.898905543365938_iwp
s(5,2)=0.050547228317031_iwp
s(6,1)=0.050547228317031_iwp
s(6,2)=0.898905543365938_iwp
s(7,1)=0.050547228317031_iwp
s(7,2)=0.050547228317031_iwp
s(8,1)=0.081414823414554_iwp
s(8,2)=0.459292588292723_iwp
s(9,1)=0.459292588292723_iwp
s(9,2)=0.081414823414554_iwp
s(10,1)=0.459292588292723_iwp
s(10,2)=0.459292588292723_iwp
s(11,1)=0.008394777409958_iwp
s(11,2)=0.263112829634638_iwp
s(12,1)=0.008394777409958_iwp
s(12,2)=0.728492392955404_iwp
s(13,1)=0.263112829634638_iwp
s(13,2)=0.008394777409958_iwp
s(14,1)=0.263112829634638_iwp
s(14,2)=0.728492392955404_iwp
s(15,1)=0.728492392955404_iwp
s(15,2)=0.008394777409958_iwp
s(16,1)=0.728492392955404_iwp
s(16,2)=0.263112829634638_iwp
wt(1)=0.144315607677787_iwp
wt(2:4)=0.103217370534718_iwp
wt(5:7)=0.032458497623198_iwp
wt(8:10)=0.095091634267284_iwp
wt(11:16)=0.027230314174435_iwp
wt=0.5_iwp*wt
CASE DEFAULT
WRITE(*,*)"wrong number of integrating points for a triangle"
END SELECT
CASE('quadrilateral')
SELECT CASE(nip)
CASE(1)
s(1,1)=0.0_iwp
s(1,2)=0.0_iwp
wt(1)=4.0_iwp
CASE(4)
s(1,1)=-root3
s(1,2)= root3
s(2,1)= root3
s(2,2)= root3
s(3,1)=-root3
s(3,2)=-root3
s(4,1)= root3
s(4,2)=-root3
wt=1.0_iwp
CASE(9)
s(1:7:3,1)=-r15
s(2:8:3,1)=0.0_iwp
s(3:9:3,1)=r15
s(1:3,2) =r15
s(4:6,2) =0.0_iwp
s(7:9,2) =-r15
wt= v
CASE(16)
s(1:13:4,1)=-0.861136311594053_iwp
s(2:14:4,1)=-0.339981043584856_iwp
s(3:15:4,1)= 0.339981043584856_iwp
s(4:16:4,1)= 0.861136311594053_iwp
s(1:4,2) = 0.861136311594053_iwp
s(5:8,2) = 0.339981043584856_iwp
s(9:12,2) =-0.339981043584856_iwp
s(13:16,2) =-0.861136311594053_iwp
wt(1) = 0.121002993285602_iwp
wt(4) = wt(1)
wt(13) = wt(1)
wt(16) = wt(1)
wt(2) = 0.226851851851852_iwp
wt(3) = wt(2)
wt(5) = wt(2)
wt(8) = wt(2)
wt(9) = wt(2)
wt(12) = wt(2)
wt(14) = wt(2)
wt(15) = wt(2)
wt(6) = 0.425293303010694_iwp
wt(7) = wt(6)
wt(10) = wt(6)
wt(11) = wt(6)
CASE(25)
s(1:21:5,1)= 0.906179845938664_iwp
s(2:22:5,1)= 0.538469310105683_iwp
s(3:23:5,1)= 0.0_iwp
s(4:24:5,1)=-0.538469310105683_iwp
s(5:25:5,1)=-0.906179845938664_iwp
s( 1: 5,2) = 0.906179845938664_iwp
s( 6:10,2) = 0.538469310105683_iwp
s(11:15,2) = 0.0_iwp
s(16:20,2) =-0.538469310105683_iwp
s(21:25,2) =-0.906179845938664_iwp
wt(1) =0.056134348862429_iwp
wt(2) =0.113400000000000_iwp
wt(3) =0.134785072387521_iwp
wt(4) =0.113400000000000_iwp
wt(5) =0.056134348862429_iwp
wt(6) =0.113400000000000_iwp
wt(7) =0.229085404223991_iwp
wt(8) =0.272286532550750_iwp
wt(9) =0.229085404223991_iwp
wt(10)=0.113400000000000_iwp
wt(11)=0.134785072387521_iwp
wt(12)=0.272286532550750_iwp
wt(13)=0.323634567901235_iwp
wt(14)=0.272286532550750_iwp
wt(15)=0.134785072387521_iwp
wt(16)=0.113400000000000_iwp
wt(17)=0.229085404223991_iwp
wt(18)=0.272286532550750_iwp
wt(19)=0.229085404223991_iwp
wt(20)=0.113400000000000_iwp
wt(21)=0.056134348862429_iwp
wt(22)=0.113400000000000_iwp
wt(23)=0.134785072387521_iwp
wt(24)=0.113400000000000_iwp
wt(25)=0.056134348862429_iwp
CASE DEFAULT
WRITE(*,*)"wrong number of integrating points for a quadrilateral"
END SELECT
CASE('tetrahedron')
! for tetrahedra weights multiplied by 1/6
SELECT CASE(nip)
CASE(1)
s(1,1)=0.25_iwp
s(1,2)=0.25_iwp
s(1,3)=0.25_iwp
wt(1)=1.0_iwp/6.0_iwp
CASE(4)
s(1,1)=0.58541020_iwp
s(1,2)=0.13819660_iwp
s(1,3)=s(1,2)
s(2,2)=s(1,1)
s(2,3)=s(1,2)
s(2,1)=s(1,2)
s(3,3)=s(1,1)
s(3,1)=s(1,2)
s(3,2)=s(1,2)
s(4,1)=s(1,2)
s(4,2)=s(1,2)
s(4,3)=s(1,2)
wt(1:4)=0.25_iwp/6.0_iwp
CASE(5)
s(1,1)=0.25_iwp
s(1,2)=0.25_iwp
s(1,3)=0.25_iwp
s(2,1)=0.5_iwp
s(2,2)=1.0_iwp/6.0_iwp
s(2,3)=s(2,2)
s(3,2)=0.5_iwp
s(3,3)=1.0_iwp/6.0_iwp
s(3,1)=s(3,3)
s(4,3)=0.5_iwp
s(4,1)=1.0_iwp/6.0_iwp
s(4,2)=s(4,1)
s(5,1)=1.0_iwp/6.0_iwp
s(5,2)=s(5,1)
s(5,3)=s(5,1)
wt(1)=-0.8_iwp
wt(2)=9.0_iwp/20.0_iwp
wt(3:5)=wt(2)
wt=wt/6.0_iwp
CASE DEFAULT
WRITE(*,*)"wrong number of integrating points for a tetrahedron"
END SELECT
CASE('hexahedron')
SELECT CASE(nip)
CASE(1)
s(1,1:3)=0.0_iwp
wt(1)=8.0_iwp
CASE(8)
s(1,1)= root3
s(1,2)= root3
s(1,3)= root3
s(2,1)= root3
s(2,2)= root3
s(2,3)=-root3
s(3,1)= root3
s(3,2)=-root3
s(3,3)= root3
s(4,1)= root3
s(4,2)=-root3
s(4,3)=-root3
s(5,1)=-root3
s(5,2)= root3
s(5,3)= root3
s(6,1)=-root3
s(6,2)=-root3
s(6,3)= root3
s(7,1)=-root3
s(7,2)= root3
s(7,3)=-root3
s(8,1)=-root3
s(8,2)=-root3
s(8,3)=-root3
wt=1.0_iwp
CASE(14)
b=0.795822426_iwp
c=0.758786911_iwp
wt(1:6)=0.886426593_iwp
wt(7:14)=0.335180055_iwp
s(1,1)=-b
s(2,1)=b
s(3,2)=-b
s(4,2)=b
s(5,3)=-b
s(6,3)=b
s(7:,:)=c
s(7,1)=-c
s(7,2)=-c
s(7,3)=-c
s(8,2)=-c
s(8,3)=-c
s(9,1)=-c
s(9,3)=-c
s(10,3)=-c
s(11,1)=-c
s(11,2)=-c
s(12,2)=-c
s(13,1)=-c
CASE(15)
b=1.0_iwp
c =0.674199862_iwp
wt(1) =1.564444444_iwp
wt(2:7) =0.355555556_iwp
wt(8:15)=0.537777778_iwp
s(2,1)=-b
s(3,1)=b
s(4,2)=-b
s(5,2)=b
s(6,3)=-b
s(7,3)=b
s(8:,:)=c
s(8,1)=-c
s(8,2)=-c
s(8,3)=-c
s(9,2)=-c
s(9,3)=-c
s(10,1)=-c
s(10,3)=-c
s(11,3)=-c
s(12,1)=-c
s(12,2)=-c
s(13,2)=-c
s(14,1)=-c
CASE(27)
wt=(/5.0_iwp/9.0_iwp*v,8.0_iwp/9.0_iwp*v,5.0_iwp/9.0_iwp*v/)
s(1:7:3,1)=-r15
s(2:8:3,1)=0.0_iwp
s(3:9:3,1)=r15
s(1:3,3)=r15
s(4:6,3)=0.0_iwp
s(7:9,3)=-r15
s(1:9,2)=-r15
s(10:16:3,1)=-r15
s(11:17:3,1)=0.0_iwp
s(12:18:3,1)=r15
s(10:12,3)=r15
s(13:15,3)=0.0_iwp
s(16:18,3)=-r15
s(10:18,2)=0.0_iwp
s(19:25:3,1)=-r15
s(20:26:3,1)=0.0_iwp
s(21:27:3,1)=r15
s(19:21,3)= r15
s(22:24,3)=0.0_iwp
s(25:27,3)=-r15
s(19:27,2)= r15
CASE DEFAULT
WRITE(*,*)"wrong number of integrating points for a hexahedron"
END SELECT
CASE DEFAULT
WRITE(*,*)"not a valid element type"
END SELECT
RETURN
END SUBROUTINE sample
SUBROUTINE shape_der(der,points,i)
!
! This subroutine produces derivatives of shape functions withe respect
! to local coordinates.
!
IMPLICIT NONE
INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
INTEGER,INTENT(IN)::i
REAL(iwp),INTENT(IN)::points(:,:)
REAL(iwp),INTENT(OUT)::der(:,:)
REAL(iwp)::eta,xi,zeta,xi0,eta0,zeta0,etam,etap,xim,xip,c1,c2,c3
REAL(iwp)::t1,t2,t3,t4,t5,t6,t7,t8,t9,x2p1,x2m1,e2p1,e2m1,zetam,zetap
REAL,PARAMETER::zero=0.0_iwp,pt125=0.125_iwp,pt25=0.25_iwp,pt5=0.5_iwp, &
pt75=0.75_iwp,one=1.0_iwp,two=2.0_iwp,d3=3.0_iwp,d4=4.0_iwp,d5=5.0_iwp,&
d6=6.0_iwp,d8=8.0_iwp,d9=9.0_iwp,d10=10.0_iwp,d11=11.0_iwp, &
d12=12.0_iwp,d16=16.0_iwp,d18=18.0_iwp,d27=27.0_iwp,d32=32.0_iwp, &
d36=36.0_iwp,d54=54.0_iwp,d64=64.0_iwp,d128=128.0_iwp
INTEGER::xii(20),etai(20),zetai(20),l,ndim,nod
ndim=UBOUND(der,1)
nod= UBOUND(der,2)
SELECT CASE(ndim)
CASE(1) ! one dimensional elements
xi=points(i,1)
SELECT CASE(nod)
CASE(2)
der(1,1)=-pt5
der(1,2)= pt5
CASE(3)
t1=-one-xi
t2=-xi
t3=one-xi
der(1,1)=-(t3+t2)/two
der(1,2)=(t3+t1)
der(1,3)=-(t2+t1)/two
CASE(4)
t1=-one-xi
t2=-one/d3-xi
t3=one/d3-xi
t4=one-xi
der(1,1)=-(t3*t4+t2*t4+t2*t3)*d9/d16
der(1,2)=(t3*t4+t1*t4+t1*t3)*d27/d16
der(1,3)=-(t2*t4+t1*t4+t1*t2)*d27/d16
der(1,4)=(t2*t3+t1*t3+t1*t2)*d9/d16
CASE(5)
t1=-one-xi
t2=-pt5-xi
t3=-xi
t4=pt5-xi
t5=one-xi
der(1,1)=-(t3*t4*t5+t2*t4*t5+t2*t3*t5+t2*t3*t4)*two/d3
der(1,2)=(t3*t4*t5+t1*t4*t5+t1*t3*t5+t1*t3*t4)*d8/d3
der(1,3)=-(t2*t4*t5+t1*t4*t5+t1*t2*t5+t1*t2*t4)*d4
der(1,4)=(t2*t3*t5+t1*t3*t5+t1*t2*t5+t1*t2*t3)*d8/d3
der(1,5)=-(t2*t3*t4+t1*t3*t4+t1*t2*t4+t1*t2*t3)*two/d3
CASE DEFAULT
WRITE(*,*)"wrong number of nodes in shape_der"
END SELECT
CASE(2) ! two dimensional elements
xi=points(i,1)
eta=points(i,2)
c1=xi
c2=eta
c3=one-c1-c2
etam=pt25*(one-eta)
etap=pt25*(one+eta)
xim= pt25*(one-xi)
xip= pt25*(one+xi)
x2p1=two*xi+one
x2m1=two*xi-one
e2p1=two*eta+one
e2m1=two*eta-one
SELECT CASE(nod)
CASE(3)
der(1,1)=one
der(1,3)=zero
der(1,2)=-one
der(2,1)=zero
der(2,3)=one
der(2,2)=-one
CASE(6)
der(1,1)=d4*c1-one
der(1,6)=d4*c2
der(1,5)=zero
der(1,4)=-d4*c2
der(1,3)=-(d4*c3-one)
der(1,2)=d4*(c3-c1)
der(2,1)=zero
der(2,6)=d4*c1
der(2,5)=d4*c2-one
der(2,4)=d4*(c3-c2)
der(2,3)=-(d4*c3-one)
der(2,2)=-d4*c1
CASE(10)
der(1,1)=(d27*c1**2-d18*c1+two)/two
der(1,9)=(d9*(d6*c1-one)*c2)/two
der(1,8)=(d9*(d3*c2-one)*c2)/two
der(1,7)=zero
der(1,6)=-(d9*(d3*c2-one)*c2)/two
der(1,5)= (d9*(d6*c1+d6*c2-d5)*c2)/two
der(1,4)=-(d27*c1**2+d54*c1*c2-d36*c1+d27*c2**2-d36*c2+d11)/two
der(1,3)= (d9*(d9*c1**2+d12*c1*c2-d10*c1+d3*c2**2-d5*c2+two))/two
der(1,2)=-(d9*(d9*c1**2+d6*c1*c2-d8*c1-c2+one))/two
der(1,10)=-d27*(((c2-one)+c1)+c1)*c2
der(2,1)=zero
der(2,9)= (d9*(d3*c1-one)*c1)/two
der(2,8)= (d9*(d6*c2-one)*c1)/two
der(2,7)=(d27*c2**2-d18*c2+two)/two
der(2,6)=-(d9*((c1+c2-one)*(d6*c2-one)+(d3*c2-one)*c2))/two
der(2,5)= (d9*(d3*c1**2+d12*c1*c2-d5*c1+d9*c2**2-d10*c2+two))/two
der(2,4)=-(d27*c1**2+d54*c1*c2-d36*c1+d27*c2**2-d36*c2+d11)/two
der(2,3)= (d9*(d6*c1+d6*c2-d5)*c1)/two
der(2,2)=-(d9*(d3*c1-one)*c1)/two
der(2,10)=-d27*(((c2-one)+c1)+c2)*c1
CASE(15)
t1=c1-pt25
t2=c1-pt5
t3=c1-pt75
t4=c2-pt25
t5=c2-pt5
t6=c2-pt75
t7=c3-pt25
t8=c3-pt5
t9=c3-pt75
der(1,1)=d32/d3*(t2*t3*(t1+c1)+c1*t1*(t3+t2))
der(1,12)=d128/d3*c2*(t2*(t1+c1)+c1*t1)
der(1,11)=d64*c2*t4*(t1+c1)
der(1,10)=d128/d3*c2*t4*t5
der(1,9)=zero
der(1,8)=-d128/d3*c2*t4*t5
der(1,7)=-d64*c2*t4*(t7+c3)
der(1,6)=-d128/d3*c2*(t8*(t7+c3)+c3*t7)
der(1,5)=-d32/d3*(t8*t9*(t7+c3)+c3*t7*(t8+t9))
der(1,4)=d128/d3*(c3*t7*t8-c1*(t8*(t7+c3)+c3*t7))
der(1,3)=d64*(c3*t7*(t1+c1)-c1*t1*(t7+c3))
der(1,2)=d128/d3*(c3*(t2*(t1+c1)+c1*t1)-c1*t1*t2)
der(1,13)=d128*c2*(c3*(t1+c1)-c1*t1)
der(1,15)=d128*c2*t4*(c3-c1)
der(1,14)=d128*c2*(c3*t7-c1*(t7+c3))
der(2,1)=zero
der(2,12)=d128/d3*c1*t1*t2
der(2,11)=d64*c1*t1*(t4+c2)
der(2,10)=d128/d3*c1*(t5*(t4+c2)+c2*t4)
der(2,9)=d32/d3*(t5*t6*(t4+c2)+c2*t4*(t6+t5))
der(2,8)=d128/d3*((c3*(t5*(t4+c2)+c2*t4))-c2*t4*t5)
der(2,7)=d64*(c3*t7*(t4+c2)-c2*t4*(t7+c3))
der(2,6)=d128/d3*(c3*t7*t8-c2*(t8*(t7+c3)+c3*t7))
der(2,5)=-d32/d3*(t8*t9*(t7+c3)+c3*t7*(t8+t9))
der(2,4)=-d128/d3*c1*(t8*(t7+c3)+c3*t7)
der(2,3)=-d64*c1*t1*(t7+c3)
der(2,2)=-d128/d3*c1*t1*t2
der(2,13)=d128*c1*t1*(c3-c2)
der(2,15)=d128*c1*(c3*(t4+c2)-c2*t4)
der(2,14)=d128*c1*(c3*t7-c2*(c3+t7))
CASE (4)
der(1,1)=-etam
der(1,2)=-etap
der(1,3)=etap
der(1,4)=etam
der(2,1)=-xim
der(2,2)=xim
der(2,3)=xip
der(2,4)=-xip
CASE(8)
der(1,1)=etam*(two*xi+eta)
der(1,2)=-d8*etam*etap
der(1,3)=etap*(two*xi-eta)
der(1,4)=-d4*etap*xi
der(1,5)=etap*(two*xi+eta)
der(1,6)=d8*etap*etam
der(1,7)=etam*(two*xi-eta)
der(1,8)=-d4*etam*xi
der(2,1)=xim*(xi+two*eta)
der(2,2)=-d4*xim*eta
der(2,3)=xim*(two*eta-xi)
der(2,4)=d8*xim*xip
der(2,5)=xip*(xi+two*eta)
der(2,6)=-d4*xip*eta
der(2,7)=xip*(two*eta-xi)
der(2,8)=-d8*xim*xip
CASE(9)
etam=eta-one
etap=eta+one
xim=xi-one
xip=xi+one
der(1,1)=pt25*x2m1*eta*etam
der(1,2)=-pt5*x2m1*etap*etam
der(1,3)=pt25*x2m1*eta*etap
der(1,4)=-xi*eta*etap
der(1,5)=pt25*x2p1*eta*etap
der(1,6)=-pt5*x2p1*etap*etam
der(1,7)=pt25*x2p1*eta*etam
der(1,8)=-xi*eta*etam
der(1,9)=two*xi*etap*etam
der(2,1)=pt25*xi*xim*e2m1
der(2,2)=-xi*xim*eta
der(2,3)=pt25*xi*xim*e2p1
der(2,4)=-pt5*xip*xim*e2p1
der(2,5)=pt25*xi*xip*e2p1
der(2,6)=-xi*xip*eta
der(2,7)=pt25*xi*xip*e2m1
der(2,8)=-pt5*xip*xim*e2m1
der(2,9)=two*xip*xim*eta
CASE DEFAULT
WRITE(*,*)"wrong number of nodes in shape_der"
END SELECT
CASE(3) ! d3 dimensional elements
xi=points(i,1)
eta=points(i,2)
zeta=points(i,3)
etam=one-eta
xim=one-xi
zetam=one-zeta
etap=eta+one
xip=xi+one
zetap=zeta+one
SELECT CASE(nod)
CASE(4)
der(1:3,1:4)=zero
der(1,1)=one
der(2,2)=one
der(3,3)=one
der(1,4)=-one
der(2,4)=-one
der(3,4)=-one
CASE(8)
der(1,1)=-pt125*etam*zetam
der(1,2)=-pt125*etam*zetap
der(1,3)= pt125*etam*zetap
der(1,4)= pt125*etam*zetam
der(1,5)=-pt125*etap*zetam
der(1,6)=-pt125*etap*zetap
der(1,7)= pt125*etap*zetap
der(1,8)= pt125*etap*zetam
der(2,1)=-pt125*xim*zetam
der(2,2)=-pt125*xim*zetap
der(2,3)=-pt125*xip*zetap
der(2,4)=-pt125*xip*zetam
der(2,5)= pt125*xim*zetam
der(2,6)= pt125*xim*zetap
der(2,7)= pt125*xip*zetap
der(2,8)= pt125*xip*zetam
der(3,1)=-pt125*xim*etam
der(3,2)= pt125*xim*etam
der(3,3)= pt125*xip*etam
der(3,4)=-pt125*xip*etam
der(3,5)=-pt125*xim*etap
der(3,6)= pt125*xim*etap
der(3,7)= pt125*xip*etap
der(3,8)=-pt125*xip*etap
CASE(14) ! type 6 element
der(1,1)= (two*xi*eta+two*xi*zeta+d4*xi+eta*zeta+eta+zeta)* &
(eta-one)*(zeta-one)/d8
der(1,2)=-(two*xi*eta-two*xi*zeta+d4*xi-eta*zeta+eta-zeta)* &
(eta-one)*(zeta+one)/d8
der(1,3)=-(two*xi*eta-two*xi*zeta+d4*xi+eta*zeta-eta+zeta)* &
(eta-one)*(zeta+one)/d8
der(1,4)= (two*xi*eta+two*xi*zeta+d4*xi-eta*zeta-eta-zeta)* &
(eta-one)*(zeta-one)/d8
der(1,5)= -(eta-one)*(zeta+one)*(zeta-one)*xi
der(1,6)=-(eta+one)*(eta-one)*(zeta+one)*(zeta-one)/two
der(1,7)= (eta+one)*(eta-one)*(zeta+one)*xi
der(1,8)= (eta+one)*(eta-one)*(zeta+one)*(zeta-one)/two
der(1,9)= -(eta+one)*(eta-one)*(zeta-one)*xi
der(1,10)= (two*xi*eta-two*xi*zeta-d4*xi+eta*zeta+eta-zeta)* &
(eta+one)*(zeta-one)/d8
der(1,11)=-(two*xi*eta+two*xi*zeta-d4*xi-eta*zeta+eta+zeta)* &
(eta+one)*(zeta+one)/d8
der(1,12)=-(two*xi*eta+two*xi*zeta-d4*xi+eta*zeta-eta-zeta)* &
(eta+one)*(zeta+one)/d8
der(1,13)= (two*xi*eta-two*xi*zeta-d4*xi-eta*zeta-eta+zeta)* &
(eta+one)*(zeta-one)/d8
der(1,14)= (eta+one)*(zeta+one)*(zeta-one)*xi
der(2,1)= (two*xi*eta+xi*zeta+xi+two*eta*zeta+d4*eta+zeta)* &
(xi-one)*(zeta-one)/d8
der(2,2)=-(two*xi*eta-xi*zeta+xi-two*eta*zeta+d4*eta-zeta)* &
(xi-one)*(zeta+one)/d8
der(2,3)=-(two*xi*eta-xi*zeta+xi+two*eta*zeta-d4*eta+zeta)* &
(xi+one)*(zeta+one)/d8
der(2,4)= (two*xi*eta+xi*zeta+xi-two*eta*zeta-d4*eta-zeta)* &
(xi+one)*(zeta-one)/d8
der(2,5)=-(xi+one)*(xi-one)*(zeta+one)*(zeta-one)/two
der(2,6)= -(xi-one)*(zeta+one)*(zeta-one)*eta
der(2,7)= (xi+one)*(xi-one)*(zeta+one)*eta
der(2,8)= (xi+one)*(zeta+one)*(zeta-one)*eta
der(2,9)= -(xi+one)*(xi-one)*(zeta-one)*eta
der(2,10)= (two*xi*eta-xi*zeta-xi+two*eta*zeta+d4*eta-zeta)* &
(xi-one)*(zeta-one)/d8
der(2,11)=-(two*xi*eta+xi*zeta-xi-two*eta*zeta+d4*eta+zeta)* &
(xi-one)*(zeta+one)/d8
der(2,12)=-(two*xi*eta+xi*zeta-xi+two*eta*zeta-d4*eta-zeta)* &
(xi+one)*(zeta+one)/d8
der(2,13)= (two*xi*eta-xi*zeta-xi-two*eta*zeta-d4*eta+zeta)* &
(xi+one)*(zeta-one)/d8
der(2,14)= (xi+one)*(xi-one)*(zeta+one)*(zeta-one)/two