2D AMRCLAW
nestck2.f
Go to the documentation of this file.
1 c
2 c ---------------------------------------------------------
3 c
4  logical function nestck2(mnew,lbase,badpts,npts,numptc,icl,
5  1 nclust, nvar,naux)
6 c
7  use amr_module
8  implicit double precision (a-h,o-z)
9  dimension badpts(2,npts)
10  logical basecheck, isnested1, isnested2
11  logical projeccheck
12 
13  integer numptc(maxcl), zerobuff
14 c
15 c ::::::::::::::::::::::: NESTCK :::::::::::::::::::::::::::::::::::
16 c
17 c nestck - check that the potential grid mnew is completely
18 c contained in the (coarser) finest grid which stays
19 c fixed, at level lbase. projec algo. will guarantee
20 c containment in all finer grids twixt them.
21 c if grid not contained in some coarse grid, then
22 c bisect in long direction.
23 c EVENTUALLY this has to work, since flagged pts were
24 c checked for proper nesting.
25 c
26 c input parameter:
27 c mnew - grid descriptor of potential grid
28 c lbase - level which stays fixed during regridding
29 c badpts - only the flagged pts. in this cluster (# icl)
30 c :::::::::::::::::::::::::::::::::;::::::::::::::::::::::::::::::::
31 c
32  nestck2 = .true.
33  levnew = node(nestlevel,mnew)
34  lratiox = intratx(levnew-1)
35  lratioy = intraty(levnew-1)
36 c
37 !--c # for CONVEX coarsest grid at level 1, nothing to check
38  if (lbase .eq. 1) then
39  isnested1 = .true.
40 
41 c POTENTIAL BUG FIX
42 c need to also check that new grid can be projected to level-2 grids so is
43 c properly nested. might be an accident of grid gen that makes it stick out
44 c for now check using same call for both purposes
45  else
46 
47  zerobuff = 0 ! dont count buffer zone around grid in checking
48  isnested1 = basecheck(mnew,lbase,node(ndilo,mnew),
49  . node(ndihi,mnew),node(ndjlo,mnew),
50  . node(ndjhi,mnew),nvar,naux,zerobuff)
51  endif
52 
53 c again using new second definition of proper nesting (must have existing grid to project to
54 c to insure new lev-2 grid generated containing levnew grids
55  levtocheck = levnew - 2
56  if (levtocheck .le. 1) then
57  isnested2 = .true. ! base grid convex, no L shaped domains
58  else if (levtocheck .le. lbase) then
59  isnested2 = isnested1
60  else
61  mbuff = max(nghost,ibuff+1) ! you can use buffer zone in checking, since is only to flag points
62  isnested2 = basecheck(mnew,levtocheck,node(ndilo,mnew),
63  . node(ndihi,mnew),node(ndjlo,mnew),
64  . node(ndjhi,mnew),nvar,naux,mbuff)
65 
66  endif
67 
68  if (isnested1 .and. isnested2) then
69  nestck2 = .true.
70  go to 99
71  endif
72 c
73 c ### use grid indices coarsened by 1 level in checking
74 c ### remember to offset by 1 since 1st grid cell is 0,0
75 
76 c ### grid not properly nested. bisect in long direction, and return
77 c ### two clusters instead of 1.
78 c
79  50 if (npts .gt. 1) go to 55
80  write(outunit,101) levnew
81  write(*,101) levnew
82  101 format(' nestck2: 1 pt. cluster at level ',i5,' still not',
83  1 ' nested',/,' pt. too close to boundary')
84  write(outunit,104) badpts(1,npts),badpts(2,npts)
85  write(*,104) badpts(1,npts),badpts(2,npts)
86  104 format(' non-nested flagged pt. at: ',2e15.7)
87  call outtre(mstart, .false.,nvar,naux)
88  call outmsh(mnew, .false.,nvar,naux)
89  stop
90 
91  55 if (nclust .lt. maxcl) go to 60
92  write(outunit,102) maxcl
93  write(*,102) maxcl
94  102 format(' too many clusters: > ',i5,' (from nestck2) ')
95  stop
96 
97  60 if (nprint) write(outunit,103) icl, npts
98  103 format(' bisecting cluster ',i5,' with ',i5,' pts. in nestck2')
99  if (rnode(cornxhi,mnew)-rnode(cornxlo,mnew) .gt.
100  1 rnode(cornyhi,mnew) - rnode(cornylo,mnew)) then
101  rmid = (rnode(cornxhi,mnew) + rnode(cornxlo,mnew) ) / 2.
102  rmid = (node(ndihi,mnew) + node(ndilo,mnew) + 1 ) / 2.
103  rmid = rmid / lratiox
104  idir = 1
105  else
106  rmid = (rnode(cornyhi,mnew) + rnode(cornylo,mnew) ) / 2.
107  rmid = (node(ndjhi,mnew) + node(ndjlo,mnew) + 1) / 2.
108  rmid = rmid / lratioy
109  idir = 2
110  endif
111 c
112  ipt = 1
113  ntop = npts
114 
115  90 if (badpts(idir,ipt) .lt. rmid) go to 100
116 c
117 c ### swap with a point in top half not yet tested. keep smaller
118 c ### half of rect. in bottom half
119 c
120  temp = badpts(1,ipt)
121  badpts(1,ipt) = badpts(1,ntop)
122  badpts(1,ntop) = temp
123  temp = badpts(2,ipt)
124  badpts(2,ipt) = badpts(2,ntop)
125  badpts(2,ntop) = temp
126  ntop = ntop - 1
127  if (ipt .le. ntop) go to 90
128  go to 110
129  100 ipt = ipt +1
130  if (ipt .le. ntop) go to 90
131 c
132 c ### ntop points to top of 1st cluster (= no. of points in 1st cluster)
133 c
134  110 numptc(icl) = npts - ntop
135  do 120 i = icl, nclust
136  nmove = nclust + icl - i
137  120 numptc(nmove+1) = numptc(nmove)
138  numptc(icl) = ntop
139  nclust = nclust + 1
140  nestck2 = .false.
141 c
142  99 return
143  end
logical function basecheck(mnew, lbase, ilo, ihi, jlo, jhi, nvar, naux, thisBuff)
Definition: baseCheck.f:4
logical function nestck2(mnew, lbase, badpts, npts, numptc, icl, nclust, nvar, naux)
Definition: nestck2.f:4
subroutine outtre(mlev, outgrd, nvar, naux)
Definition: outtre.f:4
subroutine outmsh(mptr, outgrd, nvar, naux)
Definition: outmsh.f:4