hyperion-rt / hyperion

Hyperion Radiative Transfer Code
http://www.hyperion-rt.org
BSD 2-Clause "Simplified" License
52 stars 26 forks source link

Issues with AMR grids: grid creation #203

Open smarandeshmukh opened 6 years ago

smarandeshmukh commented 6 years ago

Hi,

I was trying to create my own AMR grid for some testing purposes. I have frequently run into the following problem. As an example, I create an AMR grid with two levels: (a) Level 1 -> One large cube of unit length (e.g. 1pc) (b) Level 2 -> this large cube has been subdivided into 8 smaller cubes similar to an octree. Hyperion complains while running the fortran binaries, saying that the walls are not aligned.

############################################################ An example: level = amr.add_level() grid = level.add_grid() grid.xmin, grid.xmax, grid.ymin, grid.ymax, grid.zmin, grid.zmax = 0, pc, 0, pc, 0, pc #Level 1 grid.nx,...,nz = 1,1,1

level = amr.add_level() grid = level.add_grid() grid.xmin, grid.xmax, grid.ymin, grid.ymax, grid.zmin, grid.zmax = 0, pc/2, 0, pc/2, 0, pc/2 #Level 2 grid.nx,...,nz = 1,1,1 ... grid.xmin, grid.xmax, grid.ymin, grid.ymax, grid.zmin, grid.zmax = pc/2, pc, pc/2, pc, pc/2, pc #Level 2 grid.nx,...,nz = 1,1,1 ###########################################################

The offending line has been highlighted in bold and hyperion says that grid 2 is not aligned with parent cell in level 1 in the xdirection After examining the source code, I think I have identified the issue (grid_geometry_amr.f90, line 258):

if(.not.aligned(grid%xmin, grid_ref%xmin, grid_ref%width(1))) then

Is there a reason why only the xmin boundaries are checked for alignment? Shouldn't it be a check for xmin OR xmax? Thanks!

astrofrog commented 6 years ago

@smarandeshmukh - this looks like a typo, I think the call to aligned should include xmin and xmax.

astrofrog commented 4 years ago

Coming back to this, I wonder if the issue is that the level 2 grid should actually have 2,2,2 cells, not 1,1,1? I never got a chance to investigate, but if anyone can take a look, please post your findings here!