7 double precision,
dimension(:^D&,:),
pointer:: flux => null()
8 double precision,
dimension(:^D&,:),
pointer:: edge => null()
11 type(fluxalloc),
dimension(:,:,:),
allocatable,
public ::
pflux
13 double precision,
allocatable,
save :: recvbuffer(:), sendbuffer(:)
15 double precision,
allocatable,
save :: recvbuffer_cc(:), sendbuffer_cc(:)
16 integer,
dimension(:),
allocatable :: fc_recvreq, fc_sendreq
17 integer,
dimension(:,:),
allocatable :: fc_recvstat, fc_sendstat
18 integer,
dimension(^ND),
save :: isize
19 integer,
save :: nrecv, nsend
20 integer :: ibuf, ibuf_send
22 integer,
save :: nrecv_ct, nsend_ct
23 integer,
dimension(:),
allocatable :: cc_recvreq, cc_sendreq
24 integer,
dimension(:,:),
allocatable :: cc_recvstat, cc_sendstat
25 integer,
dimension(^ND),
save :: isize_stg
26 integer :: ibuf_cc, ibuf_cc_send
27 integer :: itag, itag_cc, isend, isend_cc, irecv, irecv_cc
44 integer,
intent(in) :: idim^lim,nwfluxin
46 integer :: iigrid, igrid, idims, iside, i^
d, nxco^
d
47 integer :: ic^
d, inc^
d, ipe_neighbor
48 integer :: recvsize, sendsize
49 integer :: recvsize_cc, sendsize_cc
71 nrecv=nrecv+nrecv_fc(^
d)
72 nsend=nsend+nsend_fc(^
d)
74 isize(^
d)={nxco^dd*}*(nwfluxin)
75 recvsize=recvsize+nrecv_fc(^
d)*isize(^
d)
76 sendsize=sendsize+nsend_fc(^
d)*isize(^
d)
80 isize_stg(^
d)={nxco^dd*}*(^nd-1)
82 isize(^
d)=isize(^
d)+isize_stg(^
d)
83 recvsize=recvsize+nrecv_fc(^
d)*isize_stg(^
d)
84 sendsize=sendsize+nsend_fc(^
d)*isize_stg(^
d)
86 nrecv_ct=nrecv_ct+nrecv_cc(^
d)
87 nsend_ct=nsend_ct+nsend_cc(^
d)
88 recvsize_cc=recvsize_cc+nrecv_cc(^
d)*isize_stg(^
d)
89 sendsize_cc=sendsize_cc+nsend_cc(^
d)*isize_stg(^
d)
96 if (
allocated(recvbuffer))
then
97 if (recvsize /=
size(recvbuffer))
then
98 deallocate(recvbuffer)
99 allocate(recvbuffer(recvsize))
102 allocate(recvbuffer(recvsize))
105 if (
allocated(fc_recvreq))
then
106 if (nrecv /=
size(fc_recvreq))
then
107 deallocate(fc_recvreq, fc_recvstat)
108 allocate(fc_recvstat(mpi_status_size,nrecv), fc_recvreq(nrecv))
111 allocate(fc_recvstat(mpi_status_size,nrecv), fc_recvreq(nrecv))
114 if (
allocated(fc_sendreq))
then
115 if (nsend /=
size(fc_sendreq))
then
116 deallocate(fc_sendreq, fc_sendstat)
117 allocate(fc_sendstat(mpi_status_size,nsend), fc_sendreq(nsend))
120 allocate(fc_sendstat(mpi_status_size,nsend), fc_sendreq(nsend))
125 if (
allocated(sendbuffer))
then
126 if (sendsize /=
size(sendbuffer))
then
127 deallocate(sendbuffer)
128 allocate(sendbuffer(sendsize))
131 allocate(sendbuffer(sendsize))
134 if (
allocated(recvbuffer_cc))
then
135 if (recvsize_cc /=
size(recvbuffer_cc))
then
136 deallocate(recvbuffer_cc)
137 allocate(recvbuffer_cc(recvsize_cc))
140 allocate(recvbuffer_cc(recvsize_cc))
143 if (
allocated(cc_recvreq))
then
144 if (nrecv_ct /=
size(cc_recvreq))
then
145 deallocate(cc_recvreq, cc_recvstat)
146 allocate(cc_recvstat(mpi_status_size,nrecv_ct), cc_recvreq(nrecv_ct))
149 allocate(cc_recvstat(mpi_status_size,nrecv_ct), cc_recvreq(nrecv_ct))
152 if (
allocated(sendbuffer_cc))
then
153 if (sendsize_cc /=
size(sendbuffer_cc))
then
154 deallocate(sendbuffer_cc)
155 allocate(sendbuffer_cc(sendsize_cc))
158 allocate(sendbuffer_cc(sendsize_cc))
161 if (
allocated(cc_sendreq))
then
162 if (nsend_ct /=
size(cc_sendreq))
then
163 deallocate(cc_sendreq, cc_sendstat)
164 allocate(cc_sendstat(mpi_status_size,nsend_ct), cc_sendreq(nsend_ct))
167 allocate(cc_sendstat(mpi_status_size,nsend_ct), cc_sendreq(nsend_ct))
176 integer,
intent(in) :: idim^lim
178 integer :: iigrid, igrid, idims, iside, i^
d, nxco^
d
179 integer :: ic^
d, inc^
d, ipe_neighbor
180 integer :: pi^
d,mi^
d,ph^
d,mh^
d,idir
183 fc_recvreq=mpi_request_null
187 do iigrid=1,igridstail; igrid=igrids(iigrid);
190 i^
d=
kr(^
d,idims)*(2*iside-3);
192 if (neighbor_pole(i^
d,igrid)/=0) cycle
194 if (neighbor_type(i^
d,igrid)/=4) cycle
195 {
do ic^db=1+int((1-i^db)/2),2-int((1+i^db)/2)
196 inc^db=2*i^db+ic^db\}
197 ipe_neighbor=neighbor_child(2,inc^
d,igrid)
198 if (ipe_neighbor/=
mype)
then
200 itag=4**^nd*(igrid-1)+{inc^
d*4**(^
d-1)+}
201 call mpi_irecv(recvbuffer(ibuf),isize(idims), &
202 mpi_double_precision,ipe_neighbor,itag, &
204 ibuf=ibuf+isize(idims)
212 if(stagger_grid)
then
215 cc_recvreq=mpi_request_null
219 do iigrid=1,igridstail; igrid=igrids(iigrid);
222 i^d=kr(^d,idims)*(2*iside-3);
229 if (neighbor_type(i^d,igrid)==3)
then
231 pi^d=i^d+kr(idir,^d);
232 mi^d=i^d-kr(idir,^d);
233 ph^d=pi^d-kr(idims,^d)*(2*iside-3);
234 mh^d=mi^d-kr(idims,^d)*(2*iside-3);
236 if (neighbor_type(pi^d,igrid)==4.and.&
237 neighbor_type(ph^d,igrid)==3.and.&
238 neighbor_pole(pi^d,igrid)==0)
then
240 {
do ic^db=1+int((1-pi^db)/2),2-int((1+pi^db)/2)
241 inc^db=2*pi^db+ic^db\}
242 ipe_neighbor=neighbor_child(2,inc^d,igrid)
243 if (mype/=ipe_neighbor)
then
245 itag_cc=4**^nd*(igrid-1)+{inc^d*4**(^d-1)+}
246 call mpi_irecv(recvbuffer_cc(ibuf_cc),isize_stg(idims),&
247 mpi_double_precision,ipe_neighbor,itag_cc,&
248 icomm,cc_recvreq(irecv_cc),ierrmpi)
249 ibuf_cc=ibuf_cc+isize_stg(idims)
254 if (neighbor_type(mi^d,igrid)==4.and.&
255 neighbor_type(mh^d,igrid)==3.and.&
256 neighbor_pole(mi^d,igrid)==0)
then
258 {
do ic^db=1+int((1-mi^db)/2),2-int((1+mi^db)/2)
259 inc^db=2*mi^db+ic^db\}
260 ipe_neighbor=neighbor_child(2,inc^d,igrid)
261 if (mype/=ipe_neighbor)
then
263 itag_cc=4**^nd*(igrid-1)+{inc^d*4**(^d-1)+}
264 call mpi_irecv(recvbuffer_cc(ibuf_cc),isize_stg(idims),&
265 mpi_double_precision,ipe_neighbor,itag_cc,&
266 icomm,cc_recvreq(irecv_cc),ierrmpi)
267 ibuf_cc=ibuf_cc+isize_stg(idims)
284 integer,
intent(in) :: idim^lim
286 integer :: idims, iside, i^
d, ic^
d, inc^
d, ix^
d, ixco^
d, nxco^
d, iw
287 integer :: ineighbor, ipe_neighbor, igrid, iigrid, ibuf_send_next
288 integer :: idir, ibuf_cc_send_next, pi^
d, ph^
d, mi^
d, mh^
d
290 fc_sendreq = mpi_request_null
294 cc_sendreq=mpi_request_null
299 do iigrid=1,igridstail; igrid=igrids(iigrid);
304 i^dd=
kr(^dd,^
d)*(2*iside-3);
306 if (neighbor_pole(i^dd,igrid)/=0) cycle
308 if (neighbor_type(i^dd,igrid)==neighbor_coarse)
then
310 ineighbor=neighbor(1,i^dd,igrid)
311 ipe_neighbor=neighbor(2,i^dd,igrid)
312 if (ipe_neighbor/=
mype)
then
313 ic^dd=1+modulo(
node(
pig^dd_,igrid)-1,2);
314 inc^
d=-2*i^
d+ic^
d^
d%inc^dd=ic^dd;
315 itag=4**^nd*(ineighbor-1)+{inc^dd*4**(^dd-1)+}
319 ibuf_send_next=ibuf_send+isize(^
d)
320 sendbuffer(ibuf_send:ibuf_send_next-isize_stg(^
d)-1)=&
321 reshape(
pflux(iside,^
d,igrid)%flux,(/isize(^
d)-isize_stg(^
d)/))
323 sendbuffer(ibuf_send_next-isize_stg(^
d):ibuf_send_next-1)=&
324 reshape(
pflux(iside,^
d,igrid)%edge,(/isize_stg(^
d)/))
325 call mpi_isend(sendbuffer(ibuf_send),isize(^
d), &
326 mpi_double_precision,ipe_neighbor,itag, &
328 ibuf_send=ibuf_send_next
330 call mpi_isend(
pflux(iside,^
d,igrid)%flux,isize(^
d), &
331 mpi_double_precision,ipe_neighbor,itag, &
339 pi^dd=i^dd+
kr(idir,^dd);
340 mi^dd=i^dd-
kr(idir,^dd);
341 ph^dd=pi^dd-
kr(idims,^dd)*(2*iside-3);
342 mh^dd=mi^dd-
kr(idims,^dd)*(2*iside-3);
344 if (neighbor_type(pi^dd,igrid)==2.and.&
345 neighbor_type(ph^dd,igrid)==2.and.&
346 mype/=neighbor(2,pi^dd,igrid).and.&
347 neighbor_pole(pi^dd,igrid)==0)
then
349 ineighbor=neighbor(1,pi^dd,igrid)
350 ipe_neighbor=neighbor(2,pi^dd,igrid)
351 ic^dd=1+modulo(
node(
pig^dd_,igrid)-1,2);
352 inc^dd=-2*pi^dd+ic^dd;
353 itag_cc=4**^nd*(ineighbor-1)+{inc^dd*4**(^dd-1)+}
356 ibuf_cc_send_next=ibuf_cc_send+isize_stg(^
d)
357 sendbuffer_cc(ibuf_cc_send:ibuf_cc_send_next-1)=&
358 reshape(
pflux(iside,^
d,igrid)%edge,shape=(/isize_stg(^
d)/))
359 call mpi_isend(sendbuffer_cc(ibuf_cc_send),isize_stg(^
d),&
360 mpi_double_precision,ipe_neighbor,itag_cc,&
362 ibuf_cc_send=ibuf_cc_send_next
365 if (neighbor_type(mi^dd,igrid)==2.and.&
366 neighbor_type(mh^dd,igrid)==2.and.&
367 mype/=neighbor(2,mi^dd,igrid).and.&
368 neighbor_pole(mi^dd,igrid)==0)
then
370 ineighbor=neighbor(1,mi^dd,igrid)
371 ipe_neighbor=neighbor(2,mi^dd,igrid)
372 ic^dd=1+modulo(
node(
pig^dd_,igrid)-1,2);
373 inc^dd=-2*pi^dd+ic^dd;
374 inc^dd=-2*mi^dd+ic^dd;
375 itag_cc=4**^nd*(ineighbor-1)+{inc^dd*4**(^dd-1)+}
378 ibuf_cc_send_next=ibuf_cc_send+isize_stg(^
d)
379 sendbuffer_cc(ibuf_cc_send:ibuf_cc_send_next-1)=&
380 reshape(
pflux(iside,^
d,igrid)%edge,shape=(/isize_stg(^
d)/))
381 call mpi_isend(sendbuffer_cc(ibuf_cc_send),isize_stg(^
d),&
382 mpi_double_precision,ipe_neighbor,itag_cc,&
384 ibuf_cc_send=ibuf_cc_send_next
399 integer :: iigrid, igrid, iside, i^
d, nx^
d, nxco^
d
400 integer :: idir,idim,pi^
d, mi^
d, ph^
d, mh^
d
402 nx^
d=ixmhi^
d-ixmlo^
d+1;
405 do iigrid=1,igridstail; igrid=igrids(iigrid);
410 i^dd=
kr(^dd,^
d)*(2*iside-3);
412 if (neighbor_pole(i^dd,igrid)/=0) cycle
414 select case (neighbor_type(i^dd,igrid))
416 allocate(
pflux(iside,^
d,igrid)%flux(1^
d%1:nx^dd,1:nwflux))
418 case(neighbor_coarse)
419 allocate(
pflux(iside,^
d,igrid)%flux(1^
d%1:nxco^dd,1:nwflux))
421 case(neighbor_sibling)
426 pi^dd=i^dd+
kr(idir,^dd);
427 mi^dd=i^dd-
kr(idir,^dd);
428 ph^dd=pi^dd-
kr(^
d,^dd)*(2*iside-3);
429 mh^dd=mi^dd-
kr(^
d,^dd)*(2*iside-3);
430 if ((neighbor_type(pi^dd,igrid)==4&
431 .and.neighbor_type(ph^dd,igrid)==3)&
432 .or.(neighbor_type(mi^dd,igrid)==4&
433 .and.neighbor_type(mh^dd,igrid)==3))
then
434 allocate(
pflux(iside,^
d,igrid)%edge(1^
d%0:nx^dd,1:
ndim-1))
448 integer :: iigrid, igrid, iside
450 do iigrid=1,igridstail; igrid=igrids(iigrid);
452 if (
associated(
pflux(iside,^
d,igrid)%flux))
then
453 deallocate(
pflux(iside,^
d,igrid)%flux)
454 nullify(
pflux(iside,^
d,igrid)%flux)
456 if (
associated(
pflux(iside,^
d,igrid)%edge))
then
457 deallocate(
pflux(iside,^
d,igrid)%edge)
458 nullify(
pflux(iside,^
d,igrid)%edge)
468 integer,
intent(in) :: idim^lim, nw0, nwfluxin
471 integer :: iigrid, igrid, idims, iside, iotherside, i^
d, ic^
d, inc^
d, ix^
l
472 integer :: nxco^
d, iw, ix, ipe_neighbor, ineighbor, nbuf, ibufnext, nw1
473 double precision :: cofiratio
479 cofiratio=one/dble(2**
ndim)
483 call mpi_waitall(nrecv,fc_recvreq,fc_recvstat,
ierrmpi)
487 nxco^
d=(ixmhi^
d-ixmlo^
d+1)/2;
490 do iigrid=1,igridstail; igrid=igrids(iigrid);
495 i^dd=
kr(^dd,^
d)*(2*iside-3);
497 if (neighbor_pole(i^dd,igrid)/=0) cycle
499 if (neighbor_type(i^dd,igrid)/=4) cycle
503 if (.not.neighbor_active(i^dd,igrid).or.&
504 .not.neighbor_active(0^dd&,igrid) )
then
505 {
do ic^ddb=1+int((1-i^ddb)/2),2-int((1+i^ddb)/2)
506 inc^ddb=2*i^ddb+ic^ddb\}
507 ipe_neighbor=neighbor_child(2,inc^dd,igrid)
508 if (ipe_neighbor/=
mype)
then
509 ibufnext=ibuf+isize(^
d)
525 if (slab_uniform)
then
526 psb(igrid)%w(ix^d%ixM^t,nw0:nw1) &
527 = psb(igrid)%w(ix^d%ixM^t,nw0:nw1) &
528 -
pflux(iside,^d,igrid)%flux(1^d%:^dd&,1:nwfluxin)
531 psb(igrid)%w(ix^d%ixM^t,iw)=psb(igrid)%w(ix^d%ixM^t,iw)&
532 -
pflux(iside,^d,igrid)%flux(1^d%:^dd&,iw-nw0+1) &
533 /ps(igrid)%dvolume(ix^d%ixM^t)
539 {
do ic^ddb=1+int((1-i^ddb)/2),2-int((1+i^ddb)/2)
540 inc^ddb=2*i^ddb+ic^ddb\}
541 ineighbor=neighbor_child(1,inc^dd,igrid)
542 ipe_neighbor=neighbor_child(2,inc^dd,igrid)
543 ixmin^d=ix^d%ixmin^dd=ixmlo^dd+(ic^dd-1)*nxco^dd;
544 ixmax^d=ix^d%ixmax^dd=ixmin^dd-1+nxco^dd;
545 if (ipe_neighbor==mype)
then
547 if (slab_uniform)
then
548 psb(igrid)%w(ix^s,nw0:nw1) &
549 = psb(igrid)%w(ix^s,nw0:nw1) &
550 +
pflux(iotherside,^d,ineighbor)%flux(:^dd&,1:nwfluxin)&
554 psb(igrid)%w(ix^s,iw)=psb(igrid)%w(ix^s,iw) &
555 +
pflux(iotherside,^d,ineighbor)%flux(:^dd&,iw-nw0+1) &
556 /ps(igrid)%dvolume(ix^s)
560 if (slab_uniform)
then
561 ibufnext=ibuf+isize(^d)
562 if(stagger_grid) ibufnext=ibufnext-isize_stg(^d)
563 psb(igrid)%w(ix^s,nw0:nw1) &
564 = psb(igrid)%w(ix^s,nw0:nw1)+cofiratio &
565 *reshape(source=recvbuffer(ibuf:ibufnext-1), &
566 shape=shape(psb(igrid)%w(ix^s,nw0:nw1)))
569 ibufnext=ibuf+isize(^d)
570 if(stagger_grid)
then
571 nbuf=(isize(^d)-isize_stg(^d))/nwfluxin
573 nbuf=isize(^d)/nwfluxin
576 psb(igrid)%w(ix^s,iw)=psb(igrid)%w(ix^s,iw) &
577 +reshape(source=recvbuffer(ibuf:ibufnext-1), &
578 shape=shape(psb(igrid)%w(ix^s,iw))) &
579 /ps(igrid)%dvolume(ix^s)
592 call mpi_waitall(nsend,fc_sendreq,fc_sendstat,ierrmpi)
600 integer,
intent(in) :: igrid, idim^lim, nwfluxin
601 double precision,
intent(in) :: fc(ixg^t,1:nwfluxin,1:
ndim)
603 integer :: idims, iside, i^
d, ic^
d, inc^
d, ix^
d, ixco^
d, nxco^
d, iw
609 i^dd=
kr(^dd,^
d)*(2*iside-3);
611 if (neighbor_pole(i^dd,igrid)/=0) cycle
613 select case (neighbor_type(i^dd,igrid))
617 pflux(iside,^
d,igrid)%flux(1^
d%:^dd&,1:nwfluxin) = &
620 pflux(iside,^
d,igrid)%flux(1^
d%:^dd&,1:nwfluxin) = &
621 fc(ixmhi^
d^
d%ixM^t,1:nwfluxin,^
d)
623 case (neighbor_coarse)
628 {
do ixco^ddb=1,nxco^ddb\}
630 pflux(iside,^
d,igrid)%flux(ixco^dd,iw) &
631 = {^noonedsum}(fc(ix^
d^
d%ix^dd:ix^dd+1,iw,^
d))
636 {
do ixco^ddb=1,nxco^ddb\}
637 ix^d=ixmhi^d^d%ix^dd=ixmlo^dd+2*(ixco^dd-1);
638 pflux(iside,^d,igrid)%flux(ixco^dd,iw) &
639 =-{^noonedsum}(fc(ix^d^d%ix^dd:ix^dd+1,iw,^d))
653 integer,
intent(in) :: igrid, ixi^
l, idim^lim
654 double precision,
intent(in) :: fe(ixi^s,
sdim:3)
656 integer :: idims, idir, iside, i^
d
657 integer :: pi^
d, mi^
d, ph^
d, mh^
d
663 i^
d=
kr(^
d,idims)*(2*iside-3);
664 if (neighbor_pole(i^
d,igrid)/=0) cycle
665 select case (neighbor_type(i^
d,igrid))
670 case(neighbor_coarse)
673 case(neighbor_sibling)
678 pi^
d=i^
d+
kr(idir,^
d);
679 mi^
d=i^
d-
kr(idir,^
d);
680 ph^
d=pi^
d-
kr(idims,^
d)*(2*iside-3);
681 mh^
d=mi^
d-
kr(idims,^
d)*(2*iside-3);
682 if (neighbor_type(pi^
d,igrid)==4&
683 .and.neighbor_type(ph^
d,igrid)==3)
then
686 if (neighbor_type(mi^
d,igrid)==4&
687 .and.neighbor_type(mh^
d,igrid)==3)
then
700 integer :: igrid,ixI^L,idims,iside
702 double precision,
intent(in) :: fE(ixI^S,sdim:3)
704 integer :: idir1,idir2
705 integer :: ixE^L,ixF^L{^IFTHREED, jxF^L,}, nx^D,nxCo^D
707 nx^d=ixmhi^d-ixmlo^d+1;
718 idir2=mod(idir1+idims-1,3)+1}
724 ixfmin^d=ixmlo^d-1+
kr(^d,idir2);
725 ixfmax^d=ixmhi^d-
kr(^d,idir2);
727 jxf^l=ixf^l+
kr(^d,idir2);}
729 ixemin^d=0+
kr(^d,idir2);
733 ixemin^d=1;ixemax^d=1;
737 {^ifthreedjxfmax^d=ixfmin^d}
740 {^ifthreedjxfmin^d=ixfmax^d}
745 pflux(iside,idims,igrid)%edge(ixe^s,idir1)=&
746 fe(ixfmin^d:ixfmax^d:2,idir2){^ifthreed +&
747 fe(jxfmin^d:jxfmax^d:2,idir2)};
751 ixfmin^d=ixmlo^d-1+
kr(^d,idir2);
753 ixemin^d=0+
kr(^d,idir2);
758 ixemin^d=1;ixemax^d=1;
768 pflux(iside,idims,igrid)%edge(ixe^s,idir1)=fe(ixf^s,idir2)
780 integer,
intent(in) :: idim^lim
782 integer :: iigrid, igrid, idims, iside, iotherside, i^
d, ic^
d, inc^
d, ixmc^
l
783 integer :: nbuf, ibufnext
784 integer :: ibufnext_cc
785 integer :: pi^
d, mi^
d, ph^
d, mh^
d
786 integer :: ixe^
l(1:3), ixte^
l, ixf^
l(1:
ndim), ixfe^
l(1:3)
787 integer :: nx^
d, idir, ix, ipe_neighbor, ineighbor
788 logical :: pcorner(1:
ndim),mcorner(1:
ndim)
791 call mpi_waitall(nrecv_ct,cc_recvreq,cc_recvstat,
ierrmpi)
797 do iigrid=1,igridstail; igrid=igrids(iigrid);
800 i^
d=
kr(^
d,idims)*(2*iside-3);
801 if (neighbor_pole(i^
d,igrid)/=0) cycle
802 select case(neighbor_type(i^
d,igrid))
805 if (.not.neighbor_active(i^
d,igrid).or.&
806 .not.neighbor_active(0^
d&,igrid) )
then
807 {
do ic^db=1+int((1-i^db)/2),2-int((1+i^db)/2)
808 inc^db=2*i^db+ic^db\}
809 ipe_neighbor=neighbor_child(2,inc^
d,igrid)
811 if (ipe_neighbor/=
mype)
then
812 ibufnext=ibuf+isize(idims)
823 pi^d=i^d+kr(idir,^d);
824 mi^d=i^d-kr(idir,^d);
825 ph^d=pi^d-kr(idims,^d)*(2*iside-3);
826 mh^d=mi^d-kr(idims,^d)*(2*iside-3);
827 if (neighbor_type(ph^d,igrid)==neighbor_fine) pcorner(idir)=.true.
828 if (neighbor_type(mh^d,igrid)==neighbor_fine) mcorner(idir)=.true.
831 call set_ix_circ(ixf^l,ixte^l,ixe^l,ixfe^l,igrid,idims,iside,.false.,.false.,0^d&,pcorner,mcorner)
833 call add_sub_circ(ixf^l,ixte^l,ixe^l,ixfe^l,
pflux(iside,idims,igrid)%edge,idims,iside,.false.,psuse(igrid))
835 {
do ic^db=1+int((1-i^db)/2),2-int((1+i^db)/2)
836 inc^db=2*i^db+ic^db\}
837 ineighbor=neighbor_child(1,inc^d,igrid)
838 ipe_neighbor=neighbor_child(2,inc^d,igrid)
840 nx^d=(ixmhi^d-ixmlo^d+1)/2;
841 call set_ix_circ(ixf^l,ixte^l,ixe^l,ixfe^l,igrid,idims,iside,.true.,.false.,inc^d,pcorner,mcorner)
842 if (ipe_neighbor==mype)
then
843 call add_sub_circ(ixf^l,ixte^l,ixe^l,ixfe^l,
pflux(iotherside,idims,ineighbor)%edge,idims,iside,.true.,psuse(igrid))
845 ibufnext=ibuf+isize(idims)
847 reshape(source=recvbuffer(ibufnext-isize_stg(idims):ibufnext-1),&
848 shape=(/ ixtemax^d-ixtemin^d+1 ,^nd-1 /)),&
849 idims,iside,.true.,psuse(igrid))
854 case(neighbor_sibling)
860 pi^d=i^d+kr(idir,^d);
861 mi^d=i^d-kr(idir,^d);
862 ph^d=pi^d-kr(idims,^d)*(2*iside-3);
863 mh^d=mi^d-kr(idims,^d)*(2*iside-3);
864 if (neighbor_type(pi^d,igrid)==neighbor_fine&
865 .and.neighbor_type(ph^d,igrid)==neighbor_sibling&
866 .and.neighbor_pole(pi^d,igrid)==0)
then
870 call set_ix_circ(ixf^l,ixte^l,ixe^l,ixfe^l,igrid,idims,iside,.false.,.true.,0^d&,pcorner,mcorner)
872 call add_sub_circ(ixf^l,ixte^l,ixe^l,ixfe^l,
pflux(iside,idims,igrid)%edge,idims,iside,.false.,psuse(igrid))
875 {^ifthreed
do ix=1,2}
876 inc^d=kr(idims,^d)*3*(iside-1)+3*kr(idir,^d){^ifthreed+kr(6-idir-idims,^d)*ix};
877 ineighbor=neighbor_child(1,inc^d,igrid)
878 ipe_neighbor=neighbor_child(2,inc^d,igrid)
881 call set_ix_circ(ixf^l,ixte^l,ixe^l,ixfe^l,igrid,idims,iside,.true.,.true.,inc^d,pcorner,mcorner)
883 if (ipe_neighbor==mype)
then
884 call add_sub_circ(ixf^l,ixte^l,ixe^l,ixfe^l,
pflux(iotherside,idims,ineighbor)%edge,idims,iside,.true.,psuse(igrid))
886 ibufnext_cc=ibuf_cc+isize_stg(idims)
888 reshape(source=recvbuffer_cc(ibuf_cc:ibufnext_cc-1),&
889 shape=(/ ixtemax^d-ixtemin^d+1 ,^nd-1 /)),&
890 idims,iside,.true.,psuse(igrid))
895 pcorner(idir)=.false.
898 if (neighbor_type(mi^d,igrid)==neighbor_fine&
899 .and.neighbor_type(mh^d,igrid)==neighbor_sibling&
900 .and.neighbor_pole(mi^d,igrid)==0)
then
904 call set_ix_circ(ixf^l,ixte^l,ixe^l,ixfe^l,igrid,idims,iside,.false.,.true.,0^d&,pcorner,mcorner)
906 call add_sub_circ(ixf^l,ixte^l,ixe^l,ixfe^l,
pflux(iside,idims,igrid)%edge,idims,iside,.false.,psuse(igrid))
909 {^ifthreed
do ix=1,2}
910 inc^d=kr(idims,^d)*3*(iside-1){^ifthreed+kr(6-idir-idims,^d)*ix};
911 ineighbor=neighbor_child(1,inc^d,igrid)
912 ipe_neighbor=neighbor_child(2,inc^d,igrid)
915 call set_ix_circ(ixf^l,ixte^l,ixe^l,ixfe^l,igrid,idims,iside,.true.,.true.,inc^d,pcorner,mcorner)
917 if (ipe_neighbor==mype)
then
918 call add_sub_circ(ixf^l,ixte^l,ixe^l,ixfe^l,
pflux(iotherside,idims,ineighbor)%edge,idims,iside,.true.,psuse(igrid))
920 ibufnext_cc=ibuf_cc+isize_stg(idims)
922 reshape(source=recvbuffer_cc(ibuf_cc:ibufnext_cc-1),&
923 shape=(/ ixtemax^d-ixtemin^d+1 ,^nd-1 /)),&
924 idims,iside,.true.,psuse(igrid))
929 mcorner(idir)=.false.
937 if (nsend_ct>0)
call mpi_waitall(nsend_ct,cc_sendreq,cc_sendstat,ierrmpi)
946 subroutine set_ix_circ(ixF^L,ixtE^L,ixE^L,ixfE^L,igrid,idims,iside,add,CoCorner,inc^D,pcorner,mcorner)
949 integer,
intent(in) :: igrid,idims,iside,inc^D
950 logical,
intent(in) :: add,CoCorner
951 logical,
intent(inout) :: pcorner(1:ndim),mcorner(1:ndim)
952 integer,
intent(out) :: ixF^L(1:ndim),ixtE^L,ixE^L(1:3),ixfE^L(1:3)
953 integer :: icor^D,idim1,idir,nx^D,middle^D
967 ixtfemin^d=ixmlo^d-1;
971 nx^d=(ixmhi^d-ixmlo^d+1)/2;
973 nx^d=ixmhi^d-ixmlo^d+1;
981 ixtemin^d=1;ixtemax^d=1;
982 if (iside==1) ixtfemax^d=ixtfemin^d;
983 if (iside==2) ixtfemin^d=ixtfemax^d;
991 ixfmin^d(idim1)=ixmlo^d-
kr(idim1,^d);
992 ixfmax^d(idim1)=ixmhi^d;
997 ixfmax^d(idim1)=ixfmin^d(idim1)
999 ixfmin^d(idim1)=ixfmax^d(idim1)
1007 middle^d=(ixmhi^d+ixmlo^d)/2;
1010 ixfmax^d(:)=middle^d
1014 ixfmin^d(:)=middle^d+1
1021 ixfemax^d(idim1)=ixtfemax^d;
1022 ixemax^d(idim1)=ixtemax^d;
1023 ixfemin^d(idim1)=ixtfemin^d+
kr(idim1,^d);
1024 ixemin^d(idim1)=ixtemin^d+
kr(idim1,^d);
1029 do idim1=idims+1,ndim
1030 if (pcorner(idim1))
then
1032 if (idir==6-idim1-idims)
then
1036 {
if (^d==idim1)
then
1037 ixfemin^d(idir)=ixfemax^d(idir)
1039 ixemax^d(idir) =ixemin^d(idir)
1041 ixemin^d(idir) =ixemax^d(idir)
1052 if (mcorner(idim1))
then
1054 if (idir==6-idim1-idims)
then
1055 {
if (^d==idim1)
then
1056 ixfemax^d(idir)=ixfemin^d(idir)
1058 ixemin^d(idir) =ixemax^d(idir)
1060 ixemax^d(idir) =ixemin^d(idir)
1080 {
if((idims.gt.^d).and.pcorner(^d))
then
1081 if((.not.add).or.(inc^d==2))
then
1084 if ((idir==idims).or.(idir==^d)) cycle
1085 ixfemax^d(idir)=ixfemax^d(idir)-1
1086 ixemax^d(idir)=ixemax^d(idir)-1
1090 {
if((idims>^d).and.mcorner(^d))
then
1091 if((.not.add).or.(inc^d==1))
then
1094 if ((idir==idims).or.(idir==^d)) cycle
1095 ixfemin^d(idir)=ixfemin^d(idir)+1
1096 ixemin^d(idir)=ixemin^d(idir)+1
1108 integer,
intent(in) :: idims,iside
1109 integer :: ixF^L(1:ndim),ixtE^L,ixE^L(1:3),ixfE^L(1:3)
1110 double precision :: edge(ixtE^S,1:ndim-1)
1111 logical,
intent(in) :: add
1113 double precision :: fE(ixG^T,sdim:3)
1114 double precision :: circ(ixG^T,1:ndim)
1115 integer :: idim1,idim2,idir,middle^D
1116 integer :: ixfEC^L,ixEC^L
1117 integer :: ix^L,hx^L,ixC^L,hxC^L
1128 idir=mod(idim1+idims-1,3)+1}
1131 ixfec^l=ixfe^l(idir);
1133 fe(ixfec^s,idir)=edge(ixec^s,idim1)
1141 if (
lvc(idim1,idim2,idir)==0) cycle
1144 hxc^l=ixc^l-
kr(idim2,^d);
1145 if(idim1==idims)
then
1146 circ(ixc^s,idim1)=circ(ixc^s,idim1)+
lvc(idim1,idim2,idir)&
1147 *(fe(ixc^s,idir)-fe(hxc^s,idir))
1151 circ(ixc^s,idim1)=circ(ixc^s,idim1)+
lvc(idim1,idim2,idir)*fe(ixc^s,idir)
1153 circ(ixc^s,idim1)=circ(ixc^s,idim1)-
lvc(idim1,idim2,idir)*fe(hxc^s,idir)
1163 where(s%surfaceC(ixc^s,idim1)>1.0d-9*s%dvolume(ixc^s))
1164 circ(ixc^s,idim1)=circ(ixc^s,idim1)/s%surfaceC(ixc^s,idim1)
1166 circ(ixc^s,idim1)=zero
1170 s%ws(ixc^s,idim1)=s%ws(ixc^s,idim1)-circ(ixc^s,idim1)
1172 s%ws(ixc^s,idim1)=s%ws(ixc^s,idim1)+circ(ixc^s,idim1)
Module for flux conservation near refinement boundaries.
subroutine, public recvflux(idimLIM)
subroutine, public fix_edges(psuse, idimLIM)
subroutine, public sendflux(idimLIM)
subroutine set_ix_circ(ixFL, ixtEL, ixEL, ixfEL, igrid, idims, iside, add, CoCorner, incD, pcorner, mcorner)
This routine sets the indexes for the correction of the circulation according to several different ca...
subroutine, public fix_conserve(psb, idimLIM, nw0, nwfluxin)
subroutine, public deallocatebflux
subroutine add_sub_circ(ixFL, ixtEL, ixEL, ixfEL, edge, idims, iside, add, s)
type(fluxalloc), dimension(:,:,:), allocatable, public pflux
store flux to fix conservation
subroutine, public store_edge(igrid, ixIL, fE, idimLIM)
subroutine flux_to_edge(igrid, ixIL, idims, iside, restrict, fE)
subroutine, public init_comm_fix_conserve(idimLIM, nwfluxin)
subroutine, public allocatebflux
subroutine, public store_flux(igrid, fC, idimLIM, nwfluxin)
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer ixghi
Upper index of grid block arrays.
integer, dimension(3, 3, 3) lvc
Levi-Civita tensor.
integer, dimension(3, 3) kr
Kronecker delta tensor.
integer, parameter ndim
Number of spatial dimensions for grid variables.
logical stagger_grid
True for using stagger grid.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
double precision, dimension(:), allocatable, parameter d
integer ierrmpi
A global MPI error return code.
integer nghostcells
Number of ghost cells surrounding a grid.
integer, parameter sdim
starting dimension for electric field
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
integer max_blocks
The maximum number of grid blocks in a processor.
integer, dimension(:,:), allocatable node