2D AMRCLAW
update.f
Go to the documentation of this file.
1 c
2 c -----------------------------------------------------------
3 c
16  subroutine update (level, nvar, naux)
17 c
18  use amr_module
19  implicit double precision (a-h,o-z)
20 
21 
22  integer listgrids(numgrids(level))
23 
24 c$$$ OLD INDEXING
25 c$$$ iadd(i,j,ivar) = loc + i - 1 + mitot*((ivar-1)*mjtot+j-1)
26 c$$$ iaddf(i,j,ivar) = locf + i - 1 + mi*((ivar-1)*mj +j-1)
27 c$$$ iaddfaux(i,j) = locfaux + i - 1 + mi*((mcapa-1)*mj + (j-1))
28 c$$$ iaddcaux(i,j) = loccaux + i - 1 + mitot*((mcapa-1)*mjtot+(j-1))
29 
30 c NEW INDEXING, ORDER SWITCHED
31  iadd(ivar,i,j) = loc + ivar-1 + nvar*((j-1)*mitot+i-1)
32  iaddf(ivar,i,j) = locf + ivar-1 + nvar*((j-1)*mi+i-1)
33  iaddfaux(i,j) = locfaux + mcapa-1 + naux*((j-1)*mi + (i-1))
34  iaddcaux(i,j) = loccaux + mcapa-1 + naux*((j-1)*mitot+(i-1))
35 c
36 c
37 c :::::::::::::::::::::::::: UPDATE :::::::::::::::::::::::::::::::::
38 c update - update all grids at level 'level'.
39 c this routine assumes cell centered variables.
40 c the update is done from 1 level finer meshes under it.
41 c input parameter:
42 c level - ptr to the only level to be updated. levels coarser than
43 c this will be at a diffeent time.
44 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
45 c
46  lget = level
47  if (uprint) write(outunit,100) lget
48 100 format(19h updating level ,i5)
49 c need to set up data structure for parallel distrib of grids
50 c call prepgrids(listgrids,numgrids(level),level)
51 
52 c
53 c grid loop for each level
54 c
55  dt = possk(lget)
56 
57 c mptr = lstart(lget)
58 c 20 if (mptr .eq. 0) go to 85
59 
60 
61 !$OMP PARALLEL DO PRIVATE(ng,mptr,loc,loccaux,nx,ny,mitot,mjtot,
62 !$OMP& ilo,jlo,ihi,jhi,mkid,iclo,jclo,
63 !$OMP& ichi,jchi,mi,mj,locf,locfaux,
64 !$OMP& iplo,jplo,iphi,jphi,iff,jff,totrat,i,j,
65 !$OMP& ivar,ico,jco,capa,levSt),
66 !$OMP& SHARED(lget,numgrids,listgrids,listsp,alloc,nvar,naux,
67 !$OMP& intratx,intraty,nghost,uprint,mcapa,node,
68 !$OMP& listOfGrids,listStart,lstart,level),
69 !$OMP& DEFAULT(none)
70 
71  do ng = 1, numgrids(lget)
72  !mptr = listgrids(ng)
73  levst = liststart(lget)
74  mptr = listofgrids(levst + ng - 1)
75  loc = node(store1,mptr)
76  loccaux = node(storeaux,mptr)
77  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
78  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
79  mitot = nx + 2*nghost
80  mjtot = ny + 2*nghost
81  ilo = node(ndilo,mptr)
82  jlo = node(ndjlo,mptr)
83  ihi = node(ndihi,mptr)
84  jhi = node(ndjhi,mptr)
85 c
86  if (node(cfluxptr,mptr) .eq. 0) go to 25
87 c locuse = igetsp(mitot*mjtot)
88  call upbnd(alloc(node(cfluxptr,mptr)),alloc(loc),nvar,
89  1 naux,mitot,mjtot,listsp(lget),mptr)
90 c 1 mitot,mjtot,listsp(lget),alloc(locuse),mptr)
91 c call reclam(locuse,mitot*mjtot)
92 c
93 c loop through all intersecting fine grids as source updaters.
94 c
95  25 mkid = lstart(lget+1)
96  30 if (mkid .eq. 0) go to 80
97  iclo = node(ndilo,mkid)/intratx(lget)
98  jclo = node(ndjlo,mkid)/intraty(lget)
99  ichi = node(ndihi,mkid)/intratx(lget)
100  jchi = node(ndjhi,mkid)/intraty(lget)
101 
102  mi = node(ndihi,mkid)-node(ndilo,mkid) + 1 + 2*nghost
103  mj = node(ndjhi,mkid)-node(ndjlo,mkid) + 1 + 2*nghost
104  locf = node(store1,mkid)
105  locfaux = node(storeaux,mkid)
106 c
107 c calculate starting and ending indices for coarse grid update, if overlap
108 c
109  iplo = max(ilo,iclo)
110  jplo = max(jlo,jclo)
111  iphi = min(ihi,ichi)
112  jphi = min(jhi,jchi)
113 
114  if (iplo .gt. iphi .or. jplo .gt. jphi) go to 75
115 c
116 c calculate starting index for fine grid source pts.
117 c
118  iff = iplo*intratx(lget) - node(ndilo,mkid) + nghost + 1
119  jff = jplo*intraty(lget) - node(ndjlo,mkid) + nghost + 1
120  totrat = intratx(lget) * intraty(lget)
121 
122  do 71 i = iplo-ilo+nghost+1, iphi-ilo+nghost+1
123  do 70 j = jplo-jlo+nghost+1, jphi-jlo+nghost+1
124  if (uprint) then
125  write(outunit,101) i,j,mptr,iff,jff,mkid
126  101 format(' updating pt. ',2i4,' of grid ',i3,' using ',2i4,
127  1 ' of grid ',i4)
128  write(outunit,102)(alloc(iadd(ivar,i,j)),ivar=1,nvar)
129  102 format(' old vals: ',4e12.4)
130  endif
131 c
132 c
133 c update using intrat fine points in each direction
134 c
135  do 35 ivar = 1, nvar
136  35 alloc(iadd(ivar,i,j)) = 0.d0
137 c
138  if (mcapa .eq. 0) then
139  do 50 jco = 1, intraty(lget)
140  do 50 ico = 1, intratx(lget)
141  do 40 ivar = 1, nvar
142  alloc(iadd(ivar,i,j))= alloc(iadd(ivar,i,j)) +
143  1 alloc(iaddf(ivar,iff+ico-1,jff+jco-1))
144  40 continue
145  50 continue
146  do 60 ivar = 1, nvar
147  60 alloc(iadd(ivar,i,j)) = alloc(iadd(ivar,i,j))/totrat
148 
149  else
150 
151  do 51 jco = 1, intraty(lget)
152  do 51 ico = 1, intratx(lget)
153  capa = alloc(iaddfaux(iff+ico-1,jff+jco-1))
154  do 41 ivar = 1, nvar
155  alloc(iadd(ivar,i,j))= alloc(iadd(ivar,i,j)) +
156  1 alloc(iaddf(ivar,iff+ico-1,jff+jco-1))*capa
157  41 continue
158  51 continue
159  do 61 ivar = 1, nvar
160  61 alloc(iadd(ivar,i,j)) = alloc(iadd(ivar,i,j))/
161  1 (totrat*alloc(iaddcaux(i,j)))
162  endif
163 c
164  if (uprint) write(outunit,103)(alloc(iadd(ivar,i,j)),
165  . ivar=1,nvar)
166  103 format(' new vals: ',4e12.4)
167 c
168  jff = jff + intraty(lget)
169  70 continue
170  iff = iff + intratx(lget)
171  jff = jplo*intraty(lget) - node(ndjlo,mkid) + nghost + 1
172  71 continue
173 c
174  75 mkid = node(levelptr,mkid)
175  go to 30
176 c
177  80 continue
178  end do
179 
180 !$OMP END PARALLEL DO
181 
182 c
183 c 80 mptr = node(levelptr, mptr)
184 c go to 20
185 c
186 c 85 continue
187 c
188  99 return
189  end
integer, parameter ndihi
global i index of right border of this grid
Definition: amr_module.f90:111
integer, dimension(nsize, maxgr) node
Definition: amr_module.f90:198
integer, dimension(0:maxlv+1) liststart
Definition: amr_module.f90:189
subroutine upbnd(listbc, val, nvar, naux, mitot, mjtot, maxsp, mptr)
Do conservation fix-up for cells on grid mptr that border finer grids.
Definition: upbnd.f:20
integer, dimension(maxlv) numgrids
Definition: amr_module.f90:198
integer, dimension(maxgr) listofgrids
Definition: amr_module.f90:189
integer pure function iadd(ivar, i, j)
Definition: intfil.f90:294
subroutine update(level, nvar, naux)
Synchronize between all grids on level level and grids on level level+1.
Definition: update.f:17
integer, parameter ndilo
global i index of left border of this grid
Definition: amr_module.f90:108
integer, parameter ndjlo
global j index of lower border of this grid
Definition: amr_module.f90:114
integer, parameter store1
pointer to the address of memory storing the first copy of solution data on this grid, usually for storing new solution
Definition: amr_module.f90:101
integer, dimension(maxlv) lstart
Definition: amr_module.f90:198
integer mcapa
Definition: amr_module.f90:253
integer, dimension(maxlv) intraty
Definition: amr_module.f90:198
integer, parameter outunit
Definition: amr_module.f90:290
real(kind=8), dimension(maxlv) possk
Definition: amr_module.f90:193
integer, parameter ndjhi
global j index of upper border of this grid
Definition: amr_module.f90:117
integer, dimension(maxlv) listsp
Definition: amr_module.f90:198
integer, dimension(maxlv) intratx
Definition: amr_module.f90:198
logical uprint
Definition: amr_module.f90:297
integer, parameter levelptr
node number (index) of next grid on the same level
Definition: amr_module.f90:35
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
integer, parameter cfluxptr
Pointer to an 5 by maxsp array, which has boundary information for this grid.
Definition: amr_module.f90:80
integer, parameter storeaux
pointer to the address of memory storing auxiliary data on this grid
Definition: amr_module.f90:120
real(kind=8), dimension(:), allocatable alloc
Definition: amr_module.f90:218