16 integer :: iigrid, igrid, jgrid, kgrid, isave, my_isafety
17 integer,
allocatable,
dimension(:,:) :: isafety
21 integer,
parameter :: nsafety = 1
26 if (.not.
allocated(isafety)) &
30 neighbor_active = .true.
38 do iigrid=1,igridstail; igrid=igrids(iigrid);
39 userflag = igrid_active(igrid)
40 if (userflag <= 0)
then
42 igrids_active(jgrid)=igrid
45 igrids_passive(kgrid)=igrid
47 isafety(igrid,
mype) = userflag
50 igridstail_active = jgrid
51 igridstail_passive = kgrid
54 if (userflag == -1)
return
60 call mpi_allgather(isafety(:,
mype),
max_blocks,mpi_integer,isafety,&
65 do iigrid=1,igridstail_passive; igrid=igrids_passive(iigrid);
66 if ( isafety(igrid,
mype) /= isave) cycle
68 if(min_isafety_neighbor(igrid) >= isafety(igrid,
mype))
then
70 isafety(igrid,
mype)=isafety(igrid,
mype)+1
75 call mpi_allgather(isafety(:,
mype),
max_blocks,mpi_integer,isafety,&
82 do iigrid=1,igridstail; igrid=igrids(iigrid);
83 if (isafety(igrid,
mype) <= nsafety)
then
85 igrids_active(jgrid)=igrid
88 igrids_passive(kgrid)=igrid
93 igridstail_active = jgrid
94 igridstail_passive = kgrid
100 if (isafety(igrid,ipe) == -1) cycle
103 if (isafety(igrid,ipe) > nsafety)
then
104 tree%node%active=.false.
106 tree%node%active=.true.
123 integer,
intent(in) :: igrid
124 integer :: my_neighbor_type, i^D, isafety_neighbor
129 if (i^d==0|.and.)
then
130 if (isafety(igrid,
mype) > nsafety) &
131 neighbor_active(i^d,igrid) = .false.
133 my_neighbor_type=neighbor_type(i^d,igrid)
135 select case (my_neighbor_type)
136 case (neighbor_boundary)
137 isafety_neighbor = nsafety+1
138 case (neighbor_coarse)
139 isafety_neighbor = isafety_fc(i^d,igrid)
140 case (neighbor_sibling)
141 isafety_neighbor = isafety_srl(i^d,igrid)
143 isafety_neighbor = isafety_cf_max(i^d,igrid)
146 if (isafety_neighbor > nsafety) &
147 neighbor_active(i^d,igrid) = .false.
153 integer function min_isafety_neighbor(igrid)
155 integer,
intent(in) :: igrid
156 integer :: my_neighbor_type, i^D
159 min_isafety_neighbor = biginteger
162 if (i^d==0|.and.) cycle
163 my_neighbor_type=neighbor_type(i^d,igrid)
165 select case (my_neighbor_type)
166 case (neighbor_coarse)
167 min_isafety_neighbor = min(isafety_fc(i^d,igrid),&
168 min_isafety_neighbor)
169 case (neighbor_sibling)
170 min_isafety_neighbor = min(isafety_srl(i^d,igrid),&
171 min_isafety_neighbor)
173 min_isafety_neighbor = min(isafety_cf_min(i^d,igrid),&
174 min_isafety_neighbor)
179 end function min_isafety_neighbor
181 integer function isafety_fc(i^D,igrid)
183 integer,
intent(in) :: i^D, igrid
184 integer :: ineighbor, ipe_neighbor
186 ineighbor=neighbor(1,i^d,igrid)
187 ipe_neighbor=neighbor(2,i^d,igrid)
189 isafety_fc = isafety(ineighbor,ipe_neighbor)
191 end function isafety_fc
193 integer function isafety_srl(i^D,igrid)
195 integer,
intent(in) :: i^D, igrid
196 integer :: ineighbor, ipe_neighbor
198 ineighbor=neighbor(1,i^d,igrid)
199 ipe_neighbor=neighbor(2,i^d,igrid)
201 isafety_srl = isafety(ineighbor,ipe_neighbor)
203 end function isafety_srl
205 integer function isafety_cf_min(i^D,igrid)
207 integer,
intent(in) :: i^D, igrid
208 integer :: ic^D, inc^D
209 integer :: ineighbor, ipe_neighbor
212 isafety_cf_min = biginteger
214 {
do ic^db=1+int((1-i^db)/2),2-int((1+i^db)/2)
217 ineighbor = neighbor_child(1,inc^d,igrid)
218 ipe_neighbor = neighbor_child(2,inc^d,igrid)
220 isafety_cf_min = min(isafety_cf_min,isafety(ineighbor,ipe_neighbor))
224 end function isafety_cf_min
226 integer function isafety_cf_max(i^D,igrid)
228 integer,
intent(in) :: i^D, igrid
229 integer :: ic^D, inc^D
230 integer :: ineighbor, ipe_neighbor
233 isafety_cf_max = - biginteger
235 {
do ic^db=1+int((1-i^db)/2),2-int((1+i^db)/2)
238 ineighbor = neighbor_child(1,inc^d,igrid)
239 ipe_neighbor = neighbor_child(2,inc^d,igrid)
241 isafety_cf_max = max(isafety_cf_max,isafety(ineighbor,ipe_neighbor))
245 end function isafety_cf_max
250 integer function igrid_active(igrid)
254 integer,
intent(in) :: igrid
255 integer :: ixO^L, flag
257 ixo^l=ixg^
ll^lsubnghostcells;
265 end function igrid_active
subroutine set_neighbor_state(igrid)
Module with basic grid data structures.
type(tree_node_ptr), dimension(:,:), allocatable, save igrid_to_node
Array to go from an [igrid, ipe] index to a node pointer.
This module contains definitions of global parameters and variables and some generic functions/subrou...
double precision global_time
The global simulation time.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
integer ierrmpi
A global MPI error return code.
integer npe
The number of MPI tasks.
integer max_blocks
The maximum number of grid blocks in a processor.
subroutine, public selectgrids
Module with all the methods that users can customize in AMRVAC.
procedure(flag_grid), pointer usr_flag_grid