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 extrapolate_u1(yi,yn,ipkon,inum,kon,lakon,nfield,nk,
20     &  ne,mi,ndim,orab,ielorien,co,iorienloc,cflag,
21     &  vold,force,ielmat,thicke,ielprop,prop,i)
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 u1;
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!     vold(j,i)          value of variable j in node i at the end
75!                        of the previous iteration
76!     force              logical variable; if true the values to
77!                        be extrapolated are force values; important for
78!                        interpolation from 3D expanded structures on the
79!                        original 1D/2D structure: forces across the
80!                        expansion have to be summed, not interpolated
81!     ielmat(i)          material of element i
82!     thicke(j,i)        thickness of layer j in node i
83!     ielprop(i)         properties for element i are stored in
84!                        prop(ielprop(i)+1),prop(ielprop(i)+2),....
85!                        (number of properties depends on the type of
86!                        element)
87!     prop               property field
88!     i                  number of the element for which the extrapolation
89!                        is to be performed
90!
91!     OUTPUT:
92!
93!     yn(nfield,*)       value of the variables at the nodes
94!     inum(i)            < 0: node i is a network node
95!                        > 0: node i is a structural node; inum(i)
96!                             should be incremented by 1 if in the
97!                             call of this routine an extrapolated value
98!                             was stored for this node
99!                        =0: node i is not used
100!
101      implicit none
102!
103      logical force
104!
105      character*1 cflag
106      character*8 lakon(*)
107!
108      integer ipkon(*),inum(*),kon(*),mi(*),ne,nfield,nk,i,ndim,
109     &  iorienloc,ielorien(mi(3),*),ielmat(mi(3),*),ielprop(*)
110!
111      real*8 yi(ndim,mi(1),*),yn(nfield,*),orab(7,*),co(3,*),prop(*),
112     &  vold(0:mi(2),*),thicke(mi(3),*)
113!
114!
115!
116!     START OF THIS SUBROUTINE
117!
118      integer indexe,j,k,node
119!
120      if(iorienloc.ne.0) then
121         write(*,*) '*ERROR in extrapolate_u1'
122         write(*,*) '       no local orientation for variables'
123         write(*,*) '       belonging to this type of element'
124         write(*,*) '       allowed'
125         call exit(201)
126      endif
127!
128      if(nfield.eq.6) then
129         indexe=ipkon(i)
130         do j=1,2
131            node=kon(indexe+j)
132            do k=1,nfield
133               yn(k,node)=yn(k,node)+yi(k,1,i)
134             enddo
135             inum(node)=inum(node)+1
136         enddo
137      else
138         write(*,*) '*ERROR in extrapolate_u1'
139         write(*,*) '       extropolation for element of type u1'
140         write(*,*) '       is only coded for fields with 6'
141         write(*,*) '       entries'
142         call exit(201)
143      endif
144!
145!     END OF THIS SUBROUTINE
146!
147      return
148      end
149