1!$Id:$
2      subroutine update(id,f,u,urate,du,fdyn,isw)
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: Static and Dynamic UPDATE algorithms for F E A P
11
12!      Inputs:
13!       id (ndf,*)   - ID-array (vector storage)
14!       f  (nneq,2)  - Nodal force/displ: 1 = current; 2 = previous
15!       u (3*nneq)   - Displacement vectors
16!       urate(nneq,*)- Rate vectors fixed by ALGO
17!       du(nneq)     - Displacement increment from SOLVER
18!       nneq         - numnp * ndf
19!       ndf          - Number of DOF/node
20!       fdyn         - Flag: true for dynamics
21!       isw          - Control switch
22!                          1  STARTING update: begining of time step
23!                          2  UPDATE at an iteration within time step
24!                          3  BACK solution to begining of time step
25
26!      Outputs:
27!       u (3*nneq)   - Displacement vectors
28!       urate(nneq,*)- Rate vectors fixed by ALGO
29!-----[--.----+----.----+----.-----------------------------------------]
30
31      implicit  none
32
33      include  'cdata.h'
34      include  'ddata.h'
35      include  'fdata.h'
36      include  'iofile.h'
37      include  'print.h'
38      include  'sdata.h'
39      include  'tdatb.h'
40      include  'pointer.h'
41      include  'comblk.h'
42
43      logical   fdyn
44      integer   j, n, nneq2,isw, nod, id(*)
45      real*8    ub,vnorm,anorm, f(nneq,*),u(*),urate(nneq,*),du(*)
46
47      save
48
49!     Update solution vectors to begin a step
50
51      nneq2 = nneq + nneq
52
53      if(isw.eq.1) then
54
55!       Compute and output norms
56
57        if(pfr) then
58        vnorm = 0.0d0
59        do n = 1,nneq
60          vnorm = vnorm + urate(n,1)*urate(n,1)
61        end do
62        vnorm = sqrt(vnorm)
63        anorm = 0.0d0
64        if(noi.eq.1 .or. noi.eq.3 .or.
65     &     noi.eq.4 .or. noi.eq.5 .or.
66     &     noi.eq.8               ) then
67          do n = 1,nneq
68            anorm = anorm + urate(n,2)*urate(n,2)
69          end do
70          anorm = sqrt(anorm)
71        endif
72        if(prnt.and.ior.lt.0) write(*,2000) vnorm,anorm
73        write(iow,2000) vnorm,anorm
74        endif
75
76!       Update rate terms
77
78!       Generalized Newmark updates
79
80        if(noi.eq.1) then
81
82          call dyna01(u,urate,nneq,1)
83
84!       SSpj updates
85
86        elseif(noi.eq.2) then
87
88          call dyna02(u,urate,nneq,1)
89
90!       USER:  User generated routine
91
92        elseif(noi.eq.-1) then
93
94          call udynam(u(nneq2+1),u,urate,nneq,1)
95
96        endif
97
98!     UPDATES WITHIN A TIME STEP
99
100      elseif(isw.eq.2) then
101
102!       STEP 1: Update displacement and its increments within step.
103
104        nod = 0
105        do n = 1,nneq
106          nod = nod + 1
107          j = id(n)
108          if (j.gt.0) then
109
110!           For active dof compute values from solution
111!           where 'du(j)' is increment of 'u' for active dof 'j'.
112
113            u(n)       = u(n)      + cc1*du(j)
114            u(n+nneq)  = u(n+nneq) + cc2*du(j)
115            u(n+nneq2) =                 du(j)
116
117          else
118
119!           Compute values from forced inputs for fixed dof
120
121            ub         = f(n,1)
122
123!           Incremental boundary solution
124
125            if(cc3.ne.0.0d0) then
126              u(n+nneq2) = (ub - u(n))*cc3
127            else
128              u(n+nneq2) = 0.0d0
129              if(ub-u(n).ne.0.0d0) then
130                write(iow,*)' WARNING - infinite acceleration'
131              endif
132            endif
133            u(n)       = ub
134            u(n+nneq)  = u(n+nneq) + cc2*u(n+nneq2)
135          endif
136        end do
137
138!       STEP 2: For Dynamics, update rate terms [urate-vectors]
139
140        if(fdyn) then
141
142!         Generalized Newmark updates
143
144          if(noi.eq.1) then
145
146            call dyna01(u(nneq2+1),urate,nneq,2)
147
148!         SSpj Updates
149
150          elseif(noi.eq.2) then
151
152            call dyna02(u(nneq2+1),urate,nneq,2)
153
154!         USER:  User generated routine
155
156          elseif(noi.eq.-1) then
157
158            call udynam(u(nneq2+1),u,urate,nneq,2)
159
160          endif
161        endif
162
163!     BACKUP SOLUTION VECTORS: Reinitiate a transient step
164
165      elseif(isw.eq.3) then
166
167        if(fdyn)then
168
169!         Generalize Newmark updates
170
171          if(noi.eq.1) then
172
173            call dyna01(u(nneq+1),urate,nneq,3)
174
175!         SSpj updates
176
177          elseif(noi.eq.2) then
178
179            call dyna02(u(nneq+1),urate,nneq,3)
180
181!         USER:  User generated routine
182
183          elseif(noi.eq.-1) then
184
185            call udynam(u(nneq2+1),u,urate,nneq,3)
186
187          endif
188
189        endif
190
191!       Back up solution vectors: u(*)
192
193        vnorm = 1.d0/cc2
194        do n = 1,nneq
195          ub = u(n+nneq)*vnorm
196          j  = id(n)
197
198!         Compute values from current solution
199
200          if (j.gt.0) then
201            u(n)       = u(n) - ub
202            u(n+nneq)  = 0.
203            u(n+nneq2) = 0.
204
205!           Compute values from forced inputs
206
207          else
208            du(neq-j)  = 0.
209            u(n+nneq2) = 0.
210            u(n+nneq)  = 0.
211            f(n,1)     = f(n,2)
212            u(n)       = f(n,2)
213          endif
214        end do
215      endif
216
217!     Formats
218
2192000  format('   N o r m s   f o r   D y n a m i c s'/
220     1   10x,'Velocity:',e13.5,' Acceleration:',e13.5)
221
222      end
223