2D AMRCLAW
findcut.f
Go to the documentation of this file.
1 
4 c
5 c -----------------------------------------------------------
6 c
7  subroutine findcut(icl,iscr,jscr,idim,jdim,index,iside,
8  1 ilo,ihi,jlo,jhi)
9 c
10 c ::::::::::::::::::::: findcut ::::::::::::::::::::::::::::;
11 c find best place to split the 2d array of flagged points
12 c either split at a hole, or use signatures to find
13 c zero crossing of laplacian.
14 c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
15 c
16  use amr_module
17  implicit double precision (a-h,o-z)
18 
19 
20  ! TODO: not necessarily use array of size idim?
21  ! For higher level AMR grids, most elements in isrc will be zero?
22  dimension iscr(idim), jscr(jdim)
23 
24 c modified 6/02:
25 c include call.i to get def's of horizontal/vertical.
26 c integer horizontal, vertical
27 c parameter(horizontal = 1)
28 c parameter(vertical = 2)
29 
30  parameter(ithres = 2)
31  parameter(minoff = 2)
32 c
33 c look for holes first in horizontal then vertical direction
34 c
35  do 10 i = ilo, ihi
36 .eq. if (iscr(i) 0) then
37  index = i
38  iside = horizontal
39  return
40  endif
41  10 continue
42 
43  do 20 j = jlo, jhi
44 .eq. if (jscr(j) 0) then
45  index = j
46  iside = vertical
47  return
48  endif
49  20 continue
50 
51 c
52 c no holes - find 2nd derivative of signatures for best cut.
53 c overwrite signature arrays. don't make cuts less than minoff
54 c from boundary
55 c
56  ipre = iscr(ilo)
57  do 50 i = ilo+1, ihi-1
58  icur = iscr(i)
59  iscr(i) = iscr(i+1)-2*icur+ipre
60  ipre = icur
61  50 continue
62 
63  locmaxi = 0
64  indexi = 0
65  imid = (ilo + ihi) / 2
66  do 60 i = ilo+minoff, ihi-minoff+1
67  itemp1 = iscr(i-1)
68  itemp2 = iscr(i)
69  locdif = iabs(itemp1-itemp2)
70  if (itemp1*itemp2.lt.0) then
71  if (locdif .gt. locmaxi) then
72  locmaxi = locdif
73  indexi = i
74  else if (locdif .eq. locmaxi) then
75  if (iabs(i-imid).lt.iabs(indexi-imid)) indexi = i
76  endif
77  endif
78  60 continue
79 
80 
81  jpre = jscr(jlo)
82  do 130 j = jlo+1, jhi-1
83  jcur = jscr(j)
84  jscr(j) = jscr(j+1)-2*jcur+jpre
85  jpre = jcur
86  130 continue
87 
88  locmaxj = 0
89  indexj = 0
90  jmid = (jlo + jhi) / 2
91  do 160 j = jlo+minoff, jhi-minoff+1
92  jtemp1 = jscr(j-1)
93  jtemp2 = jscr(j)
94  locdif = iabs(jtemp1-jtemp2)
95  if (jtemp1*jtemp2.lt.0) then
96  if (locdif .gt. locmaxj) then
97  locmaxj = locdif
98  indexj = j
99  else if (locdif .eq. locmaxj) then
100  if (iabs(j-jmid).lt.iabs(indexj-jmid)) indexj = j
101  endif
102  endif
103  160 continue
104 c
105 c ::::: choose max dif for splitting
106 c
107  220 if (locmaxi .gt. locmaxj) then
108  index = indexi
109  iside = horizontal
110  locmax = locmaxi
111  else if (locmaxi .lt. locmaxj) then
112  index = indexj
113  iside = vertical
114  locmax = locmaxj
115  else if (iabs(indexi-imid).lt.iabs(indexj-jmid)) then
116  index = indexi
117  iside = horizontal
118  locmax = locmaxi
119  else
120  index = indexj
121  iside = vertical
122  locmax = locmaxj
123  endif
124 
125 c ::::: if inflection pt. not over the threshold, signal
126 c ::::: with index 0 (out of range)
127  if (locmax .lt. ithres) index = 0
128 
129  return
130  end
integer, parameter vertical
Definition: amr_module.f90:172
integer, parameter horizontal
Definition: amr_module.f90:171
subroutine findcut(icl, iscr, jscr, idim, jdim, index, iside,
Find best place to split the 2D array of flagged points.
Definition: findcut.f:8
The module contains the definition of a "node descriptor" as well as other global variables used duri...
Definition: amr_module.f90:21