OPM/opm-porsol — pull request #89 by bska (2013-11-11 10:07:17+00:00)
Title: buildCellContrib(): Fix out-of-bounds indexing

In the interest of reducing the number of allocations/deallocations, the `rhs` and `gflux` arrays are allocated once (of maximum size, `max_ncf_`) at the start of `assembleDynamic()`. However, method `buildCellContrib()` implicitly assumes that `rhs` and `gflux` are sized according to the number of interfaces on a given cell. This discrepancy leads to out-of-bounds indexing unless all cells have the same number of interfaces.

Rewrite `buildCellContrib()` to only inspect the appropriate number of array elements, i.e., those that correspond to the current number of cell interfaces.

This bug was present for a *long* time.

Superb detective work by: @akva2.