1!$Id:$
2      subroutine shp1d(s,xl,shp,ndm,nel,xjac)
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: Compute shape functions, natural derivatives, and
11!              jacobian for 3-D line at natural coordinate s.
12!              Linear (2 nodes) or quadratic (3 nodes) element.
13
14!     Inputs:
15!       s         : natural coordinate
16!       xl(3,nel) : nodal global coordinates
17!       ndm       : coordinate dimension of mesh
18!       nel       : number of nodes of element
19
20!     Outputs:
21!       shp(2,nel): shape functions and derivatives at s
22!                   shp(1,1 to nel): derivatives of shape functions
23!                   shp(2,1 to nel): shape functions
24!       xjac      : jacobian at s
25!-----[--.----+----.----+----.-----------------------------------------]
26
27      implicit  none
28
29      integer   ndm,nel,i
30      real*8    s,xjac
31      real*8    xl(ndm,nel),shp(2,nel)
32
33      save
34
35!     Linear element
36
37      if(nel.eq.2) then
38
39        xjac = 0.0d0
40        do i = 1,ndm
41          xjac = xjac + (xl(i,2) - xl(i,1))**2
42        end do ! i
43        xjac = sqrt(xjac)
44
45        shp(2,1) = (1.d0 - s)*0.5d0
46        shp(2,2) = (1.d0 + s)*0.5d0
47
48        shp(1,1) = -1.d0/xjac
49        shp(1,2) =  1.d0/xjac
50
51!     Quadratic element
52
53      elseif(nel.eq.3) then
54
55!       Shape function natural derivatives
56
57        shp(1,1) =  s - 0.5d0
58        shp(1,2) =  s + 0.5d0
59        shp(1,3) = -s*2.d0
60
61        shp(2,1) =  s*(s - 1.d0)*0.5d0
62        shp(2,2) =  s*(s + 1.d0)*0.5d0
63        shp(2,3) =  1.d0 - s*s
64
65!       Jacobian
66
67        xjac = 0.0d0
68        do i = 1,ndm
69          xjac = xjac + (shp(1,1)*xl(i,1)
70     &                +  shp(1,2)*xl(i,2)
71     &                +  shp(1,3)*xl(i,3))**2
72        end do ! i
73        xjac = sqrt(xjac)
74
75        shp(1,1:3) = shp(1,1:3)/xjac
76      endif
77
78      end
79