pycopm.utils.parser_deck module#

Parse an OPM deck and update records for the modified grid.

class _ParserState(dimens=False, grid=False, welspecs=False, welsegs=False, complump=False, compdat=False, compsegs=False, mapaxes=False, multregt=False, process_edit=False, editnnc=False, multiply=False, props=False, operation=False, regions=False, equil=False, faults=False, multflt=False, welldims=False, skip_block=False, aqucon=False, aqunum=False, aquancon=False, bccon=False, bwpr=False, source=False, pinch=False, has_edit=False, previous_completion=<factory>, compsegs_wells=<factory>, retained_wells=<factory>, completion_wells=<factory>, segmented_wells=<factory>, separator='', schedule_keyword='')[source]#

Bases: object

Store temporary state while parsing an OPM deck.

The Boolean fields indicate active keyword blocks. The list fields track wells, completions, and segmented-well records retained in the generated deck.

Parameters:
  • dimens (bool)

  • grid (bool)

  • welspecs (bool)

  • welsegs (bool)

  • complump (bool)

  • compdat (bool)

  • compsegs (bool)

  • mapaxes (bool)

  • multregt (bool)

  • process_edit (bool)

  • editnnc (bool)

  • multiply (bool)

  • props (bool)

  • operation (bool)

  • regions (bool)

  • equil (bool)

  • faults (bool)

  • multflt (bool)

  • welldims (bool)

  • skip_block (bool)

  • aqucon (bool)

  • aqunum (bool)

  • aquancon (bool)

  • bccon (bool)

  • bwpr (bool)

  • source (bool)

  • pinch (bool)

  • has_edit (bool)

  • previous_completion (list[str])

  • compsegs_wells (list[str])

  • retained_wells (list[str])

  • completion_wells (list[str])

  • segmented_wells (list[str])

  • separator (str)

  • schedule_keyword (str)

dimens: bool#
grid: bool#
welspecs: bool#
welsegs: bool#
complump: bool#
compdat: bool#
compsegs: bool#
mapaxes: bool#
multregt: bool#
process_edit: bool#
editnnc: bool#
multiply: bool#
props: bool#
operation: bool#
regions: bool#
equil: bool#
faults: bool#
multflt: bool#
welldims: bool#
skip_block: bool#
aqucon: bool#
aqunum: bool#
aquancon: bool#
bccon: bool#
bwpr: bool#
source: bool#
pinch: bool#
has_edit: bool#
previous_completion: list[str]#
compsegs_wells: list[str]#
retained_wells: list[str]#
completion_wells: list[str]#
segmented_wells: list[str]#
separator: str#
schedule_keyword: str#
process_deck(dck, vicinity)[source]#

Rewrite deck records for the modified grid.

The parser updates dimensions, properties, grid-index ranges, wells, aquifers, faults, and selected schedule records.

Parameters:
dck

Deck configuration and axis index mappings.

vicinity

Vicinity selection used when extracting a submodel.

Returns:
modified_deck, well_cell_indices

Rewritten deck lines and coarse cells containing well completions.

Parameters:
Return type:

tuple[list[str], list[int]]

_include_contains_endbox(dck, nrwo)[source]#

Return whether an included file contains ENDBOX.

Parameters:
  • dck (ConfigViaDeck)

  • nrwo (str)

Return type:

bool

__handle_schedule_keyword(kwr, modified_deck, nrwo)[source]#

Filter supported schedule records by wells retained in the submodel.

Parameters:
Return type:

bool

_collect_vicinity_well_names(dck, kwr, vicinity)[source]#

Identify wells and segmented wells retained in the vicinity model.

Parameters:
Return type:

None

_collect_segmented_well_names(dck, kwr)[source]#

Identify wells requiring segmented-well completion handling.

Parameters:
Return type:

None

_handle_dimens(dck, kwr, modified_deck, nrwo)[source]#

Replace the original DIMENS values with the modified grid dimensions.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_welldims(dck, kwr, modified_deck, nrwo)[source]#

Update WELLDIMS for a refined grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_props(dck, vicinity, kwr, modified_deck, nrwo)[source]#

Handle the PROPS section and its supported operations.

Parameters:
Return type:

bool

_handle_oper(dck, vicinity, kwr, modified_deck, nrwo)[source]#

Update supported operation records for the modified grid.

Parameters:
Return type:

