Hi all,
I'm running clawpack 5.11, and successfully ran my 1d simulation. However I ran into problems when I tried to add gauges to my simulation.
If I set up the domain with:
from clawpack import pyclaw
domain = pyclaw.Domain([0], [100], [10])
print(f'lower: {domain.grid.lower}, upper: {domain.grid.upper}, '
f'num_cells: {domain.grid.num_cells}, delta: {domain.grid.delta}')
print(f'pcenters: {domain.grid.p_centers}')
print(f'centers: {domain.grid.centers}')
I get the expected output:
lower: [0.0], upper: [100.0], num_cells: [10], delta: [10.0]
pcenters: (array([ 5., 15., 25., 35., 45., 55., 65., 75., 85., 95.]),)
centers: [array([ 5., 15., 25., 35., 45., 55., 65., 75., 85., 95.])]
Now, I had setup the solution and obtain the state
# setup solution
solution = pyclaw.Solution(solver.num_eqn, domain)
state = solution.state
Finally, the gauges:
I had obtained the grid via
grid = state.grid
and defined the gauges at positions and pointed solver how to compute gauge values
gauges = [[6], [9], [10], [16], [95],]
grid.add_gauges(gauges)
solver.compute_gauge_values = gauge_calc_fun
Now, if I print gauges with:
print(f'gauges: {grid.gauges}')
I get this:
gauges: [[1], [1], [1], [2], [10]]
When I try to run claw simulation, I get the expected Exception
IndexError: index 10 is out of bounds for axis 1 with size 10
Now, if my reasoning is correct, the last cell spans from 90 to 100, with its center at 95. The index of the last cell should be 9, not 10.
Additionally, first and second index should be 0, not 1, since the first cell spans from 0-10, with the cell center at 5, while the gauge coordinates are 6 and 9.
Is it possible that there is a bug in Grid::add_gauges function?
Am I missing something here?
best regards,
jerry