Commit 0286c131 authored by Roy Fabrice's avatar Roy Fabrice
Browse files

use cell min and max level

cells too large or too small are removed
parent 8f391d95
......@@ -78,7 +78,7 @@ program amr2cell_hdf5
call ramses_output%Deallocate()
call cells_array%Clean(amr2cell_hdf5_parameters%cube_level)
call cells_array%Clean(amr2cell_hdf5_parameters)
call cubes_array%Init(amr2cell_hdf5_parameters, ramses_info)
......
......@@ -51,6 +51,7 @@ module cells_array_m
procedure Clean => Clean_unused_cells
procedure, private :: Remove_duplicate_cells
procedure, private :: Remove_large_cells
procedure, private :: Remove_small_cells
procedure Sort => Sort_cells_array
procedure, private :: Sort_heapify_cells
procedure, private :: Sort_sink_cells
......@@ -89,14 +90,17 @@ contains
end subroutine Allocate_cells_array
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Clean_unused_cells(this, cube_level)
subroutine Clean_unused_cells(this, amr2cell_hdf5_parameters)
use amr2cell_hdf5_parameters_m, only : amr2cell_hdf5_parameters_t
type(amr2cell_hdf5_parameters_t), intent(in) :: amr2cell_hdf5_parameters
class(cells_array_t),intent(inout) :: this
integer, intent(in) :: cube_level
call this%Sort()
call this%Remove_duplicate_cells()
call this%Remove_large_cells(cube_level)
call this%Remove_large_cells(amr2cell_hdf5_parameters%cell_level_min)
call this%Remove_small_cells(amr2cell_hdf5_parameters%cell_level_max)
end subroutine Clean_unused_cells
......@@ -383,10 +387,10 @@ contains
end subroutine Remove_duplicate_cells
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Remove_large_cells(this, cube_level)
subroutine Remove_large_cells(this, level_min)
class(cells_array_t),intent(inout) :: this
integer ,intent(in) :: cube_level
integer ,intent(in) :: level_min
integer :: icell
integer :: n_large
......@@ -401,7 +405,7 @@ contains
n_large = 0
do icell = 1, this%ncells
if(this%elts(icell)%level < cube_level ) then
if(this%elts(icell)%level < level_min ) then
n_large = n_large + 1
else
exit
......@@ -428,6 +432,52 @@ contains
end subroutine Remove_large_cells
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Remove_small_cells(this, level_max)
class(cells_array_t),intent(inout) :: this
integer, intent(in) :: level_max
integer :: icell
integer :: n_small
integer(kind=IDKIND) :: nc
integer :: nntp, nps
type(cells_array_t) :: tmp
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Remove_small_cells begins on process ', mpi_process%rank
#endif
call timer%Set_ref()
n_small = 0
do icell = 1, this%ncells
if(this%elts(icell)%level > level_max ) then
n_small = n_small + 1
else
exit
end if
enddo
nntp = this%elts(1)%n_non_thermal_pressures
nps = this%elts(1)%n_passive_scalars
nc = this%ncells - n_small
call tmp%Allocate(nntp, nps, nc)
tmp%elts(1:tmp%ncells) = this%elts(1:tmp%ncells)
if(allocated(this%elts)) then
call this%Deallocate()
end if
call move_alloc(tmp%elts,this%elts)
this%ncells=tmp%ncells
call timer%Inc_comp()
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'number of cells after small ones removed: ', this%ncells
write(ERROR_UNIT,'(a,i0)') 'Remove_small_cells ends on process ', mpi_process%rank
#endif
end subroutine Remove_small_cells
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Sort_cells_array(this)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment