1!     CalculiX - A 3-dimensional finite element program
2!     Copyright (C) 1998-2021 Guido Dhondt
3!
4!     This program is free software; you can redistribute it and/or
5!     modify it under the terms of the GNU General Public License as
6!     published by the Free Software Foundation(version 2);
7!
8!
9!     This program is distributed in the hope that it will be useful,
10!     but WITHOUT ANY WARRANTY; without even the implied warranty of
11!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!     GNU General Public License for more details.
13!
14!     You should have received a copy of the GNU General Public License
15!     along with this program; if not, write to the Free Software
16!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17!
18      subroutine eqspacednodes(co,istartfront,iendfront,nnfront,
19     &     ifrontprop,nk,nfront,ifronteq,charlen,
20     &     istartfronteq,iendfronteq,nfronteq,acrackglob,ier,
21     &     iendcrackfro,iincglob,iinc,dnglob,ncyctot)
22!
23!     determine the mesh characteristic length for each front
24!
25      implicit none
26!
27      integer i,k,m,n1,n2,istartfront(*),iendfront(*),iendcrackfro(*),
28     &     nnfront,ifrontprop(*),nodesnum,ier,icrack,id,nk,nfront,
29     &     ifronteq(*),kend,istartfronteq(*),iendfronteq(*),nfronteq,
30     &     iincglob(*),iinc,ncyctot
31!
32      real*8 co(3,*),dist,charlen(*),x(nfront),px,delta,x1,x2,
33     &     acrackglob(*),dnglob(*)
34!
35!     loop over all front(s)
36!
37      icrack=1
38      nfronteq=0
39      do i=1,nnfront
40        istartfronteq(i)=nfronteq+1
41        ifronteq(istartfronteq(i))=ifrontprop(istartfront(i))
42!
43!     loop over all nodes belonging to the propagated front
44!
45        k=1
46        x(1)=0.d0
47!
48        if(iendcrackfro(icrack).lt.istartfront(i)) then
49          icrack=icrack+1
50        endif
51!
52        dnglob(ifrontprop(istartfront(i)))=1.d0*ncyctot
53        dnglob(ifrontprop(iendfront(i)))=1.d0*ncyctot
54!
55        do m=istartfront(i),iendfront(i)-1
56!
57!     distance between two adjacent propagated nodes
58!
59          n1=ifrontprop(m)
60          n2=ifrontprop(m+1)
61          dist=dsqrt((co(1,n2)-co(1,n1))**2+
62     &         (co(2,n2)-co(2,n1))**2+
63     &         (co(3,n2)-co(3,n2))**2)
64          k=k+1
65          x(k)=x(k-1)+dist
66        enddo
67        kend=k
68!
69!     nodesnum is the new number of new nodes on the propagated front
70!
71        nodesnum=nint(x(kend)/charlen(icrack))+1
72        delta=x(kend)/(nodesnum-1)
73!
74!     treating the nodes in between start and end
75!
76        do m=1,nodesnum-2
77          px=m*delta
78          call ident(x,px,kend,id)
79          nk=nk+1
80          x1=(x(id+1)-px)/(x(id+1)-x(id))
81          x2=1.d0-x1
82          n1=ifrontprop(istartfront(i)-1+id)
83          n2=ifrontprop(istartfront(i)+id)
84          do k=1,3
85            co(k,nk)=x1*co(k,n1)+x2*co(k,n2)
86          enddo
87          acrackglob(nk)=x1*acrackglob(n1)+x2*acrackglob(n2)
88          iincglob(nk)=iinc+1
89          dnglob(nk)=1.d0*ncyctot
90          ifronteq(istartfronteq(i)+m)=nk
91        enddo
92!
93!     ifronteq contains the equivalent front nodes
94!
95        nfronteq=nfronteq+nodesnum
96        iendfronteq(i)=nfronteq
97        ifronteq(iendfronteq(i))=ifrontprop(iendfront(i))
98        if(nfronteq.gt.(2*nfront)) then
99          write(*,*) '*ERROR in calccharlength: nfronteq.gt.2*nfront'
100          ier=1
101        endif
102!
103      enddo
104      return
105      end
106
107
108