6 integer,
intent(in) :: ipe
7 integer :: igrid, igrid_available
18 if (igrid_available == 0)
then
20 print *,
"Current maximum number of grid blocks:",
max_blocks
21 call mpistop(
"Insufficient grid blocks; increase max_blocks in meshlist")
40 integer,
intent(in) :: igrid, ipe
54 integer,
intent(in) :: igrid
56 integer :: level, ig^D, ign^D, ixCoG^L, ix, i^D
57 integer :: imin, imax, index, igCo^D, ixshift, offset, ifirst
58 integer :: icase, ixGext^L
59 double precision :: dx^D, summeddx, sizeuniformpart^D
60 double precision :: xext(ixGlo^D-1:ixGhi^D+1,1:ndim)
61 double precision :: delx_ext(ixGlo1-1:ixGhi1+1)
62 double precision :: exp_factor_ext(ixGlo1-1:ixGhi1+1),del_exp_factor_ext(ixGlo1-1:ixGhi1+1),exp_factor_primitive_ext(ixGlo1-1:ixGhi1+1)
63 double precision :: xc(ixGlo1:ixGhi1),delxc(ixGlo1:ixGhi1)
64 double precision :: exp_factor_coarse(ixGlo1:ixGhi1),del_exp_factor_coarse(ixGlo1:ixGhi1),exp_factor_primitive_coarse(ixGlo1:ixGhi1)
78 ixgext^l=ixg^
ll^ladd1;
86 if(.not.
allocated(ps(igrid)%w))
then
94 call alloc_state(igrid, pso(igrid), ixg^
ll, ixgext^l, .false.)
96 call alloc_state(igrid, ps1(igrid), ixg^
ll, ixgext^l, .false.)
101 call alloc_state(igrid, ps2(igrid), ixg^
ll, ixgext^l, .false.)
103 call alloc_state(igrid, ps2(igrid), ixg^
ll, ixgext^l, .false.)
104 call alloc_state(igrid, ps3(igrid), ixg^
ll, ixgext^l, .false.)
106 call alloc_state(igrid, ps2(igrid), ixg^
ll, ixgext^l, .false.)
107 call alloc_state(igrid, ps3(igrid), ixg^
ll, ixgext^l, .false.)
108 call alloc_state(igrid, ps4(igrid), ixg^
ll, ixgext^l, .false.)
115 ps(igrid)%w(:^d&,1)=1.d0
116 ps(igrid)%level=level
117 psc(igrid)%level=level-1
119 psc(igrid)%w(:^d&,1)=1.d0
120 if(
phys_trac) ps(igrid)%special_values=0.d0
122 pso(igrid)%level=level
123 ps1(igrid)%level=level
126 ps2(igrid)%level=level
128 ps2(igrid)%level=level
129 ps3(igrid)%level=level
131 ps2(igrid)%level=level
132 ps3(igrid)%level=level
133 ps4(igrid)%level=level
160 {
do ix=ixmhi^d-nghostcells+1,ixghi^d
161 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmax^d_,igrid)+(dble(ix-ixmhi^d)-half)*dx^d
164 ^d&dx^d=2.0d0*rnode(rpdx^d_,igrid)\
165 {
do ix=ixcogmin^d,ixcogmax^d
166 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmin^d_,igrid)+(dble(ix-nghostcells)-half)*dx^d
169 ^d&ps(igrid)%dx(ixgext^s,^d)=rnode(rpdx^d_,igrid);
170 ^d&psc(igrid)%dx(ixcog^s,^d)=2.0d0*rnode(rpdx^d_,igrid);
171 ^d&dx^d=rnode(rpdx^d_,igrid)\
172 {
do ix=ixgextmin^d,ixgextmax^d
173 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)+(dble(ix-nghostcells)-half)*dx^d
176 if(any(stretched_dim))
then
177 {
if(stretch_type(^d) == stretch_uni)
then
178 imin=(ig^d-1)*block_nx^d
180 rnode(rpxmin^d_,igrid)=xprobmin^d+dxfirst_1mq(level,^d) &
181 *(1.0d0-qstretch(level,^d)**imin)
182 rnode(rpxmax^d_,igrid)=xprobmin^d+dxfirst_1mq(level,^d) &
183 *(1.0d0-qstretch(level,^d)**imax)
185 if(rnode(rpxmax^d_,igrid)>xprobmax^d) rnode(rpxmax^d_,igrid)=xprobmax^d
186 ixshift=(ig^d-1)*block_nx^d-nghostcells
187 do ix=ixgextmin^d,ixgextmax^d
189 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(index-1)
192 ixshift=igco^d*block_nx^d+(1-modulo(ig^d,2))*block_nx^d/2-nghostcells
193 do ix=ixcogmin^d,ixcogmax^d
195 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(index-1)
196 psc(igrid)%x(ix^d%ixCoG^s,^d)=xprobmin^d+dxfirst_1mq(level-1,^d)&
197 *(1.0d0-qstretch(level-1,^d)**(index-1))&
198 + 0.5d0*dxfirst(level-1,^d)*qstretch(level-1,^d)**(index-1)
204 do ix=ixmlo^d,ixmhi^d
205 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
206 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
210 do ix=nghostcells,1,-1
211 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
212 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
216 do ix=ixghi^d-nghostcells+1,ixghi^d
217 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
218 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
223 xext(ixgext^s,^d)=ps(igrid)%x(ixgext^s,^d)
227 do ix=ixmlo^d,ixmhi^d
228 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
229 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
233 do ix=nghostcells,ixgextmin^d,-1
234 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
235 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
239 do ix=ixghi^d-nghostcells+1,ixgextmax^d
240 xext(ix^d%ixGext^s,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
241 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
247 {
if(stretch_type(^d) == stretch_symm)
then
253 if(ig^d<=nstretchedblocks(level,^d)/2)
then
255 offset=block_nx^d*nstretchedblocks(level,^d)/2
256 imin=(ig^d-1)*block_nx^d
258 rnode(rpxmin^d_,igrid)=xprobmin^d+xstretch^d-dxfirst_1mq(level,^d) &
259 *(1.0d0-qstretch(level,^d)**(offset-imin))
260 rnode(rpxmax^d_,igrid)=xprobmin^d+xstretch^d-dxfirst_1mq(level,^d) &
261 *(1.0d0-qstretch(level,^d)**(offset-imax))
263 if(rnode(rpxmin^d_,igrid)<xprobmin^d) rnode(rpxmin^d_,igrid)=xprobmin^d
264 ixshift=(ig^d-1)*block_nx^d-nghostcells
265 do ix=ixgextmin^d,ixgextmax^d
267 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(offset-index)
269 ixshift=(nstretchedblocks(level,^d)/2-ig^d)*(block_nx^d/2)+block_nx^d/2+nghostcells
270 do ix=ixcogmin^d,ixcogmax^d
272 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**index
275 if(ig^d==nstretchedblocks(level,^d)/2)
then
276 if(ng^d(level)==nstretchedblocks(level,^d))
then
278 do ix=ixghi^d-nghostcells+1,ixgextmax^d
279 ps(igrid)%dx(ix^d%ixGext^s,^d)= &
280 ps(igrid)%dx(2*(ixghi^d-nghostcells)+1-ix^d%ixGext^s,^d)
282 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
283 psc(igrid)%dx(ix^d%ixCoG^s,^d)= &
284 psc(igrid)%dx(2*(ixcogmax^d-nghostcells)+1-ix^d%ixCoG^s,^d)
288 do ix=ixghi^d-nghostcells+1,ixgextmax^d
289 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxmid(level,^d)
291 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
292 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxmid(level-1,^d)
298 do ix=ixgextmin^d,nghostcells
299 ps(igrid)%dx(ix^d%ixGext^s,^d)=ps(igrid)%dx(2*nghostcells+1-ix^d%ixGext^s,^d)
302 psc(igrid)%dx(ix^d%ixCoG^s,^d)=psc(igrid)%dx(2*nghostcells+1-ix^d%ixCoG^s,^d)
306 if(ig^d<=ng^d(level)-nstretchedblocks(level,^d)/2)
then
308 ps(igrid)%dx(ixgext^s,^d)=dxmid(level,^d)
309 psc(igrid)%dx(ixcog^s,^d)=dxmid(level-1,^d)
310 rnode(rpxmin^d_,igrid)=xprobmin^d+xstretch^d+(ig^d-nstretchedblocks(level,^d)/2-1)*block_nx^d*dxmid(level,^d)
311 rnode(rpxmax^d_,igrid)=xprobmin^d+xstretch^d+(ig^d-nstretchedblocks(level,^d)/2) *block_nx^d*dxmid(level,^d)
313 if(ig^d==nstretchedblocks(level,^d)/2+1)
then
314 do ix=ixgextmin^d,nghostcells
315 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(nghostcells-ix)
318 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(nghostcells-ix)
321 if(ig^d==ng^d(level)-nstretchedblocks(level,^d))
then
322 do ix=ixghi^d-nghostcells+1,ixgextmax^d
323 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(ix-block_nx^d-nghostcells-1)
325 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
326 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(ix-ixcogmax^d+nghostcells-1)
331 offset=block_nx^d*(ng^d(level)-nstretchedblocks(level,^d)/2)
332 sizeuniformpart^d=dxmid(1,^d)*(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d)
333 imin=(ig^d-1)*block_nx^d-offset
334 imax=ig^d*block_nx^d-offset
335 rnode(rpxmin^d_,igrid)=xprobmin^d+xstretch^d+sizeuniformpart^d+dxfirst_1mq(level,^d) &
336 *(1.0d0-qstretch(level,^d)**imin)
337 rnode(rpxmax^d_,igrid)=xprobmin^d+xstretch^d+sizeuniformpart^d+dxfirst_1mq(level,^d) &
338 *(1.0d0-qstretch(level,^d)**imax)
340 if(rnode(rpxmax^d_,igrid)>xprobmax^d) rnode(rpxmax^d_,igrid)=xprobmax^d
341 ixshift=(ig^d-1)*block_nx^d-nghostcells-offset
342 do ix=ixgextmin^d,ixgextmax^d
344 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(index-1)
346 ixshift=(ig^d+nstretchedblocks(level,^d)/2-ng^d(level)-1)*(block_nx^d/2)-nghostcells
347 do ix=ixcogmin^d,ixcogmax^d
349 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(index-1)
352 if(ig^d==ng^d(level)-nstretchedblocks(level,^d)+1)
then
353 if(ng^d(level)==nstretchedblocks(level,^d))
then
355 do ix=ixgextmin^d,nghostcells
356 ps(igrid)%dx(ix^d%ixGext^s,^d)=ps(igrid)%dx(2*nghostcells+1-ix^d%ixGext^s,^d)
359 psc(igrid)%dx(ix^d%ixCoG^s,^d)=psc(igrid)%dx(2*nghostcells+1-ix^d%ixCoG^s,^d)
363 do ix=ixgextmin^d,nghostcells
364 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxmid(level,^d)
367 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxmid(level-1,^d)
372 if(ig^d==ng^d(level))
then
373 do ix=ixghi^d-nghostcells+1,ixgextmax^d
374 ps(igrid)%dx(ix^d%ixGext^s,^d)=ps(igrid)%dx(2*(ixghi^d-nghostcells)+1-ix^d%ixGext^s,^d)
376 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
377 psc(igrid)%dx(ix^d%ixCoG^s,^d)=psc(igrid)%dx(2*(ixcogmax^d-nghostcells)+1-ix^d%ixCoG^s,^d)
386 do ix=ixmlo^d,ixmhi^d
387 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
388 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
392 do ix=nghostcells,1,-1
393 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
394 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
398 do ix=ixghi^d-nghostcells+1,ixghi^d
399 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
400 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
405 do ix=nghostcells+1,ixcogmax^d-nghostcells
406 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*psc(igrid)%dx(ix^d%ixCoG^s,^d)
407 summeddx=summeddx+psc(igrid)%dx(ix^d%ifirst,^d)
411 do ix=nghostcells,1,-1
412 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*psc(igrid)%dx(ix^d%ixCoG^s,^d)
413 summeddx=summeddx+psc(igrid)%dx(ix^d%ifirst,^d)
417 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
418 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*psc(igrid)%dx(ix^d%ixCoG^s,^d)
419 summeddx=summeddx+psc(igrid)%dx(ix^d%ifirst,^d)
424 xext(ixgext^s,^d)=ps(igrid)%x(ixgext^s,^d)
428 do ix=ixmlo^d,ixmhi^d
429 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
430 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
434 do ix=nghostcells,ixgextmin^d,-1
435 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
436 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
440 do ix=ixghi^d-nghostcells+1,ixgextmax^d
441 xext(ix^d%ixGext^s,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
442 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
451 call get_surface_area(ps(igrid),ixg^ll)
453 call get_surface_area(psc(igrid),ixcog^l)
456 select case (coordinate)
458 ps(igrid)%dvolume(ixgext^s)= {^d&rnode(rpdx^d_,igrid)|*}
459 ps(igrid)%ds(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
460 ps(igrid)%dsC(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
461 psc(igrid)%dvolume(ixcog^s)= {^d&2.d0*rnode(rpdx^d_,igrid)|*}
462 psc(igrid)%ds(ixcog^s,1:ndim)=psc(igrid)%dx(ixcog^s,1:ndim)
463 case (cartesian_stretched)
464 ps(igrid)%dvolume(ixgext^s)= {^d&ps(igrid)%dx(ixgext^s,^d)|*}
465 ps(igrid)%ds(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
466 ps(igrid)%dsC(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
467 psc(igrid)%dvolume(ixcog^s)= {^d&psc(igrid)%dx(ixcog^s,^d)|*}
468 psc(igrid)%ds(ixcog^s,1:ndim)=psc(igrid)%dx(ixcog^s,1:ndim)
469 case (cartesian_expansion)
471 delx_ext(ixgext^s) = ps(igrid)%dx(ixgext^s,1)
472 if(
associated(usr_set_surface))
call usr_set_surface(ixgext^l,xext(ixgext^s,1),delx_ext(ixgext^s),exp_factor_ext(ixgext^s),del_exp_factor_ext(ixgext^s),exp_factor_primitive_ext(ixgext^s))
473 ps(igrid)%dvolume(ixgext^s)= exp_factor_primitive_ext(ixgext^s)
474 ps(igrid)%ds(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
475 ps(igrid)%dsC(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
476 xc(ixcog^s) = psc(igrid)%x(ixcog^s,1)
477 delxc(ixcog^s) = psc(igrid)%dx(ixcog^s,1)
478 if(
associated(usr_set_surface))
call usr_set_surface(ixcog^l,xc(ixcog^s),delxc(ixcog^s),exp_factor_coarse(ixcog^s),del_exp_factor_coarse(ixcog^s),exp_factor_primitive_coarse(ixcog^s))
479 psc(igrid)%dvolume(ixcog^s)= exp_factor_primitive_coarse(ixcog^s)
480 psc(igrid)%ds(ixcog^s,1)=psc(igrid)%dx(ixcog^s,1)
483 ps(igrid)%dvolume(ixgext^s)=(xext(ixgext^s,1)**2 &
484 +ps(igrid)%dx(ixgext^s,1)**2/12.0d0)*&
485 ps(igrid)%dx(ixgext^s,1){^nooned &
486 *two*dabs(dsin(xext(ixgext^s,2))) &
487 *dsin(half*ps(igrid)%dx(ixgext^s,2))}{^ifthreed*ps(igrid)%dx(ixgext^s,3)}
488 psc(igrid)%dvolume(ixcog^s)=(psc(igrid)%x(ixcog^s,1)**2 &
489 +psc(igrid)%dx(ixcog^s,1)**2/12.0d0)*&
490 psc(igrid)%dx(ixcog^s,1){^nooned &
491 *two*dabs(dsin(psc(igrid)%x(ixcog^s,2))) &
492 *dsin(half*psc(igrid)%dx(ixcog^s,2))}{^ifthreed*psc(igrid)%dx(ixcog^s,3)}
493 ps(igrid)%ds(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
494 {^nooned ps(igrid)%ds(ixgext^s,2)=xext(ixgext^s,1)*ps(igrid)%dx(ixgext^s,2)}
495 {^ifthreed ps(igrid)%ds(ixgext^s,3)=xext(ixgext^s,1)*dsin(xext(ixgext^s,2))*&
496 ps(igrid)%dx(ixgext^s,3)}
497 ps(igrid)%dsC(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
498 {^nooned ps(igrid)%dsC(ixgext^s,2)=(xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1))*&
499 ps(igrid)%dx(ixgext^s,2)
501 ps(igrid)%dsC(ixgext^s,3)=(xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1))*&
502 dsin(xext(ixgext^s,2)+half*ps(igrid)%dx(ixgext^s,2))
505 {^ifthreed ps(igrid)%dsC(ixgext^s,3)=(xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1))*&
506 dsin(xext(ixgext^s,2)+half*ps(igrid)%dx(ixgext^s,2))*&
507 ps(igrid)%dx(ixgext^s,3)}
509 ps(igrid)%dvolume(ixgext^s)=dabs(xext(ixgext^s,1)) &
510 *ps(igrid)%dx(ixgext^s,1){^de&*ps(igrid)%dx(ixgext^s,^de) }
511 psc(igrid)%dvolume(ixcog^s)=dabs(psc(igrid)%x(ixcog^s,1)) &
512 *psc(igrid)%dx(ixcog^s,1){^de&*psc(igrid)%dx(ixcog^s,^de) }
513 ps(igrid)%ds(ixgext^s,r_)=ps(igrid)%dx(ixgext^s,r_)
514 ps(igrid)%dsC(ixgext^s,r_)=ps(igrid)%dx(ixgext^s,r_)
515 if(z_>0.and.z_<=ndim)
then
516 ps(igrid)%ds(ixgext^s,z_)=ps(igrid)%dx(ixgext^s,z_)
517 ps(igrid)%dsC(ixgext^s,z_)=ps(igrid)%dx(ixgext^s,z_)
518 if(phi_>z_.and.ndir>ndim)
then
519 ps(igrid)%dsC(ixgext^s,phi_)=xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1)
522 if(phi_>0.and.phi_<=ndim)
then
523 ps(igrid)%ds(ixgext^s,phi_)=xext(ixgext^s,1)*ps(igrid)%dx(ixgext^s,phi_)
524 ps(igrid)%dsC(ixgext^s,phi_)=(xext(ixgext^s,1)+&
525 half*ps(igrid)%dx(ixgext^s,1))*ps(igrid)%dx(ixgext^s,phi_)
526 if(z_>phi_.and.ndir>ndim) ps(igrid)%dsC(ixgext^s,z_)=1.d0
529 call mpistop(
"Sorry, coordinate unknown")
534 if (number_equi_vars>0)
call phys_set_equi_vars(igrid)
537 ps(igrid)%is_physical_boundary=.false.
544 if (periodb(^d)) ign^d=1+modulo(ign^d-1,ng^d(level))
545 if (ign^d > ng^d(level))
then
546 if(phi_ > 0 .and. poleb(2,^d))
then
548 ps(igrid)%is_physical_boundary(2*^d)=.false.
550 ps(igrid)%is_physical_boundary(2*^d)=.true.
552 else if (ign^d < 1)
then
553 if(phi_ > 0 .and. poleb(1,^d))
then
555 ps(igrid)%is_physical_boundary(2*^d-1)=.false.
557 ps(igrid)%is_physical_boundary(2*^d-1)=.true.
562 if(any(ps(igrid)%is_physical_boundary))
then
563 phyboundblock(igrid)=.true.
565 phyboundblock(igrid)=.false.
571 subroutine alloc_state(igrid, s, ixG^L, ixGext^L, alloc_once_for_ps)
574 integer,
intent(in) :: igrid, ixG^L, ixGext^L
575 logical,
intent(in) :: alloc_once_for_ps
578 allocate(s%w(ixg^s,1:nw))
582 {^
d& ixgsmin^
d = ixgmin^
d-1; ixgsmax^
d = ixgmax^
d|;}
584 allocate(s%ws(ixgs^s,1:nws))
587 allocate(s%we(ixgs^s,1:nws))
592 if(alloc_once_for_ps)
then
594 if(nw_extra>0)
allocate(s%wextra(ixg^s,1:nw_extra))
596 allocate(s%x(ixg^s,1:
ndim))
597 allocate(s%dx(ixgext^s,1:
ndim), &
598 s%ds(ixgext^s,1:
ndim),s%dsC(ixgext^s,1:3))
599 allocate(s%dvolume(ixgext^s))
600 allocate(s%surfaceC(ixgs^s,1:
ndim), &
601 s%surface(ixg^s,1:
ndim))
603 allocate(s%is_physical_boundary(2*
ndim))
606 allocate(s%J0(ixg^s,7-2*
ndir:3))
617 allocate(s%special_values(
ndim+2))
621 if(nw_extra>0) s%wextra=>ps(igrid)%wextra
626 s%dvolume=>ps(igrid)%dvolume
627 s%surfaceC=>ps(igrid)%surfaceC
628 s%surface=>ps(igrid)%surface
629 s%is_physical_boundary=>ps(igrid)%is_physical_boundary
635 s%equi_vars=>ps(igrid)%equi_vars
637 if(
phys_trac) s%special_values=>ps(igrid)%special_values
646 integer,
intent(in) :: igrid, ixG^L, ixGext^L
649 allocate(s%w(ixg^s,1:nw))
653 {^
d& ixgsmin^
d = ixgmin^
d-1; ixgsmax^
d = ixgmax^
d|;}
655 allocate(s%ws(ixgs^s,1:nws))
663 allocate(s%x(ixg^s,1:
ndim))
664 allocate(s%dx(ixgext^s,1:
ndim), &
665 s%ds(ixgext^s,1:
ndim),s%dsC(ixgext^s,1:3))
666 allocate(s%dvolume(ixgext^s))
667 allocate(s%surfaceC(ixgs^s,1:
ndim), &
668 s%surface(ixg^s,1:
ndim))
670 allocate(s%is_physical_boundary(2*
ndim))
675 integer,
intent(in) :: igrid
677 logical,
intent(in) :: dealloc_x
684 if(nw_extra>0)
deallocate(s%wextra)
687 deallocate(s%dx,s%ds,s%dsC)
688 deallocate(s%dvolume)
689 deallocate(s%surfaceC,s%surface)
690 deallocate(s%is_physical_boundary)
696 deallocate(s%equi_vars)
699 nullify(s%x,s%dx,s%ds,s%dsC,s%dvolume,s%surfaceC,s%surface)
700 nullify(s%is_physical_boundary)
705 if(nw_extra>0)
nullify(s%wextra)
712 integer,
intent(in) :: igrid
724 deallocate(s%dx,s%ds,s%dsC)
725 deallocate(s%dvolume)
726 deallocate(s%surfaceC,s%surface)
727 deallocate(s%is_physical_boundary)
733 integer,
intent(in) :: igrid
736 call mpistop(
"trying to delete a non-existing grid in dealloc_node")
subroutine alloc_node(igrid)
allocate arrays on igrid node
subroutine dealloc_node(igrid)
integer function getnode(ipe)
Get first available igrid on processor ipe.
subroutine dealloc_state_coarse(igrid, s)
subroutine putnode(igrid, ipe)
subroutine dealloc_state(igrid, s, dealloc_x)
subroutine alloc_state_coarse(igrid, s, ixGL, ixGextL)
allocate memory to one-level coarser physical state of igrid node
subroutine alloc_state(igrid, s, ixGL, ixGextL, alloc_once_for_ps)
allocate memory to physical state of igrid node
subroutine mpistop(message)
Exit MPI-AMRVAC with an error message.
Module with basic grid data structures.
logical, dimension(:,:), allocatable, save igrid_inuse
type(tree_node_ptr), dimension(:,:), allocatable, save igrid_to_node
Array to go from an [igrid, ipe] index to a node pointer.
Module with geometry-related routines (e.g., divergence, curl)
This module contains definitions of global parameters and variables and some generic functions/subrou...
type(state), pointer block
Block pointer for using one block and its previous state.
integer, parameter ssprk4
integer, parameter imex_232
double precision, dimension(:), allocatable dg
extent of grid blocks in domain per dimension, in array over levels
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer, parameter rpxmin
integer, parameter ssprk5
logical stagger_grid
True for using stagger grid.
integer, parameter imex_ars3
integer, parameter imex_trapezoidal
integer mype
The rank of the current MPI task.
integer, parameter plevel_
integer, dimension(:), allocatable, parameter d
integer, parameter nodehi
grid hierarchy info (level and grid indices)
integer ndir
Number of spatial dimensions (components) for vector variables.
logical b0field
split magnetic field as background B0 field
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
integer nghostcells
Number of ghost cells surrounding a grid.
logical phys_trac
Use TRAC (Johnston 2019 ApJL, 873, L22) for MHD or 1D HD.
logical convert
If true and restart_from_file is given, convert snapshots to other file formats.
integer, parameter ssprk3
integer, parameter rpxmax
integer, parameter rk3_bt
integer, parameter rnodehi
grid location info (corner coordinates and grid spacing)
integer max_blocks
The maximum number of grid blocks in a processor.
integer, parameter imex_cb3a
logical record_electric_field
True for record electric field.
integer, parameter imex_222
integer t_integrator
time integrator method
integer, dimension(:,:), allocatable node
double precision, dimension(ndim) dxlevel
integer, parameter imex_midpoint
Magneto-hydrodynamics module.
logical, public, protected mhd_semirelativistic
Whether semirelativistic MHD equations (Gombosi 2002 JCP) are solved.
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_set_equi_vars), pointer phys_set_equi_vars
Module with all the methods that users can customize in AMRVAC.
procedure(set_surface), pointer usr_set_surface
subroutine set_b0_grid(igrid)