diff --git a/src/CornerPointGrid/processing.jl b/src/CornerPointGrid/processing.jl index 3cb4436..67979e2 100644 --- a/src/CornerPointGrid/processing.jl +++ b/src/CornerPointGrid/processing.jl @@ -449,7 +449,7 @@ function grid_from_primitives(primitives; nnc = missing, pinch = missing) end end # Create pinch maps - pinch_top_to_bottom = generate_pinch_map(pinch, primitives, lines, column_lines, columns) + pinch_top_to_bottom, pinch_bottom_to_top = generate_pinch_map(pinch, primitives, lines, column_lines, columns) # Horizontal faces (top/bottom and faces along column) node_buffer = Int[] @@ -499,6 +499,12 @@ function grid_from_primitives(primitives; nnc = missing, pinch = missing) @assert cell_is_boundary(c2) continue end + if haskey(pinch_bottom_to_top, c2) + # If the there is a mapping (going up) from c2 to some + # other cell due to pinch we should not add anything. + @assert cell_is_boundary(c1) + continue + end # Index into pillars node_in_pillar_indices = map(F, cell_bnds) # Then find the global node indices @@ -678,6 +684,8 @@ end function generate_pinch_map(pinch, primitives, lines, column_lines, columns) pinch_top_to_bottom = Dict{Int, Int}() + pinch_bottom_to_top = Dict{Int, Int}() + if !ismissing(pinch) # Loop over columns, look for gaps (; pinch, minpv_removed) = pinch @@ -716,12 +724,13 @@ function generate_pinch_map(pinch, primitives, lines, column_lines, columns) inactive_cells = abs.(col.cells[(before_inactive+1):last_inactive]) if depth_bottom - depth_top < thres || (gap && all(minpv_removed[inactive_cells])) pinch_top_to_bottom[top_cell] = bottom_cell + pinch_bottom_to_top[bottom_cell] = top_cell num_added += 1 end end end end - return pinch_top_to_bottom + return (pinch_top_to_bottom, pinch_bottom_to_top) end function find_next_gap(cells, start)