Closed vcantarella closed 1 year ago
Looking at the source code of the function I think the problem is in this snippet:
# fill flow terms
vmult = [-1.0, -1.0, -1.0]
flows = [frf, fff, flf]
for n in range(grb.nodes):
i0, i1 = ia[n] + 1, ia[n + 1]
for j in range(i0, i1):
jcol = ja[j]
if jcol > n:
if jcol == n + 1:
ipos = 0
elif jcol == n + grb.ncol: # <======HERE
ipos = 1
else:
ipos = 2
flows[ipos][n] = vmult[ipos] * flowja[j]
return frf.reshape(shape), fff.reshape(shape), flf.reshape(shape)
It seems like it already assumes that jcol == n+grb.ncol means it is in the next row, but in this case it should jump straight to the next layer.
Thanks for picking this up @w-bonelli. I looked at this a bit and it should be easy to fix, but it is trickier than it seems. Curious to see what you come up with.
@w-bonelli we have run into edge case issues with function before. It seems we should have better testing for this. Probably need cases (1, nrow, 1)
, (1, 1, ncol)
, (1, nrow, ncol)
, (2, nrow, 1)
, (2, 1, ncol)
, (2, nrow, ncol)
, (3, nrow, 1)
, (3, 1, ncol)
, and (3, nrow, ncol)
to cover all bases.
Changes were needed to the way we determine which face each flow belongs to, while iterating through the intercell flow matrix to build right/front/lower face arrays.
In the given model, flows with m - n == ncol
go to lower face as noted by @vcantarella. Previously the logic was
m - n == 1
m - n == ncol
With #1968 it becomes
m - n == 1
m - n == ncpl
But this is not generic, it only works if the grid is extended (has multiple cells) in all 3 dimensions. Special treatment is added for "degenerate" cases among those listed above by @jdhughes-usgs
Describe the bug
Hi, I created a 2D vertical modflow6 model which has only one row, thus flow should occur only on the x and z directions. When I apply the posprocessing get_structured_faceflows I would expect fff (front face flow) to be 0 in all cells, however at the output I get flf (lower face flow) as a 0 array, and my fff is non zero.
To Reproduce
I am providing an example of a 2D vertical slice model below with the structured face flow output for inspection. Thank you.
Expected behavior flf should be a non zero array and fff should be a zero array.
Screenshots
Desktop (please complete the following information):
Thanks !