2D AMRCLAW
domain.f
Go to the documentation of this file.
1 c
2 c ----------------------------------------------------------
3 c
4  subroutine domain (nvar,vtime,nx,ny,naux,start_time)
5 c
6  use amr_module
7  implicit double precision (a-h,o-z)
8  logical vtime
9 
10 c
11 c allocate initial coarse grid domain. set node info & initialize grid
12 c initial space and time step set here too
13 c
14  mstart = nodget()
15 c
16 c code assumes in many places that lower left corner at (0,0)
17 c this initial code sets the domain - assumed rectangular
18 c if it is too large, birect will chop it up into several rectangular
19 c pieces
20 c
21  rnode(cornxlo,mstart) = xlower
22  rnode(cornylo,mstart) = ylower
23  rnode(cornyhi,mstart) = yupper
24  rnode(cornxhi,mstart) = xupper
25  node(nestlevel,mstart) = 1
26  node(levelptr,mstart) = 0
27  lstart(1) = mstart
28 
29  if (flag_richardson) then
30  if (((nx/2)*2 .ne. nx) .or. (ny/2)*2 .ne. ny) then
31  write(outunit,*)" must have even number of cells"
32  write(*,*) " must have even number of cells"
33  stop
34  endif
35  endif
36 
37  node(ndilo,mstart) = 0
38  node(ndjlo,mstart) = 0
39  node(ndihi,mstart) = nx-1
40  node(ndjhi,mstart) = ny-1
41 
42  lfine = 1
43  call birect(mstart)
44  call ginit(mstart, .true., nvar, naux, start_time)
45 c
46 c compute number of grids at level 1 (may have been bi-rected above)
47 c needs to be done here since this is used when calling advanc for
48 c parallelization
49  ngrids = 0
50  ncells = 0
51  mptr = lstart(1)
52  do while (mptr .gt. 0)
53  ngrids = ngrids + 1
54  ncells = ncells + (node(ndihi,mptr)-node(ndilo,mptr)+1)
55  & * (node(ndjhi,mptr)-node(ndjlo,mptr)+1)
56  mptr = node(levelptr, mptr)
57  end do
58  numgrids(1) = ngrids
59  numcells(1) = ncells
60  avenumgrids(1) = avenumgrids(1) + ngrids
61  iregridcount(1) = 1
62  if (ngrids .gt. 1) call arrangegrids(1,ngrids)
63 
64  write(*,100) ngrids,ncells
65  100 format("there are ",i4," grids with ",i8," cells at level 1")
66 
67 c set lbase to 1 here, to put domain 1 grids in lsit
68 c once and for all. Only here, this once, (and if restarting)
69 c does listStart have to be set outside of makeGridList
70 c but call it with lbase 0 to make grid 1
71  liststart(1) = 1
72  call makegridlist(0)
73  call makebndrylist(1) ! 1 means level 1
74 c
75 c set stable initial time step using coarse grid data
76 c
77  if (vtime) then
78  mptr = lstart(1)
79  dx = hxposs(1)
80  dy = hyposs(1)
81  dt = possk(1)
82  dtgrid = dt
83  60 mitot = node(ndihi,mptr)-node(ndilo,mptr) + 1 + 2*nghost
84  mjtot = node(ndjhi,mptr)-node(ndjlo,mptr) + 1 + 2*nghost
85  locaux = node(storeaux,mptr)
86 c # added cfl to call to estdt so call.i isnt needed in estdt:
87  call estdt(alloc(node(store1,mptr)),mitot,mjtot,nvar,
88  1 dx,dy,dtgrid,nghost,alloc(locaux),naux,cfl)
89  dt = dmin1(dt,dtgrid)
90  mptr = node(levelptr,mptr)
91  if (mptr .ne. 0) go to 60
92  possk(1) = dt
93  endif
94 c
95 c set rest of possk array for refined timesteps
96 c
97  iregsz(1) = nx
98  jregsz(1) = ny
99  iregst(1) = 0
100  jregst(1) = 0
101  iregend(1) = nx-1
102  jregend(1) = ny-1
103  do 70 level = 2, mxnest
104  iregsz(level) = iregsz(level-1) * intratx(level-1)
105  jregsz(level) = jregsz(level-1) * intraty(level-1)
106  possk(level) = possk(level-1)/dble(kratio(level-1))
107  70 continue
108 c
109  return
110  end
subroutine makebndrylist(level)
Definition: nodget.f:151
subroutine makegridlist(lbase)
Definition: nodget.f:92
subroutine ginit(msave, first, nvar, naux, start_time)
Definition: ginit.f:4
subroutine estdt(val, mitot, mjtot, nvar, dx, dy, dt, nghost, aux, naux, cfl)
Definition: estdt.f:4
integer function nodget()
Definition: nodget.f:4
subroutine birect(mptr1)
Definition: birect.f:4
subroutine arrangegrids(level, numg)
Definition: regrid.f:126
subroutine domain(nvar, vtime, nx, ny, naux, start_time)
Definition: domain.f:4