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 gapheatgenerations(inpc,textpart,elcon,nelcon,
20     &  imat,ntmat_,ncmat_,irstrt,istep,istat,n,iline,ipol,inl,ipoinp,
21     &  inp,ipoinpc,nstate_,ier)
22!
23!     reading the input deck: *GAP HEAT GENERATION
24!
25      implicit none
26!
27      logical user
28!
29      character*1 inpc(*)
30      character*132 textpart(16)
31!
32      integer nelcon(2,*),imat,ntmat_,istep,istat,ipoinpc(0:*),
33     &  n,key,i,ncmat_,irstrt(*),iline,ipol,inl,ipoinp(2,*),inp(3,*),
34     &  nstate_,nline,ier
35!
36      real*8 elcon(0:ncmat_,ntmat_,*)
37!
38      user=.false.
39!
40      if((istep.gt.0).and.(irstrt(1).ge.0)) then
41         write(*,*) '*ERROR reading *GAP HEAT GENERATION:'
42         write(*,*) '       *GAP HEAT GENERATION should be placed'
43         write(*,*) '       before all step definitions'
44         ier=1
45         return
46      endif
47!
48      if(imat.eq.0) then
49         write(*,*) '*ERROR reading *GAP HEAT GENERATION:'
50         write(*,*) '       *GAP HEAT GENERATION should be preceded'
51         write(*,*) '       by a *SURFACE INTERACTION card'
52         ier=1
53         return
54      endif
55!
56      nstate_=max(nstate_,9)
57!
58      if(nelcon(1,imat).ne.-51) nelcon(1,imat)=max(nelcon(1,imat),11)
59      nelcon(2,imat)=1
60!
61      do i=2,n
62         if(textpart(i)(1:4).eq.'USER') then
63            user=.true.
64         else
65            write(*,*) '*WARNING reading *GAP HEAT GENERATION:'
66            write(*,*) '         parameter not recognized:'
67            write(*,*) '         ',
68     &                 textpart(i)(1:index(textpart(i),' ')-1)
69            call inputwarning(inpc,ipoinpc,iline,
70     &"*MATERIAL%")
71         endif
72      enddo
73!
74!     no temperature dependence allowed; last line is decisive
75!
76      nline=0
77      do
78         call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
79     &        ipoinp,inp,ipoinpc)
80         if((istat.lt.0).or.(key.eq.1)) exit
81         nline=nline+1
82         do i=1,3
83            read(textpart(i)(1:20),'(f20.0)',iostat=istat)
84     &           elcon(8+i,1,imat)
85            if(istat.gt.0) then
86               call inputerror(inpc,ipoinpc,iline,
87     &              "*GAP HEAT GENERATION%",ier)
88               return
89            endif
90         enddo
91         if(elcon(9,1,imat).le.0.d0) then
92            write(*,*)
93     &       '*ERROR reading *GAP HEAT GENERATION: fraction of'
94            write(*,*) '       dissipated energy converted into heat'
95            write(*,*) '       must be strictly positive'
96            call inputerror(inpc,ipoinpc,iline,
97     &           "*GAP HEAT GENERATION%",ier)
98            return
99         endif
100         if((elcon(10,1,imat).lt.0.d0).or.
101     &      (elcon(10,1,imat).gt.1.d0)) then
102            write(*,*)
103     &         '*ERROR reading *GAP HEAT GENERATION: weighting factor'
104            write(*,*) '       for the distribution of heat between'
105            write(*,*) '       the slave and master surface must '
106            write(*,*) '       be contained in [0,1]'
107            call inputerror(inpc,ipoinpc,iline,
108     &           "*GAP HEAT GENERATION%",ier)
109            return
110         endif
111         elcon(0,1,imat)=0.d0
112      enddo
113!
114      if((.not.user).and.(nline.eq.0)) then
115         write(*,*)
116     &        '*ERROR reading *GAP HEAT GENERATION: no data given'
117         ier=1
118         return
119      endif
120!
121!     user subroutine: vnorm=-0.01
122!     no user subroutine: vnorm from input deck: vnorm >= 0.
123!                         vnorm calculated from differential velocity: vnorm=-1.
124!
125      if(user) then
126         elcon(11,1,imat)=-0.01d0
127      elseif(elcon(11,1,imat).lt.0.d0) then
128         elcon(11,1,imat)=-1.d0
129      endif
130!
131      return
132      end
133
134