1!$Id:$
2      subroutine shap2(s,t,shp,ix,nel)
3
4!      * * F E A P * * A Finite Element Analysis Program
5
6!....  Copyright (c) 1984-2017: Regents of the University of California
7!                               All rights reserved
8
9!-----[--.----+----.----+----.-----------------------------------------]
10!      Purpose: Adds quadratic functions to quadrilaterals for any
11!               non-zero mid-side or central node
12
13!      Inputs:
14!         s,t      - Natural coordinates
15!         ix(*)    - List of nodes attached to element (0 = no node)
16!         nel      - Maximum number of local node on element <= 9
17
18!      Outputs:
19!         shp(3,*) - Shape functions and derivatives w/r natural coords
20!                    shp(1,i) = dN_i/dxi_1
21!                    shp(2,i) = dN_i/dxi_2
22!                    shp(3,i) = N_i
23!-----[--.----+----.----+----.-----------------------------------------]
24
25      implicit  none
26
27      integer   i, j, k, l, nel
28      real*8    s, t, s2, t2
29
30      integer   ix(nel)
31      real*8    shp(3,nel)
32
33      save
34
35      s2 = (1.d0-s*s)*0.5d0
36      t2 = (1.d0-t*t)*0.5d0
37
38      do i = 5,9
39        do j = 1,3
40          shp(j,i) = 0.0d0
41        end do
42      end do
43
44!     Midside nodes (serendipity)
45
46      if(ix(5).ne.0) then
47        shp(1,5) = -s*(1.d0-t)
48        shp(2,5) = -s2
49        shp(3,5) = s2*(1.d0-t)
50      endif
51      if(nel.lt.6) go to 100
52      if(ix(6).ne.0) then
53        shp(1,6) = t2
54        shp(2,6) = -t*(1.d0+s)
55        shp(3,6) = t2*(1.d0+s)
56      endif
57      if(nel.lt.7) go to 100
58      if(ix(7).ne.0) then
59        shp(1,7) = -s*(1.d0+t)
60        shp(2,7) = s2
61        shp(3,7) = s2*(1.d0+t)
62      endif
63      if(nel.lt.8) go to 100
64      if(ix(8).ne.0) then
65        shp(1,8) = -t2
66        shp(2,8) = -t*(1.d0-s)
67        shp(3,8) = t2*(1.d0-s)
68      endif
69
70!     Interior node (lagrangian)
71
72      shp(1,9) = -4.d0*s*t2
73      shp(2,9) = -4.d0*t*s2
74      shp(3,9) =  4.d0*s2*t2
75      if(nel.lt.9 .or. ix(9).eq.0) go to 100
76
77!     Correct edge nodes for interior node (lagrangian)
78
79      do j= 1,3
80        do i = 1,4
81          shp(j,i) = shp(j,i) - 0.25d0*shp(j,9)
82        end do
83        do i = 5,8
84          if(ix(i).ne.0) shp(j,i) = shp(j,i) - 0.5d0*shp(j,9)
85        end do
86      end do
87
88!     Correct corner nodes for presence of midside nodes
89
90100   k = 8
91      do i = 1,4
92        l = i + 4
93        do j = 1,3
94          shp(j,i) = shp(j,i) - 0.5d0*(shp(j,k)+shp(j,l))
95        end do
96        k = l
97      end do
98
99      end
100