bool

_handle_bwpr(dck, kwr, modified_deck, nrwo)[source]#

Update BWPR grid indices for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_regions(dck, kwr, modified_deck, nrwo)[source]#

Replace the REGIONS content with generated include files.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_equil(dck, kwr, modified_deck, nrwo)[source]#

Replace EQUIL with explicit initialization include files.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_append_explicit_solution_includes(dck, modified_deck)[source]#

Append include statements for the explicit solution properties.

Parameters:
  • dck (ConfigViaDeck)

  • modified_deck (list[str])

Return type:

None

_handle_grid_props(dck, kwr, modified_deck, nrwo)[source]#

Replace GRID properties and preserve supported GRID-section keywords.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_aqunum(dck, kwr, modified_deck, nrwo)[source]#

Update AQUNUM grid indices for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_aquancon(dck, kwr, modified_deck, nrwo)[source]#

Update AQUANCON grid-index ranges for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_aqucon(dck, kwr, modified_deck, nrwo)[source]#

Update AQUCON grid-index ranges for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_multflt(kwr, modified_deck, nrwo)[source]#

Preserve fault multiplier records from the input deck.

Parameters:
Return type:

bool

_handle_mapaxes(kwr, modified_deck, nrwo)[source]#

Preserve MAPAXES so the generated grids retain the same map view.

Parameters:
Return type:

bool

_handle_pinch(kwr, modified_deck, nrwo)[source]#

Preserve PINCH records from the input deck.

Parameters:
Return type:

bool

_handle_multregt(kwr, modified_deck, nrwo)[source]#

Preserve MULTREGT records from the GRID section.

Parameters:
Return type:

bool

_handle_bccon(dck, kwr, modified_deck, nrwo)[source]#

Update BCCON grid-index ranges for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_multiply(dck, kwr, modified_deck, nrwo)[source]#

Update MULTIPLY grid-index ranges for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_editnnc(dck, kwr, modified_deck, nrwo)[source]#

Update EDITNNC grid indices for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_fault(dck, kwr, modified_deck, nrwo)[source]#

Update FAULTS grid-index ranges for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_handle_welsegs(kwr, modified_deck, nrwo)[source]#

Filter WELSEGS records by wells retained in the submodel.

Parameters:
Return type:

bool

_handle_compsegs(kwr, modified_deck, nrwo)[source]#

Filter COMPSEGS records by wells retained in the submodel.

Parameters:
Return type:

bool

_handle_segmented_wells(dck, kwr, modified_deck, nrwo, wellcind)[source]#

Update COMPDAT, COMPSEGS, and COMPLUMP records for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

  • wellcind (list)

Return type:

bool

_handle_wells(dck, kwr, modified_deck, nrwo, hv)[source]#

Update well-head grid indices and activate completion handlers.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

  • hv (bool)

Return type:

bool

_handle_source(dck, kwr, modified_deck, nrwo)[source]#

Update SOURCE grid indices for the modified grid.

Parameters:
  • dck (ConfigViaDeck)

  • kwr (_ParserState)

  • modified_deck (list[str])

  • nrwo (str)

Return type:

bool

_scan_deck_file(dck, file_path)[source]#

Scan a deck file for includes and directional multipliers.

Parameters:
dck

Deck configuration providing the file encoding.

file_path

DATA or include file to scan.

Returns:
includes, has_main_multflt, multipliers

Resolved include paths, whether the main deck contains MULTFLT, and flags for MULTX, MULTX-, MULTY, MULTY-, MULTZ, and MULTZ-.

Parameters:
  • dck (ConfigViaDeck)

  • file_path (str | Path)

Return type:

tuple[list[str], bool, NDArray]

_mark_multiplier_keyword(deck_line, mults)[source]#

Set the corresponding flag if a multiplier keyword is found.

Parameters:
  • deck_line (str)

  • mults (NDArray)

Return type:

NDArray

find_multiplier_keywords(dck)[source]#

Find directional multiplier keywords in nested includes.

At most three levels of included files are scanned.

Parameters:
dck

Deck configuration identifying the input deck and encoding.

Returns:
has_main_multflt, multipliers

Whether the main deck contains MULTFLT and directional multiplier flags in x, x-, y, y-, z, and z- order.

Parameters:

dck (ConfigViaDeck)

Return type:

tuple[bool, NDArray]