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 mafillvlhs(nk,kon,ipkon,lakon,ne,icolv,jqv,irowv,
20     &     nzsv,adbv,aubv,ipvar,var)
21!
22!     filling the stiffness matrix in spare matrix format (sm)
23!
24      implicit none
25!
26      character*8 lakon(*)
27!
28      integer kon(*),icolv(*),jqv(*),nzsv,konl(8),irowv(*),ipkon(*),
29     &     ipvar(*),nk,ne,nzlv,i,j,l,jdof1,jdof2,indexe,nope
30!
31      real*8 sm(8,8),adbv(*),aubv(*),var(*)
32!
33!     determining nzlv
34!
35      nzlv=0
36      do i=nk,1,-1
37        if(icolv(i).gt.0) then
38          nzlv=i
39          exit
40        endif
41      enddo
42!
43      do i=1,nk
44        adbv(i)=0.d0
45      enddo
46      do i=1,nzsv
47        aubv(i)=0.d0
48      enddo
49!
50!     loop over all fluid elements
51!
52      do i=1,ne
53!
54        if(ipkon(i).lt.0) cycle
55        if(lakon(i)(1:1).ne.'F') cycle
56        indexe=ipkon(i)
57        if(lakon(i)(4:4).eq.'8') then
58          nope=8
59        elseif(lakon(i)(4:4).eq.'4') then
60          nope=4
61        elseif(lakon(i)(4:4).eq.'6') then
62          nope=6
63        endif
64!
65        do j=1,nope
66          konl(j)=kon(indexe+j)
67        enddo
68!
69        call e_c3d_vlhs(lakon(i),sm,i,ipvar,var)
70!
71        do j=1,nope
72!
73          jdof1=kon(indexe+j)
74!
75          do l=j,nope
76!
77            jdof2=kon(indexe+l)
78!
79            call add_sm_fl(aubv,adbv,jqv,irowv,jdof1,jdof2,
80     &           sm(j,l),j,l)
81          enddo
82        enddo
83      enddo
84!
85      return
86      end
87