19 integer,
intent(in) :: ipe
20 integer :: igrid, igrid_available
31 if (igrid_available == 0)
then
33 print *,
"Current maximum number of grid blocks:",
max_blocks
34 call mpistop(
"Insufficient grid blocks; increase max_blocks in meshlist")
53 integer,
intent(in) :: igrid, ipe
68 integer,
intent(in) :: igrid
70 integer :: level, ig^
d, ign^
d, ixcog^
l, ix, i^
d
71 integer :: imin, imax, index, igco^
d, ixshift, offset, ifirst
72 integer :: icase, ixgext^
l
73 double precision ::
dx^
d, summeddx, sizeuniformpart^
d
75 double precision :: delx_ext(ixglo1-1:ixghi1+1)
76 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)
77 double precision :: xc(ixglo1:ixghi1),delxc(ixglo1:ixghi1)
78 double precision :: exp_factor_coarse(ixglo1:ixghi1),del_exp_factor_coarse(ixglo1:ixghi1),exp_factor_primitive_coarse(ixglo1:ixghi1)
92 ixgext^
l=ixg^
ll^ladd1;
100 if(.not.
allocated(ps(igrid)%w))
then
127 ps(igrid)%w(:^
d&,1)=1.d0
128 ps(igrid)%level=level
129 psc(igrid)%level=level-1
131 psc(igrid)%w(:^
d&,1)=1.d0
132 if(
phys_trac) ps(igrid)%special_values=0.d0
134 ps1(igrid)%level=level
137 ps2(igrid)%level=level
139 ps2(igrid)%level=level
140 ps3(igrid)%level=level
142 ps2(igrid)%level=level
143 ps3(igrid)%level=level
144 ps4(igrid)%level=level
171 {
do ix=ixmhi^d-nghostcells+1,ixghi^d
172 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmax^d_,igrid)+(dble(ix-ixmhi^d)-half)*dx^d
175 ^d&dx^d=2.0d0*rnode(rpdx^d_,igrid)\
176 {
do ix=ixcogmin^d,ixcogmax^d
177 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmin^d_,igrid)+(dble(ix-nghostcells)-half)*dx^d
180 ^d&ps(igrid)%dx(ixgext^s,^d)=rnode(rpdx^d_,igrid);
181 ^d&psc(igrid)%dx(ixcog^s,^d)=2.0d0*rnode(rpdx^d_,igrid);
182 ^d&dx^d=rnode(rpdx^d_,igrid)\
183 {
do ix=ixgextmin^d,ixgextmax^d
184 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)+(dble(ix-nghostcells)-half)*dx^d
187 if(any(stretched_dim))
then
188 {
if(stretch_type(^d) == stretch_uni)
then
189 imin=(ig^d-1)*block_nx^d
191 rnode(rpxmin^d_,igrid)=xprobmin^d+dxfirst_1mq(level,^d) &
192 *(1.0d0-qstretch(level,^d)**imin)
193 rnode(rpxmax^d_,igrid)=xprobmin^d+dxfirst_1mq(level,^d) &
194 *(1.0d0-qstretch(level,^d)**imax)
196 if(rnode(rpxmax^d_,igrid)>xprobmax^d) rnode(rpxmax^d_,igrid)=xprobmax^d
197 ixshift=(ig^d-1)*block_nx^d-nghostcells
198 do ix=ixgextmin^d,ixgextmax^d
200 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(index-1)
203 ixshift=igco^d*block_nx^d+(1-modulo(ig^d,2))*block_nx^d/2-nghostcells
204 do ix=ixcogmin^d,ixcogmax^d
206 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(index-1)
207 psc(igrid)%x(ix^d%ixCoG^s,^d)=xprobmin^d+dxfirst_1mq(level-1,^d)&
208 *(1.0d0-qstretch(level-1,^d)**(index-1))&
209 + 0.5d0*dxfirst(level-1,^d)*qstretch(level-1,^d)**(index-1)
215 do ix=ixmlo^d,ixmhi^d
216 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
217 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
221 do ix=nghostcells,1,-1
222 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
223 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
227 do ix=ixghi^d-nghostcells+1,ixghi^d
228 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
229 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
234 xext(ixgext^s,^d)=ps(igrid)%x(ixgext^s,^d)
238 do ix=ixmlo^d,ixmhi^d
239 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
240 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
244 do ix=nghostcells,ixgextmin^d,-1
245 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
246 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
250 do ix=ixghi^d-nghostcells+1,ixgextmax^d
251 xext(ix^d%ixGext^s,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
252 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
255 call mpistop(
"no such case")
258 {
if(stretch_type(^d) == stretch_symm)
then
264 if(ig^d<=nstretchedblocks(level,^d)/2)
then
266 offset=block_nx^d*nstretchedblocks(level,^d)/2
267 imin=(ig^d-1)*block_nx^d
269 rnode(rpxmin^d_,igrid)=xprobmin^d+xstretch^d-dxfirst_1mq(level,^d) &
270 *(1.0d0-qstretch(level,^d)**(offset-imin))
271 rnode(rpxmax^d_,igrid)=xprobmin^d+xstretch^d-dxfirst_1mq(level,^d) &
272 *(1.0d0-qstretch(level,^d)**(offset-imax))
274 if(rnode(rpxmin^d_,igrid)<xprobmin^d) rnode(rpxmin^d_,igrid)=xprobmin^d
275 ixshift=(ig^d-1)*block_nx^d-nghostcells
276 do ix=ixgextmin^d,ixgextmax^d
278 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(offset-index)
280 ixshift=(nstretchedblocks(level,^d)/2-ig^d)*(block_nx^d/2)+block_nx^d/2+nghostcells
281 do ix=ixcogmin^d,ixcogmax^d
283 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**index
286 if(ig^d==nstretchedblocks(level,^d)/2)
then
287 if(ng^d(level)==nstretchedblocks(level,^d))
then
289 do ix=ixghi^d-nghostcells+1,ixgextmax^d
290 ps(igrid)%dx(ix^d%ixGext^s,^d)= &
291 ps(igrid)%dx(2*(ixghi^d-nghostcells)+1-ix^d%ixGext^s,^d)
293 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
294 psc(igrid)%dx(ix^d%ixCoG^s,^d)= &
295 psc(igrid)%dx(2*(ixcogmax^d-nghostcells)+1-ix^d%ixCoG^s,^d)
299 do ix=ixghi^d-nghostcells+1,ixgextmax^d
300 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxmid(level,^d)
302 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
303 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxmid(level-1,^d)
309 do ix=ixgextmin^d,nghostcells
310 ps(igrid)%dx(ix^d%ixGext^s,^d)=ps(igrid)%dx(2*nghostcells+1-ix^d%ixGext^s,^d)
313 psc(igrid)%dx(ix^d%ixCoG^s,^d)=psc(igrid)%dx(2*nghostcells+1-ix^d%ixCoG^s,^d)
317 if(ig^d<=ng^d(level)-nstretchedblocks(level,^d)/2)
then
319 ps(igrid)%dx(ixgext^s,^d)=dxmid(level,^d)
320 psc(igrid)%dx(ixcog^s,^d)=dxmid(level-1,^d)
321 rnode(rpxmin^d_,igrid)=xprobmin^d+xstretch^d+(ig^d-nstretchedblocks(level,^d)/2-1)*block_nx^d*dxmid(level,^d)
322 rnode(rpxmax^d_,igrid)=xprobmin^d+xstretch^d+(ig^d-nstretchedblocks(level,^d)/2) *block_nx^d*dxmid(level,^d)
324 if(ig^d==nstretchedblocks(level,^d)/2+1)
then
325 do ix=ixgextmin^d,nghostcells
326 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(nghostcells-ix)
329 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(nghostcells-ix)
332 if(ig^d==ng^d(level)-nstretchedblocks(level,^d))
then
333 do ix=ixghi^d-nghostcells+1,ixgextmax^d
334 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(ix-block_nx^d-nghostcells-1)
336 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
337 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(ix-ixcogmax^d+nghostcells-1)
342 offset=block_nx^d*(ng^d(level)-nstretchedblocks(level,^d)/2)
343 sizeuniformpart^d=dxmid(1,^d)*(domain_nx^d-nstretchedblocks_baselevel(^d)*block_nx^d)
344 imin=(ig^d-1)*block_nx^d-offset
345 imax=ig^d*block_nx^d-offset
346 rnode(rpxmin^d_,igrid)=xprobmin^d+xstretch^d+sizeuniformpart^d+dxfirst_1mq(level,^d) &
347 *(1.0d0-qstretch(level,^d)**imin)
348 rnode(rpxmax^d_,igrid)=xprobmin^d+xstretch^d+sizeuniformpart^d+dxfirst_1mq(level,^d) &
349 *(1.0d0-qstretch(level,^d)**imax)
351 if(rnode(rpxmax^d_,igrid)>xprobmax^d) rnode(rpxmax^d_,igrid)=xprobmax^d
352 ixshift=(ig^d-1)*block_nx^d-nghostcells-offset
353 do ix=ixgextmin^d,ixgextmax^d
355 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxfirst(level,^d)*qstretch(level,^d)**(index-1)
357 ixshift=(ig^d+nstretchedblocks(level,^d)/2-ng^d(level)-1)*(block_nx^d/2)-nghostcells
358 do ix=ixcogmin^d,ixcogmax^d
360 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxfirst(level-1,^d)*qstretch(level-1,^d)**(index-1)
363 if(ig^d==ng^d(level)-nstretchedblocks(level,^d)+1)
then
364 if(ng^d(level)==nstretchedblocks(level,^d))
then
366 do ix=ixgextmin^d,nghostcells
367 ps(igrid)%dx(ix^d%ixGext^s,^d)=ps(igrid)%dx(2*nghostcells+1-ix^d%ixGext^s,^d)
370 psc(igrid)%dx(ix^d%ixCoG^s,^d)=psc(igrid)%dx(2*nghostcells+1-ix^d%ixCoG^s,^d)
374 do ix=ixgextmin^d,nghostcells
375 ps(igrid)%dx(ix^d%ixGext^s,^d)=dxmid(level,^d)
378 psc(igrid)%dx(ix^d%ixCoG^s,^d)=dxmid(level-1,^d)
383 if(ig^d==ng^d(level))
then
384 do ix=ixghi^d-nghostcells+1,ixgextmax^d
385 ps(igrid)%dx(ix^d%ixGext^s,^d)=ps(igrid)%dx(2*(ixghi^d-nghostcells)+1-ix^d%ixGext^s,^d)
387 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
388 psc(igrid)%dx(ix^d%ixCoG^s,^d)=psc(igrid)%dx(2*(ixcogmax^d-nghostcells)+1-ix^d%ixCoG^s,^d)
397 do ix=ixmlo^d,ixmhi^d
398 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
399 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
403 do ix=nghostcells,1,-1
404 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
405 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
409 do ix=ixghi^d-nghostcells+1,ixghi^d
410 ps(igrid)%x(ix^d%ixG^t,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixG^t,^d)
411 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
416 do ix=nghostcells+1,ixcogmax^d-nghostcells
417 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*psc(igrid)%dx(ix^d%ixCoG^s,^d)
418 summeddx=summeddx+psc(igrid)%dx(ix^d%ifirst,^d)
422 do ix=nghostcells,1,-1
423 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*psc(igrid)%dx(ix^d%ixCoG^s,^d)
424 summeddx=summeddx+psc(igrid)%dx(ix^d%ifirst,^d)
428 do ix=ixcogmax^d-nghostcells+1,ixcogmax^d
429 psc(igrid)%x(ix^d%ixCoG^s,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*psc(igrid)%dx(ix^d%ixCoG^s,^d)
430 summeddx=summeddx+psc(igrid)%dx(ix^d%ifirst,^d)
435 xext(ixgext^s,^d)=ps(igrid)%x(ixgext^s,^d)
439 do ix=ixmlo^d,ixmhi^d
440 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
441 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
445 do ix=nghostcells,ixgextmin^d,-1
446 xext(ix^d%ixGext^s,^d)=rnode(rpxmin^d_,igrid)-summeddx-0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
447 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
451 do ix=ixghi^d-nghostcells+1,ixgextmax^d
452 xext(ix^d%ixGext^s,^d)=rnode(rpxmax^d_,igrid)+summeddx+0.5d0*ps(igrid)%dx(ix^d%ixGext^s,^d)
453 summeddx=summeddx+ps(igrid)%dx(ix^d%ifirst,^d)
456 call mpistop(
"no such case")
462 call get_surface_area(ps(igrid),ixg^ll)
464 call get_surface_area(psc(igrid),ixcog^l)
467 select case (coordinate)
469 ps(igrid)%dvolume(ixgext^s)= {^d&rnode(rpdx^d_,igrid)|*}
470 ps(igrid)%ds(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
471 ps(igrid)%dsC(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
472 psc(igrid)%dvolume(ixcog^s)= {^d&2.d0*rnode(rpdx^d_,igrid)|*}
473 psc(igrid)%ds(ixcog^s,1:ndim)=psc(igrid)%dx(ixcog^s,1:ndim)
474 case (cartesian_stretched)
475 ps(igrid)%dvolume(ixgext^s)= {^d&ps(igrid)%dx(ixgext^s,^d)|*}
476 ps(igrid)%ds(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
477 ps(igrid)%dsC(ixgext^s,1:ndim)=ps(igrid)%dx(ixgext^s,1:ndim)
478 psc(igrid)%dvolume(ixcog^s)= {^d&psc(igrid)%dx(ixcog^s,^d)|*}
479 psc(igrid)%ds(ixcog^s,1:ndim)=psc(igrid)%dx(ixcog^s,1:ndim)
480 case (cartesian_expansion)
482 delx_ext(ixgext^s) = ps(igrid)%dx(ixgext^s,1)
483 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))
484 ps(igrid)%dvolume(ixgext^s)= exp_factor_primitive_ext(ixgext^s)
485 ps(igrid)%ds(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
486 ps(igrid)%dsC(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
487 xc(ixcog^s) = psc(igrid)%x(ixcog^s,1)
488 delxc(ixcog^s) = psc(igrid)%dx(ixcog^s,1)
489 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))
490 psc(igrid)%dvolume(ixcog^s)= exp_factor_primitive_coarse(ixcog^s)
491 psc(igrid)%ds(ixcog^s,1)=psc(igrid)%dx(ixcog^s,1)
494 ps(igrid)%dvolume(ixgext^s)=(xext(ixgext^s,1)**2 &
495 +ps(igrid)%dx(ixgext^s,1)**2/12.0d0)*&
496 ps(igrid)%dx(ixgext^s,1){^nooned &
497 *two*dabs(dsin(xext(ixgext^s,2))) &
498 *dsin(half*ps(igrid)%dx(ixgext^s,2))}{^ifthreed*ps(igrid)%dx(ixgext^s,3)}
499 psc(igrid)%dvolume(ixcog^s)=(psc(igrid)%x(ixcog^s,1)**2 &
500 +psc(igrid)%dx(ixcog^s,1)**2/12.0d0)*&
501 psc(igrid)%dx(ixcog^s,1){^nooned &
502 *two*dabs(dsin(psc(igrid)%x(ixcog^s,2))) &
503 *dsin(half*psc(igrid)%dx(ixcog^s,2))}{^ifthreed*psc(igrid)%dx(ixcog^s,3)}
504 ps(igrid)%ds(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
505 {^nooned ps(igrid)%ds(ixgext^s,2)=xext(ixgext^s,1)*ps(igrid)%dx(ixgext^s,2)}
506 {^ifthreed ps(igrid)%ds(ixgext^s,3)=xext(ixgext^s,1)*dsin(xext(ixgext^s,2))*&
507 ps(igrid)%dx(ixgext^s,3)}
508 ps(igrid)%dsC(ixgext^s,1)=ps(igrid)%dx(ixgext^s,1)
509 {^nooned ps(igrid)%dsC(ixgext^s,2)=(xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1))*&
510 ps(igrid)%dx(ixgext^s,2)
512 ps(igrid)%dsC(ixgext^s,3)=(xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1))*&
513 dsin(xext(ixgext^s,2)+half*ps(igrid)%dx(ixgext^s,2))
516 {^ifthreed ps(igrid)%dsC(ixgext^s,3)=(xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1))*&
517 dsin(xext(ixgext^s,2)+half*ps(igrid)%dx(ixgext^s,2))*&
518 ps(igrid)%dx(ixgext^s,3)}
520 ps(igrid)%dvolume(ixgext^s)=dabs(xext(ixgext^s,1)) &
521 *ps(igrid)%dx(ixgext^s,1){^de&*ps(igrid)%dx(ixgext^s,^de) }
522 psc(igrid)%dvolume(ixcog^s)=dabs(psc(igrid)%x(ixcog^s,1)) &
523 *psc(igrid)%dx(ixcog^s,1){^de&*psc(igrid)%dx(ixcog^s,^de) }
524 ps(igrid)%ds(ixgext^s,r_)=ps(igrid)%dx(ixgext^s,r_)
525 ps(igrid)%dsC(ixgext^s,r_)=ps(igrid)%dx(ixgext^s,r_)
526 if(z_>0.and.z_<=ndim)
then
527 ps(igrid)%ds(ixgext^s,z_)=ps(igrid)%dx(ixgext^s,z_)
528 ps(igrid)%dsC(ixgext^s,z_)=ps(igrid)%dx(ixgext^s,z_)
529 if(phi_>z_.and.ndir>ndim)
then
530 ps(igrid)%dsC(ixgext^s,phi_)=xext(ixgext^s,1)+half*ps(igrid)%dx(ixgext^s,1)
533 if(phi_>0.and.phi_<=ndim)
then
534 ps(igrid)%ds(ixgext^s,phi_)=xext(ixgext^s,1)*ps(igrid)%dx(ixgext^s,phi_)
535 ps(igrid)%dsC(ixgext^s,phi_)=(xext(ixgext^s,1)+&
536 half*ps(igrid)%dx(ixgext^s,1))*ps(igrid)%dx(ixgext^s,phi_)
537 if(z_>phi_.and.ndir>ndim) ps(igrid)%dsC(ixgext^s,z_)=1.d0
540 call mpistop(
"Sorry, coordinate unknown")
544 if (b0field)
call set_b0_grid(igrid)
545 if (number_equi_vars>0)
call phys_set_equi_vars(igrid)
548 ps(igrid)%is_physical_boundary=.false.
555 if (periodb(^d)) ign^d=1+modulo(ign^d-1,ng^d(level))
556 if (ign^d > ng^d(level))
then
557 if(phi_ > 0 .and. poleb(2,^d))
then
559 ps(igrid)%is_physical_boundary(2*^d)=.false.
561 ps(igrid)%is_physical_boundary(2*^d)=.true.
563 else if (ign^d < 1)
then
564 if(phi_ > 0 .and. poleb(1,^d))
then
566 ps(igrid)%is_physical_boundary(2*^d-1)=.false.
568 ps(igrid)%is_physical_boundary(2*^d-1)=.true.
573 if(any(ps(igrid)%is_physical_boundary))
then
574 phyboundblock(igrid)=.true.
576 phyboundblock(igrid)=.false.
582 subroutine alloc_state(igrid, s, ixG^L, ixGext^L, alloc_once_for_ps)
585 integer,
intent(in) :: igrid, ixg^
l, ixgext^
l
586 logical,
intent(in) :: alloc_once_for_ps
589 allocate(s%w(ixg^s,1:nw))
593 {^
d& ixgsmin^
d = ixgmin^
d-1; ixgsmax^
d = ixgmax^
d|;}
595 allocate(s%ws(ixgs^s,1:nws))
598 allocate(s%we(ixgs^s,1:nws))
603 if(alloc_once_for_ps)
then
605 if(nw_extra>0)
allocate(s%wextra(ixg^s,1:nw_extra))
607 allocate(s%x(ixg^s,1:
ndim))
608 allocate(s%dx(ixgext^s,1:
ndim), &
609 s%ds(ixgext^s,1:
ndim),s%dsC(ixgext^s,1:3))
610 allocate(s%dvolume(ixgext^s))
611 allocate(s%surfaceC(ixgs^s,1:
ndim), &
612 s%surface(ixg^s,1:
ndim))
614 allocate(s%is_physical_boundary(2*
ndim))
616 allocate(s%dt(ixg^s))
621 allocate(s%J0(ixg^s,7-2*
ndir:3))
632 allocate(s%special_values(
ndim+2))
636 if(nw_extra>0) s%wextra=>ps(igrid)%wextra
641 s%dvolume=>ps(igrid)%dvolume
642 s%surfaceC=>ps(igrid)%surfaceC
643 s%surface=>ps(igrid)%surface
644 s%is_physical_boundary=>ps(igrid)%is_physical_boundary
650 s%equi_vars=>ps(igrid)%equi_vars
652 if(
phys_trac) s%special_values=>ps(igrid)%special_values
660 integer,
intent(in) :: igrid, ixG^L, ixGext^L
663 allocate(s%w(ixg^s,1:nw))
667 {^
d& ixgsmin^
d = ixgmin^
d-1; ixgsmax^
d = ixgmax^
d|;}
669 allocate(s%ws(ixgs^s,1:nws))
677 allocate(s%x(ixg^s,1:
ndim))
678 allocate(s%dx(ixgext^s,1:
ndim), &
679 s%ds(ixgext^s,1:
ndim),s%dsC(ixgext^s,1:3))
680 allocate(s%dvolume(ixgext^s))
681 allocate(s%surfaceC(ixgs^s,1:
ndim), &
682 s%surface(ixg^s,1:
ndim))
684 allocate(s%is_physical_boundary(2*
ndim))
689 integer,
intent(in) :: igrid
691 logical,
intent(in) :: dealloc_x
699 if(nw_extra>0)
deallocate(s%wextra)
702 deallocate(s%dx,s%dt,s%ds,s%dsC)
703 deallocate(s%dvolume)
704 deallocate(s%surfaceC,s%surface)
705 deallocate(s%is_physical_boundary)
711 deallocate(s%equi_vars)
714 deallocate(s%special_values)
717 nullify(s%x,s%dx,s%dt,s%ds,s%dsC,s%dvolume,s%surfaceC,s%surface)
718 nullify(s%is_physical_boundary)
723 if(nw_extra>0)
nullify(s%wextra)
729 integer,
intent(in) :: igrid
741 deallocate(s%dx,s%dt,s%ds,s%dsC)
742 deallocate(s%dvolume)
743 deallocate(s%surfaceC,s%surface)
744 nullify(s%x,s%dx,s%dt,s%ds,s%dsC,s%dvolume,s%surfaceC,s%surface)
745 nullify(s%is_physical_boundary)
751 integer,
intent(in) :: igrid
754 call mpistop(
"trying to delete a non-existing grid in dealloc_node")
subroutine alloc_state_coarse(igrid, s, ixGL, ixGextL)
allocate memory to one-level coarser physical state of igrid node
subroutine, public putnode(igrid, ipe)
subroutine dealloc_state_coarse(igrid, s)
subroutine, public dealloc_node(igrid)
subroutine, public alloc_node(igrid)
allocate arrays on igrid node
subroutine, public alloc_state(igrid, s, ixGL, ixGextL, alloc_once_for_ps)
allocate memory to physical state of igrid node
integer function, public getnode(ipe)
Get first available igrid on processor ipe.
subroutine dealloc_state(igrid, s, dealloc_x)
subroutine, public set_b0_grid(igrid)
subroutine, public 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 ixghi
Upper index of grid block arrays.
logical b0fieldalloccoarse
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
logical local_timestep
each cell has its own timestep or not
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.
double precision, dimension(:,:), allocatable dx
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
integer, parameter ixglo
Lower index of grid block arrays (always 1)
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