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 networkextrapolate(v,ipkon,inum,kon,lakon,
20     &  ne,mi)
21!
22!     extrapolates nodal values in fluid elements
23!
24      implicit none
25!
26      character*8 lakon(*),lakonl
27!
28      integer ipkon(*),inum(*),kon(*),ne,indexe,i,node1,node2,node3,
29     &  mi(*)
30!
31      real*8 v(0:mi(2),*)
32!
33!     determining all inflowing mass flow in the end nodes and
34!     assigning it to the end nodes
35!
36!     the corresponding action for the .dat file is done in
37!     flowoutput.f; this latter result is always positive.
38!
39      do i=1,ne
40!
41         if(ipkon(i).lt.0) cycle
42         lakonl=lakon(i)
43         if(lakonl(1:1).ne.'D') cycle
44         if(lakonl(1:7).eq.'DCOUP3D') cycle
45!
46         indexe=ipkon(i)
47         if(kon(indexe+1).ne.0)  then
48            node1=kon(indexe+1)
49            v(1,node1)=0.d0
50         endif
51         if(kon(indexe+3).ne.0) then
52            node3=kon(indexe+3)
53            v(1,node3)=0.d0
54         endif
55      enddo
56!
57      do i=1,ne
58!
59         if(ipkon(i).lt.0) cycle
60         lakonl=lakon(i)
61         if(lakonl(1:1).ne.'D') cycle
62         if(lakonl(1:7).eq.'DCOUP3D') cycle
63!
64         indexe=ipkon(i)
65         node2=kon(indexe+2)
66         if(kon(indexe+1).ne.0)  then
67            node1=kon(indexe+1)
68            inum(node1)=-1
69c            if(v(1,node2).gt.0.d0) v(1,node1)=v(1,node1)+v(1,node2)
70            if(v(1,node2).lt.0.d0) v(1,node1)=v(1,node1)-v(1,node2)
71         endif
72         inum(node2)=inum(node2)-1
73         if(kon(indexe+3).ne.0) then
74            node3=kon(indexe+3)
75            inum(node3)=-1
76c            if(v(1,node2).lt.0.d0) v(1,node3)=v(1,node3)+v(1,node2)
77            if(v(1,node2).gt.0.d0) v(1,node3)=v(1,node3)+v(1,node2)
78         endif
79      enddo
80!
81!     interpolating the total temperature, total pressure
82!     and static temperature;
83!
84      do i=1,ne
85!
86         if(ipkon(i).lt.0) cycle
87         lakonl=lakon(i)
88         if(lakonl(1:1).ne.'D') cycle
89         if(lakonl(1:7).eq.'DCOUP3D') cycle
90!
91         indexe=ipkon(i)
92!
93!        end node
94!
95         node1=kon(indexe+1)
96!
97!        other end node
98!
99         node3=kon(indexe+3)
100!
101!        middle node and zero nodes (network entrances/exits)
102!        interpolating the total temperature, total pressure
103!        and static temperature
104!
105         node2=kon(indexe+2)
106         if(node1.eq.0) then
107            v(0,node2)=v(0,node3)
108            v(2,node2)=v(2,node3)
109            v(3,node2)=v(3,node3)
110         elseif(node3.eq.0) then
111            v(0,node2)=v(0,node1)
112            v(2,node2)=v(2,node1)
113            v(3,node2)=v(3,node1)
114         else
115            v(0,node2)=(v(0,node1)+v(0,node3))/2.d0
116            v(2,node2)=(v(2,node1)+v(2,node3))/2.d0
117            v(3,node2)=(v(3,node1)+v(3,node3))/2.d0
118         endif
119      enddo
120!
121      return
122      end
123