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 resultsprint(co,nk,kon,ipkon,lakon,ne,v,stn,inum,
20     &  stx,ielorien,norien,orab,t1,ithermal,filab,een,iperturb,fn,
21     &  nactdof,iout,vold,nodeboun,ndirboun,nboun,nmethod,ttime,xstate,
22     &  epn,mi,nstate_,ener,enern,xstaten,eei,set,nset,istartset,
23     &  iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,
24     &  nelemload,nload,ikin,ielmat,thicke,eme,emn,rhcon,nrhcon,shcon,
25     &  nshcon,cocon,ncocon,ntmat_,sideload,icfd,inomat,pslavsurf,
26     &  islavact,cdn,mortar,islavnode,nslavnode,ntie,islavsurf,time,
27     &  ielprop,prop,veold,ne0,nmpc,ipompc,nodempc,labmpc,energyini,
28     &  energy,orname,xload,itiefac,pmastsurf,springarea,tieset,ipobody,
29     &  ibody,xbody,nbody)
30!
31!     - stores the results in the .dat file, if requested
32!       - nodal quantities at the nodes
33!       - element quantities at the integration points
34!     - calculates the extrapolation of element quantities to
35!       the nodes (if requested for .frd output)
36!     - calculates 1d/2d results for 1d/2d elements by
37!       interpolation
38!
39      implicit none
40!
41      logical force,rfprint
42!
43      character*1 cflag
44      character*6 prlab(*)
45      character*8 lakon(*)
46      character*20 sideload(*),labmpc(*)
47      character*80 orname(*)
48      character*81 set(*),prset(*),tieset(3,*)
49      character*87 filab(*)
50!
51      integer kon(*),inum(*),iperm(20),mi(*),ielorien(mi(3),*),
52     &  ipkon(*),nactdof(0:mi(2),*),nodeboun(*),compressible,
53     &  nelemload(2,*),ndirboun(*),ielmat(mi(3),*),nrhcon(*),
54     &  inotr(2,*),iorienloc,iflag,nload,mt,nk,ne,ithermal(*),i,
55     &  norien,iperturb(*),iout,nboun,nmethod,node,nshcon(*),
56     &  nfield,ndim,nstate_,nset,istartset(*),iendset(*),ialset(*),
57     &  nprint,ntrans,ikin,ncocon(2,*),ntmat_,icfd,inomat(*),mortar,
58     &  islavact(*),islavnode(*),nslavnode(*),ntie,islavsurf(2,*),
59     &  ielprop(*),ne0,index,nmpc,ipompc(*),nodempc(3,*),nactdoh,
60     &  iextrapolate,itiefac(2,*),ipobody(2,*),ibody(3,*),nbody
61!
62      real*8 co(3,*),v(0:mi(2),*),stx(6,mi(1),*),stn(6,*),cdn(6,*),
63     &  qfx(3,mi(1),*),qfn(3,*),orab(7,*),fn(0:mi(2),*),pslavsurf(3,*),
64     &  t1(*),een(6,*),vold(0:mi(2),*),epn(*),thicke(mi(3),*),time,
65     &  ener(mi(1),*),enern(*),eei(6,mi(1),*),rhcon(0:1,ntmat_,*),
66     &  ttime,xstate(nstate_,mi(1),*),trab(7,*),xstaten(nstate_,*),
67     &  eme(6,mi(1),*),emn(6,*),shcon(0:3,ntmat_,*),cocon(0:6,ntmat_,*),
68     &  prop(*),veold(0:mi(2),*),energy(*),energyini(*),xload(2,*),
69     &  pmastsurf,springarea(2,*),xbody(7,*)
70!
71!
72!
73      data iflag /3/
74      data iperm /5,6,7,8,1,2,3,4,13,14,15,16,9,10,11,12,17,18,19,20/
75!
76      mt=mi(2)+1
77      iextrapolate=0
78!
79!     no print requests
80!
81      if(iout.le.0) then
82!
83!        2d basic dof results (displacements, temperature) are
84!        calculated in each iteration, so that they are available
85!        in the user subroutines
86!
87         if(filab(1)(5:5).ne.' ') then
88            nfield=mt
89            call map3dto1d2d_v(v,ipkon,inum,kon,lakon,nfield,nk,
90     &           ne,nactdof)
91         endif
92!
93!        the total energy should not be calculated:
94!        - for non-dynamical calculations (nmethod!=4)
95!        - for modal dynamics (iperturb(1)<=1)
96!        - for thermal and thermomechanical calculations (ithermal(1)>1)
97!        - for electromagnetic calculations (mi(2)=5)
98!
99c         if((nmethod.eq.4).and.(iperturb(1).gt.1).and.
100c     &      (ithermal(1).le.1).and.(mi(2).ne.5)) then
101c            call calcenergy(ipkon,lakon,kon,co,ener,mi,ne,thicke,
102c     &           ielmat,energyini,energy,ielprop,prop)
103c         endif
104!
105         return
106      endif
107!
108!     output in dat file (with *NODE PRINT or *EL PRINT)
109!
110      call printout(set,nset,istartset,iendset,ialset,nprint,
111     &  prlab,prset,v,t1,fn,ipkon,lakon,stx,eei,xstate,ener,
112     &  mi(1),nstate_,ithermal,co,kon,qfx,ttime,trab,inotr,ntrans,
113     &  orab,ielorien,norien,nk,ne,inum,filab,vold,ikin,ielmat,thicke,
114     &  eme,islavsurf,mortar,time,ielprop,prop,veold,orname,
115     &  nelemload,nload,sideload,xload,rhcon,nrhcon,ntmat_,ipobody,
116     &  ibody,xbody,nbody,nmethod)
117!
118!     for facial information (*section print): if forces and/or
119!     moments in sections are requested, the stresses have to be
120!     extrapolated from the integration points to the nodes first
121!
122      do i=1,nprint
123         if(prlab(i)(1:3).eq.'SOF') then
124            nfield=6
125            ndim=6
126            if((norien.gt.0).and.(filab(3)(6:6).eq.'L')) then
127               iorienloc=1
128            else
129               iorienloc=0
130            endif
131            cflag=filab(3)(5:5)
132            force=.false.
133!
134            call extrapolate(stx,stn,ipkon,inum,kon,lakon,nfield,nk,
135     &           ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
136     &           vold,force,ielmat,thicke,ielprop,prop)
137            iextrapolate=1
138            exit
139         endif
140      enddo
141!
142      compressible=0
143      call printoutface(co,rhcon,nrhcon,ntmat_,vold,shcon,nshcon,
144     &  cocon,ncocon,compressible,istartset,iendset,ipkon,lakon,kon,
145     &  ialset,prset,ttime,nset,set,nprint,prlab,ielmat,mi,
146     &     ithermal,nactdoh,icfd,time,stn)
147!
148      call printoutcontact(co,vold,lakon,ne0,ne,pslavsurf,stx,
149     &  prset,ttime,nprint,prlab,mi,ipkon,kon,springarea,
150     &  time,tieset,itiefac,ntie,pmastsurf)
151!
152!     interpolation in the original nodes of 1d and 2d elements
153!     this operation has to be performed in any case since
154!     the interpolated values may be needed as boundary conditions
155!     in the next step (e.g. the temperature in a heat transfer
156!     calculation as boundary condition in a subsequent static
157!     step)
158!
159      if(filab(1)(5:5).ne.' ') then
160         nfield=mt
161         cflag=filab(1)(5:5)
162         force=.false.
163         call map3dto1d2d(v,ipkon,inum,kon,lakon,nfield,nk,
164     &        ne,cflag,co,vold,force,mi,ielprop,prop)
165      endif
166!
167      if((filab(2)(1:4).eq.'NT  ').and.(ithermal(1).le.1)) then
168         if(filab(2)(5:5).eq.'I') then
169            nfield=1
170            cflag=filab(2)(5:5)
171            force=.false.
172            call map3dto1d2d(t1,ipkon,inum,kon,lakon,nfield,nk,
173     &           ne,cflag,co,vold,force,mi,ielprop,prop)
174         endif
175      endif
176!
177!     check whether forces are requested in the frd-file. If so, but
178!     none are requested in the .dat file, and output=2d,
179!     map3dto1d2d has to be called
180!
181      if(filab(5)(1:2).eq.'RF') then
182         if(filab(5)(5:5).eq.'I') then
183            rfprint=.false.
184            do i=1,nprint
185               if(prlab(i)(1:2).eq.'RF') then
186                  rfprint=.true.
187                  exit
188               endif
189            enddo
190            if(.not.rfprint) then
191               nfield=mt
192               cflag=' '
193               force=.true.
194               call map3dto1d2d(fn,ipkon,inum,kon,lakon,nfield,nk,
195     &              ne,cflag,co,vold,force,mi,ielprop,prop)
196            endif
197         endif
198      endif
199!
200!     for composites:
201!     interpolation of the displacements and temperatures
202!     from the expanded nodes to the layer nodes
203!
204      if(mi(3).gt.1) then
205         if((filab(1)(1:3).eq.'U  ').or.
206     &        ((filab(2)(1:4).eq.'NT  ').and.(ithermal(1).gt.1))) then
207            nfield=mt
208            call map3dtolayer(v,ipkon,kon,lakon,nfield,
209     &           ne,co,ielmat,mi)
210         endif
211         if((filab(2)(1:4).eq.'NT  ').and.(ithermal(1).le.1)) then
212            nfield=1
213            call map3dtolayer(t1,ipkon,kon,lakon,nfield,
214     &           ne,co,ielmat,mi)
215         endif
216      endif
217!
218!     determining the contact differential displacements and stresses
219!     in the contact nodes for output in frd format (only for face-
220!     to-face penalty; for node-to-face penalty these quantities are
221!     determined in the slave nodes and no extrapolation is necessary)
222!
223!     This block must precede all calls to extrapolate, since the
224!     field inum from extrapolatecontact.f is not correct; by a
225!     subsequent call to extrapolate inum is corrected.
226!
227      if((filab(26)(1:4).eq.'CONT').or.(filab(46)(1:4).eq.'PCON')) then
228         if(mortar.eq.1) then
229            nfield=6
230            ndim=6
231            cflag=filab(3)(5:5)
232            force=.false.
233            call extrapolatecontact(stx,cdn,ipkon,inum,kon,lakon,nfield,
234     &        nk,ne,mi(1),ndim,co,cflag,vold,force,pslavsurf,
235     &        islavact,islavnode,nslavnode,ntie,islavsurf,ielprop,prop,
236     &        ielmat,ne0)
237         endif
238      endif
239!
240!     determining the stresses in the nodes for output in frd format
241!
242      if((filab(3)(1:4).eq.'S   ').or.(filab(18)(1:4).eq.'PHS ').or.
243     &   (filab(20)(1:4).eq.'MAXS').or.
244     &   (((filab(44)(1:4).eq.'EMFE').or.(filab(45)(1:4).eq.'EMFB'))
245     &         .and.(ithermal(1).ne.2))) then
246         nfield=6
247         ndim=6
248         if((norien.gt.0).and.(filab(3)(6:6).eq.'L')) then
249            iorienloc=1
250         else
251            iorienloc=0
252         endif
253         cflag=filab(3)(5:5)
254         force=.false.
255!
256         call extrapolate(stx,stn,ipkon,inum,kon,lakon,nfield,nk,
257     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
258     &        vold,force,ielmat,thicke,ielprop,prop)
259         iextrapolate=1
260!
261      endif
262!
263!     determining the total strains in the nodes for output in frd format
264!
265      if((filab(4)(1:4).eq.'E   ').or.(filab(30)(1:4).eq.'MAXE'))
266     &     then
267         nfield=6
268         ndim=6
269         if((norien.gt.0).and.(filab(4)(6:6).eq.'L')) then
270            iorienloc=1
271         else
272            iorienloc=0
273         endif
274         cflag=filab(4)(5:5)
275         force=.false.
276         call extrapolate(eei,een,ipkon,inum,kon,lakon,nfield,nk,
277     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
278     &        vold,force,ielmat,thicke,ielprop,prop)
279         iextrapolate=1
280      endif
281!
282!     determining the mechanical strains in the nodes for output in
283!     frd format
284!
285      if(filab(32)(1:4).eq.'ME  ') then
286         nfield=6
287         ndim=6
288         if((norien.gt.0).and.(filab(4)(6:6).eq.'L')) then
289            iorienloc=1
290         else
291            iorienloc=0
292         endif
293         cflag=filab(4)(5:5)
294         force=.false.
295         call extrapolate(eme,emn,ipkon,inum,kon,lakon,nfield,nk,
296     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
297     &        vold,force,ielmat,thicke,ielprop,prop)
298         iextrapolate=1
299      endif
300!
301!     determining the plastic equivalent strain in the nodes
302!     for output in frd format
303!
304      if(filab(6)(1:4).eq.'PEEQ') then
305         nfield=1
306         ndim=nstate_
307         iorienloc=0
308         cflag=filab(6)(5:5)
309         force=.false.
310         call extrapolate(xstate,epn,ipkon,inum,kon,lakon,nfield,nk,
311     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
312     &        vold,force,ielmat,thicke,ielprop,prop)
313         iextrapolate=1
314      endif
315!
316!     determining the internal energy in the nodes
317!     for output in frd format
318!
319      if(filab(7)(1:4).eq.'ENER') then
320         nfield=1
321         ndim=1
322         iorienloc=0
323         cflag=filab(7)(5:5)
324         force=.false.
325         call extrapolate(ener,enern,ipkon,inum,kon,lakon,nfield,nk,
326     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
327     &        vold,force,ielmat,thicke,ielprop,prop)
328         iextrapolate=1
329      endif
330!
331!     determining the internal state variables in the nodes
332!     for output in frd format
333!
334      if(filab(8)(1:4).eq.'SDV ') then
335         nfield=nstate_
336         ndim=nstate_
337         if((norien.gt.0).and.(filab(9)(6:6).eq.'L')) then
338            write(*,*) '*WARNING in results: SDV variables cannot'
339            write(*,*) '         be stored in a local frame;'
340            write(*,*) '         the global frame will be used'
341         endif
342         iorienloc=0
343         cflag=filab(8)(5:5)
344         force=.false.
345         call extrapolate(xstate,xstaten,ipkon,inum,kon,lakon,nfield,nk,
346     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
347     &        vold,force,ielmat,thicke,ielprop,prop)
348         iextrapolate=1
349      endif
350!
351!     determining the heat flux in the nodes for output in frd format
352!
353      if(((filab(9)(1:4).eq.'HFL ').and.(ithermal(1).gt.1)).or.
354     &   ((filab(42)(1:3).eq.'ECD').and.(ithermal(1).eq.2))) then
355         nfield=3
356         ndim=3
357         if((norien.gt.0).and.(filab(9)(6:6).eq.'L')) then
358            iorienloc=1
359         else
360            iorienloc=0
361         endif
362         cflag=filab(9)(5:5)
363         force=.false.
364         call extrapolate(qfx,qfn,ipkon,inum,kon,lakon,nfield,nk,
365     &        ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
366     &        vold,force,ielmat,thicke,ielprop,prop)
367         iextrapolate=1
368      endif
369!
370!     if no element quantities requested in the nodes: calculate
371!     inum if nodal quantities are requested: used in subroutine frd
372!     to determine which nodes are active in the model
373!
374      if((iextrapolate.eq.0).and.
375     &   ((nmethod.ne.4).or.(iperturb(1).ge.2))) then
376!
377         nfield=0
378         ndim=0
379         iorienloc=0
380         cflag=filab(1)(5:5)
381         call createinum(ipkon,inum,kon,lakon,nk,ne,cflag,nelemload,
382     &       nload,nodeboun,nboun,ndirboun,ithermal,co,vold,mi,ielmat,
383     &       ielprop,prop)
384      endif
385!
386      if(ithermal(2).gt.1) then
387!
388!        next section is executed if at least one step is thermal
389!        or thermomechanical
390!
391!        extrapolation for the network
392!         -interpolation for the total pressure and temperature
393!          in the middle nodes
394!         -extrapolation for the mass flow in the end nodes
395!
396         call networkextrapolate(v,ipkon,inum,kon,lakon,ne,mi)
397!
398!     printing values for environmental film and
399!     pressure nodes (these nodes are considered to be network
400!     nodes)
401!
402         do i=1,nload
403            if((sideload(i)(3:4).ne.'FC').and.
404     &         (sideload(i)(3:4).ne.'NP')) cycle
405            node=nelemload(2,i)
406            if(icfd.ne.0) then
407               if(node.gt.0) then
408                  if(inomat(node).ne.0) cycle
409               endif
410            endif
411            if((node.gt.0).and.(sideload(i)(1:1).ne.' ')) then
412               if(inum(node).lt.0) cycle
413               inum(node)=-1
414            endif
415         enddo
416!
417!     printing values radiation
418!     (these nodes are considered to be network nodes, unless
419!      they were already assigned to the structure)
420!
421         do i=1,nload
422            if((sideload(i)(3:4).ne.'CR')) cycle
423            node=nelemload(2,i)
424            if(icfd.ne.0) then
425               if(node.gt.0) then
426                  if(inomat(node).ne.0) cycle
427               endif
428            endif
429            if((node.gt.0).and.(sideload(i)(1:1).ne.' ')) then
430               if(inum(node).ne.0) cycle
431               inum(node)=-1
432            endif
433         enddo
434!
435!        printing values for nodes belonging to network MPC's
436!        (these nodes are considered to be network nodes)
437!
438         do i=1,nmpc
439            if(labmpc(i)(1:7).eq.'NETWORK') then
440               index=ipompc(i)
441               do
442                  node=nodempc(1,index)
443                  if(inum(node).ge.0) inum(node)=-1
444                  index=nodempc(3,index)
445                  if(index.eq.0) exit
446               enddo
447            endif
448         enddo
449!
450!     printing values of prescribed boundary conditions (these
451!     nodes are considered to be network nodes)
452!
453         do i=1,nboun
454            node=nodeboun(i)
455            if(inum(node).ne.0) cycle
456            if(icfd.ne.0) then
457               if(inomat(node).ne.0) cycle
458            endif
459            if((cflag.ne.' ').and.(ndirboun(i).eq.3)) cycle
460            inum(node)=-1
461         enddo
462      endif
463!
464      return
465      end
466