Using GEOMPACK as basis it is relative easy to adapt it for a specific application. A very good property is that the algorithm automatically determines the length scale in a specific region. This assures a good mesh quality overall and at cross overs between regions.
This mesher requires a definition of the regions which define the modell. For this the basic coordinates needs to be defined. Adding nodes afterwards means the region (variables) needs to be redefined. Due to the mesh variables this is no problem keeping track of the added nodes. The subroutine below adds nodes and update the mesh variables autmatically.
John: In the meanwhile I have learned a lot about meshing and produced quite a few lines of code. The whole time I was keeping the advancing front method in mind. Your hint motivated me to keep this in mind and I think that a some stage I will try to implement it!
subroutine nc_line(a,b,segnr,M,srg)
implicit none
integer, intent(in) :: a,b,segnr,M
type(srg_type) :: srg
integer :: i,j,n,ib,ie,d,e,k,ivrt_max
double precision :: dx,dy
!
! Add n-1 nodes to the segment with nodes from numbered d to e. First:
! 1.) find the starting node in the sequence;
! 2.) shift the nodes from k+1 to ivrt_max by n-1 positions to the right
! 3.) add the new nodes to the list
! 4.) update srg with new added nodes
!
dx = srg%x(a)-srg%x(b)
dy = srg%y(a)-srg%y(b)
n = int( dsqrt(dx*dx+dy*dy)/(srg%slot_pitch/dble(M)) + 0.5d0)
call calculate_nvc(srg)
ivrt_max = sum(srg%nvbc(1:srg%ncur))
d = sum(srg%nvbc(1:segnr-1))+1
e = d+srg%nvbc(segnr)-1
do j=d,e
if ( iabs(srg%ivrt(j)) == a ) then
k = j
exit
endif
enddo
ib = k+1+n-1
ie = ivrt_max+n-1
srg%ivrt(ib:ie) = srg%ivrt(k+1:ivrt_max)
srg%ivrt(k+1:e) = 0
dx = (srg%x(b)-srg%x(a))/dble(n)
dy = (srg%y(b)-srg%y(a))/dble(n)
do i = k+1,ib-1
srg%nvc = srg%nvc+1
srg%x(srg%nvc) = srg%x(a)+dble(i-k)*dx
srg%y(srg%nvc) = srg%y(a)+dble(i-k)*dy
srg%ivrt(i) = sign(srg%nvc,srg%ivrt(k))
end do
srg%nvc = srg%nvc+(n-1)
srg%nvbc(segnr) = srg%nvbc(segnr)+(n-1)
return
end subroutine
[URL=http://imageshack.us/photo/my-images/832/ceslot.jpg/]
[/URL]