1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998-2021 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19      subroutine extrapolateshell_us3(yi,yn,ipkon,inum,kon,lakon,
20     &  nfield,nk,ne,mi,ndim,orab,ielorien,co,iorienloc,cflag,
21     &  ielmat,thicke,ielprop,prop,i,iflag)
22!
23!     extrapolates field values at the integration points to the
24!     nodes for user element i of type u1
25!
26!     the present routine is called for each user element of type us45;
27!     the field yn(j,i) contains at entry the sum of all extrapolations
28!     done for component j of the variable to node i (since a node can
29!     belong to n elements (not necessarily all of type user element
30!     u1) at the end n extrapolated values are available
31!     for this node). They are accumulated and at the end divided by n. The
32!     value of n is stored in inum(i): it starts at zero and is incremented
33!     by one for each extrapolation done to node i.
34!
35!     the present routine cannot be used for network elements, only for
36!     structural elements
37!
38!     INPUT:
39!
40!     yi(ndim,mi(1),*)   value of the variables at the integration
41!                        points
42!     yn(nfield,*)       sum of the extrapolated variables at the nodes
43!                        from all elements treated previously
44!     ipkon(i)           points to the location in field kon preceding
45!                        the topology of element i
46!     inum(i)            < 0: node i is a network node
47!                        > 0: node i is a structural node; its value is
48!                             number of extrapolations performed to this
49!                             node so far
50!                        =0: node i is not used
51!     kon(*)             contains the topology of all elements. The
52!                        topology of element i starts at kon(ipkon(i)+1)
53!                        and continues until all nodes are covered. The
54!                        number of nodes depends on the element label
55!     lakon(i)           contains the label of element i
56!     nfield             number of variables to be extrapolated
57!     nk                 maximum node number in the mesh
58!     ne                 maximum element number in the mesh
59!     ndim               number of variables in the integration point
60!                        field to be extrapolated
61!     orab(7,*)          description of all local coordinate systems.
62!                        (cf. List of variables and their meaning in the
63!                        User's manual)
64!     ielorien(i)        orientation in element i
65!     co(1..3,i)         global coordinates of node i
66!     iorienloc          0: extrapolated variables requested in global
67!                           coordinates
68!                        1: extrapolated variables requested in local
69!                           coordinates
70!     cflag (char*1)     I: interpolate 3D results onto 1D/2D
71!                        E: store extrapolated 1D/2D results
72!                        M: store 1D section forces
73!                        blank: any other case
74!     ielmat(i)          material of element i
75!     thicke(j,i)        thickness of layer j in node i
76!     ielprop(i)         properties for element i are stored in
77!                        prop(ielprop(i)+1),prop(ielprop(i)+2),....
78!                        (number of properties depends on the type of
79!                        element)
80!     prop               property field
81!     i                  number of the element for which the extrapolation
82!                        is to be performed
83!     iflag              -1: values for lower surface of shell requested
84!                         0: values for midsurface of shell requested
85!                        +1: values for upper surface of shell requested
86!
87!
88!     OUTPUT:
89!
90!     yn(nfield,*)       value of the variables at the nodes
91!     inum(i)            < 0: node i is a network node
92!                        > 0: node i is a structural node; inum(i)
93!                             should be incremented by 1 if in the
94!                             call of this routine an extrapolated value
95!                             was stored for this node
96!                        =0: node i is not used
97!
98      implicit none
99!
100      character*1 cflag
101      character*8 lakon(*)
102!
103      integer ipkon(*),inum(*),kon(*),mi(*),ne,nfield,nk,i,ndim,
104     &  iorienloc,ielorien(mi(3),*),ielmat(mi(3),*),ielprop(*),iflag,
105     &  jj
106!
107      real*8 yi(ndim,mi(1),*),yn(nfield,*),orab(7,*),co(3,*),prop(*),
108     &  thicke(mi(3),*)
109!
110!     START OF THIS SUBROUTINE
111!
112      integer indexe,j,k,node
113
114
115      !
116      if(iorienloc.ne.0) then
117         write(*,*) '*ERROR in extrapolate_us3'
118         write(*,*) '       no local orientation for variables'
119         write(*,*) '       belonging to this type of element'
120         write(*,*) '       allowed'
121         call exit(201)
122      endif
123      !
124      if(nfield.eq.6) then
125         indexe=ipkon(i)
126         do j=1,3 ! number of nodes
127            node = kon(indexe+j)
128            do k=1,nfield
129            !
130            ! BOT
131            !
132              if(iflag.eq.-1) then  ! gauss point 1
133                yn(k,node) = yn(k,node) + yi(k,1,i)
134              endif
135            !
136            ! MID
137            !
138              if(iflag.eq.0) then  ! gauss point 2
139                yn(k,node) = yn(k,node) + yi(k,2,i)
140              endif
141            !
142            ! TOP
143            !
144              if(iflag.eq.1) then  ! gauss point 3
145                yn(k,node) = yn(k,node) + yi(k,3,i)
146              endif
147            enddo
148            inum(node)=inum(node)+1  ! add divider
149         enddo
150      else
151         write(*,*) '*ERROR in extrapolate_us3'
152         write(*,*) '       extropolation for element of type US3'
153         write(*,*) '       is only coded for fields with 6'
154         write(*,*) '       entries'
155         call exit(201)
156      endif
157!
158!     END OF THIS SUBROUTINE
159!
160      return
161      end
162