2D AMRCLAW
errf1.f
Go to the documentation of this file.
1 c
2 c --------------------------------------------------------------
3 c
4  subroutine errf1(rctfine,nvar,rctcrse,mptr,mi2tot,mj2tot,
5  2 mitot,mjtot,rctflg,mibuff,mjbuff)
7  implicit double precision (a-h,o-z)
8 
9 
10  dimension rctfine(nvar,mitot,mjtot)
11  dimension rctcrse(nvar,mi2tot,mj2tot)
12  dimension rctflg(mibuff,mjbuff)
13 c
14 c
15 c ::::::::::::::::::::::::::::: ERRF1 ::::::::::::::::::::::::::::::::
16 c
17 c Richardson error estimator: Used when flag_richardson is .true.
18 c Compare error estimates in rctfine, rctcrse,
19 c A point is flagged if the error estimate is greater than tol
20 c later we check if its in a region where its allowed to be flagged
21 c or alternatively required.
22 c
23 c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
24 c
25 
26 c
27  time = rnode(timemult, mptr)
28  xleft = rnode(cornxlo,mptr)
29  levm = node(nestlevel, mptr)
30  hx = hxposs(levm)
31  ybot = rnode(cornylo,mptr)
32  hy = hyposs(levm)
33  dt = possk(levm)
34  numsp = 0
35 
36  errmax = 0.0d0
37  err2 = 0.0d0
38 c order = dt*dble(2**(iorder+1) - 2)
39  order = dble(2**(iorder+1) - 2)
40 c
41  if (.not. (edebug)) go to 20
42  write(outunit,107) mptr
43  107 format(//,' coarsened grid values for grid ',i4)
44  do 10 jj = nghost+1, mj2tot-nghost
45  j = mj2tot + 1 - jj
46  write(outunit,101) (rctcrse(1,i,j),
47  . i = nghost+1, mi2tot-nghost)
48 10 continue
49  write(outunit,108) mptr
50  108 format(//, ' fine grid values for grid ',i4)
51  do 15 jj = nghost+1, mjtot-nghost
52  j = mjtot + 1 - jj
53  write(outunit,101) (rctfine(1,i,j),i=nghost+1,mitot-nghost)
54 15 continue
55 101 format(' ',40e11.3)
56 c
57 c zero out the exterior locations so they don't affect err.est.
58 c
59  20 continue
60  jfine = nghost+1
61  do 35 j = nghost+1, mj2tot-nghost
62  yofj = ybot + (dble(jfine) - .5d0)*hy
63  ifine = nghost+1
64 c
65  do 30 i = nghost+1, mi2tot-nghost
66  rflag = goodpt
67  xofi = xleft + (dble(ifine) - .5d0)*hx
68  term1 = rctfine(1,ifine,jfine)
69  term2 = rctfine(1,ifine+1,jfine)
70  term3 = rctfine(1,ifine+1,jfine+1)
71  term4 = rctfine(1,ifine,jfine+1)
72 c # divide by (aval*order) for relative error
73  aval = (term1+term2+term3+term4)/4.d0
74  est = dabs((aval-rctcrse(1,i,j))/ order)
75  if (est .gt. errmax) errmax = est
76  err2 = err2 + est*est
77 c write(outunit,102) i,j,est,rctcrse(1,i,j)
78  102 format(' i,j,est ',2i5,2e15.7)
79 c write(outunit,104) term1,term2,term3,term4
80  104 format(' ',4e15.7)
81 c rctcrse(2,i,j) = est
82 c
83  if (est .ge. tol) then
84  rflag = badpt
85  endif
86  rctcrse(1,i,j) = rflag
87  ifine = ifine + 2
88  30 continue
89  jfine = jfine + 2
90  35 continue
91 c
92 c print out intermediate flagged rctcrse (for debugging)
93 c
94  if (eprint) then
95  err2 = dsqrt(err2/dble((mi2tot-2*nghost)*(mj2tot-2*nghost)))
96  write(outunit,103) mptr, levm, time,errmax, err2
97  103 format(' grid ',i4,' level ',i4,' time ',e12.5,
98  . ' max. error = ',e15.7,' err2 = ',e15.7)
99  if (edebug) then
100  write(outunit,*) ' flagged points on coarsened grid ',
101  . '(no ghost cells) for grid ',mptr
102  do 45 jj = nghost+1, mj2tot-nghost
103  j = mj2tot + 1 - jj
104  write(outunit,106) (nint(rctcrse(1,i,j)),
105  . i=nghost+1,mi2tot-nghost)
106 106 format(1h ,80i1)
107 45 continue
108  endif
109  endif
110 c
111  jfine = nghost+1
112  do 70 j = nghost+1, mj2tot-nghost
113  ifine = nghost+1
114  do 60 i = nghost+1, mi2tot-nghost
115  if (rctcrse(1,i,j) .eq. goodpt) go to 55
116 c ## never set rctflg to good, since flag2refine may
117 c ## have previously set it to bad
118 c ## can only add bad pts in this routine
119  rctflg(ifine,jfine) = badpt
120  rctflg(ifine+1,jfine) = badpt
121  rctflg(ifine,jfine+1) = badpt
122  rctflg(ifine+1,jfine+1)= badpt
123  55 ifine = ifine + 2
124  60 continue
125  jfine = jfine + 2
126  70 continue
127 c
128 
129  if (eprint) then
130  write(outunit,118)
131  118 format(' on fine grid (no ghost cells) flagged points are')
132  if (edebug) then
133  do 56 jj = nghost+1, mjtot-nghost
134  j = mjtot + 1 - jj
135  write(outunit,106)
136  & (nint(rctflg(i,j)),i=nghost+1,mitot-nghost)
137  56 continue
138  endif
139  endif
140 
141  return
142  end
integer, parameter timemult
current simulation time on this grid
Definition: amr_module.f90:151
integer, parameter cornxlo
x-coordinate of the left border of this grid
Definition: amr_module.f90:143
real(kind=8), dimension(maxlv) hyposs
Definition: amr_module.f90:193
real(kind=8), dimension(maxlv) hxposs
Definition: amr_module.f90:193
integer, dimension(nsize, maxgr) node
Definition: amr_module.f90:198
logical edebug
Definition: amr_module.f90:297
integer, parameter nestlevel
AMR level of the grid.
Definition: amr_module.f90:44
real(kind=8), parameter goodpt
Definition: amr_module.f90:163
real(kind=8), dimension(rsize, maxgr) rnode
Definition: amr_module.f90:193
real(kind=8) tol
Definition: amr_module.f90:197
logical eprint
Definition: amr_module.f90:297
integer iorder
Definition: amr_module.f90:198
subroutine errf1(rctfine, nvar, rctcrse, mptr, mi2tot, mj2tot, mitot, mjtot, rctflg, mibuff, mjbuff)
Definition: errf1.f:6
real(kind=8), parameter badpt
Definition: amr_module.f90:165
integer, parameter outunit
Definition: amr_module.f90:290
real(kind=8), dimension(maxlv) possk
Definition: amr_module.f90:193
integer, parameter cornylo
y-coordinate of the lower border of this grid
Definition: amr_module.f90:145
integer nghost
Definition: amr_module.f90:232
The module contains the definition of a "node descriptor" as well as other global variables used duri...
Definition: amr_module.f90:21