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 flowresult(ntg,itg,cam,vold,v,nload,sideload,
20     &     nelemload,xloadact,nactdog,network,mi,ne,ipkon,lakon,kon)
21!
22      implicit none
23!
24      character*8 lakon(*),lakonl
25      character*20 sideload(*)
26!
27      integer i,j,nload,node,ntg,itg(*),nelemload(2,*),kon(*),
28     &     nactdog(0:3,*),network,mi(*),ne,indexe,ipkon(*),
29     &     node1,node2,node3
30!
31      real*8 cam(5),vold(0:mi(2),*),v(0:mi(2),*),xloadact(2,*)
32!
33!
34!
35!     calculating the change of gas temperature: is taken
36!     into account in the global convergence for purely
37!     thermal networks (reason: for purely thermal networks
38!     the network solution is not iterated to speed up
39!     the calculation)
40!
41      if(network.le.1) then
42         do i=1,ntg
43            node=itg(i)
44            if(nactdog(0,node).eq.0) cycle
45            if(dabs(vold(0,node)-v(0,node)).gt.cam(2)) then
46               cam(2)=dabs(vold(0,node)-v(0,node))
47               cam(5)=node+0.5d0
48            endif
49         enddo
50      endif
51!
52!     replacing vold by v (including the static temperature for
53!     gases and the critical depth for liquid channels)
54!
55      do i=1,ntg
56         node=itg(i)
57         do j=0,3
58            vold(j,node)=v(j,node)
59         enddo
60      enddo
61!
62!     determining all inflowing mass flow in the end nodes and
63!     assigning it to the end nodes
64!
65      do i=1,ne
66!
67         if(ipkon(i).lt.0) cycle
68         lakonl=lakon(i)
69         if(lakonl(1:1).ne.'D') cycle
70         if(lakonl(1:7).eq.'DCOUP3D') cycle
71!
72         indexe=ipkon(i)
73         if(kon(indexe+1).ne.0)  then
74            node1=kon(indexe+1)
75            vold(1,node1)=0.d0
76         endif
77         if(kon(indexe+3).ne.0) then
78            node3=kon(indexe+3)
79            vold(1,node3)=0.d0
80         endif
81      enddo
82!
83      do i=1,ne
84!
85         if(ipkon(i).lt.0) cycle
86         lakonl=lakon(i)
87         if(lakonl(1:1).ne.'D') cycle
88         if(lakonl(1:7).eq.'DCOUP3D') cycle
89!
90         indexe=ipkon(i)
91         node2=kon(indexe+2)
92         if(kon(indexe+1).ne.0)  then
93            node1=kon(indexe+1)
94c            if(vold(1,node2).gt.0.d0)
95c     &         vold(1,node1)=vold(1,node1)+vold(1,node2)
96            if(vold(1,node2).lt.0.d0)
97     &         vold(1,node1)=vold(1,node1)-vold(1,node2)
98         endif
99         if(kon(indexe+3).ne.0) then
100            node3=kon(indexe+3)
101c            if(vold(1,node2).lt.0.d0)
102c     &         vold(1,node3)=vold(1,node3)-vold(1,node2)
103            if(vold(1,node2).gt.0.d0)
104     &         vold(1,node3)=vold(1,node3)+vold(1,node2)
105         endif
106      enddo
107!
108!     updating the film boundary conditions
109!
110      do i=1,nload
111         if(sideload(i)(3:4).eq.'FC') then
112            node=nelemload(2,i)
113            xloadact(2,i)=vold(0,node)
114         endif
115      enddo
116!
117!     updating the pressure boundary conditions
118!
119      do i=1,nload
120         if(sideload(i)(3:4).eq.'NP') then
121            node=nelemload(2,i)
122            xloadact(1,i)=vold(2,node)
123         endif
124      enddo
125!
126      return
127      end
128
129
130
131
132
133
134
135
136