pycopm.utils.parser_deck module
Parse an OPM deck and update records for the modified grid.
- class pycopm.utils.parser_deck._ParserState(dimens: bool = False, grid: bool = False, welspecs: bool = False, welsegs: bool = False, complump: bool = False, compdat: bool = False, compsegs: bool = False, mapaxes: bool = False, multregt: bool = False, process_edit: bool = False, editnnc: bool = False, multiply: bool = False, props: bool = False, operation: bool = False, regions: bool = False, equil: bool = False, faults: bool = False, multflt: bool = False, welldims: bool = False, skip_block: bool = False, aqucon: bool = False, aqunum: bool = False, aquancon: bool = False, bccon: bool = False, bwpr: bool = False, source: bool = False, pinch: bool = False, has_edit: bool = False, previous_completion: list[str] = <factory>, compsegs_wells: list[str] = <factory>, retained_wells: list[str] = <factory>, completion_wells: list[str] = <factory>, segmented_wells: list[str] = <factory>, separator: str = '', schedule_keyword: str = '')
Bases:
objectStore 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.
- aquancon: bool
- aqucon: bool
- aqunum: bool
- bccon: bool
- bwpr: bool
- compdat: bool
- completion_wells: list[str]
- complump: bool
- compsegs: bool
- compsegs_wells: list[str]
- dimens: bool
- editnnc: bool
- equil: bool
- faults: bool
- grid: bool
- has_edit: bool
- mapaxes: bool
- multflt: bool
- multiply: bool
- multregt: bool
- operation: bool
- pinch: bool
- previous_completion: list[str]
- process_edit: bool
- props: bool
- regions: bool
- retained_wells: list[str]
- schedule_keyword: str
- segmented_wells: list[str]
- separator: str
- skip_block: bool
- source: bool
- welldims: bool
- welsegs: bool
- welspecs: bool
- pycopm.utils.parser_deck.__handle_schedule_keyword(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Filter supported schedule records by wells retained in the submodel.
- pycopm.utils.parser_deck._append_explicit_solution_includes(dck: ConfigViaDeck, modified_deck: list[str]) None
Append include statements for the explicit solution properties.
- pycopm.utils.parser_deck._collect_segmented_well_names(dck: ConfigViaDeck, kwr: _ParserState) None
Identify wells requiring segmented-well completion handling.
- pycopm.utils.parser_deck._collect_vicinity_well_names(dck: ConfigViaDeck, kwr: _ParserState, vicinity: VicinityMaps) None
Identify wells and segmented wells retained in the vicinity model.
- pycopm.utils.parser_deck._handle_aquancon(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update AQUANCON grid-index ranges for the modified grid.
- pycopm.utils.parser_deck._handle_aqucon(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update AQUCON grid-index ranges for the modified grid.
- pycopm.utils.parser_deck._handle_aqunum(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update AQUNUM grid indices for the modified grid.
- pycopm.utils.parser_deck._handle_bccon(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update BCCON grid-index ranges for the modified grid.
- pycopm.utils.parser_deck._handle_bwpr(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update BWPR grid indices for the modified grid.
- pycopm.utils.parser_deck._handle_compsegs(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Filter COMPSEGS records by wells retained in the submodel.
- pycopm.utils.parser_deck._handle_dimens(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Replace the original DIMENS values with the modified grid dimensions.
- pycopm.utils.parser_deck._handle_editnnc(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update EDITNNC grid indices for the modified grid.
- pycopm.utils.parser_deck._handle_equil(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Replace EQUIL with explicit initialization include files.
- pycopm.utils.parser_deck._handle_fault(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update FAULTS grid-index ranges for the modified grid.
- pycopm.utils.parser_deck._handle_grid_props(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Replace GRID properties and preserve supported GRID-section keywords.
- pycopm.utils.parser_deck._handle_mapaxes(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Preserve MAPAXES so the generated grids retain the same map view.
- pycopm.utils.parser_deck._handle_multflt(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Preserve fault multiplier records from the input deck.
- pycopm.utils.parser_deck._handle_multiply(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update MULTIPLY grid-index ranges for the modified grid.
- pycopm.utils.parser_deck._handle_multregt(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Preserve MULTREGT records from the GRID section.
- pycopm.utils.parser_deck._handle_oper(dck: ConfigViaDeck, vicinity: VicinityMaps, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update supported operation records for the modified grid.
- pycopm.utils.parser_deck._handle_pinch(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Preserve PINCH records from the input deck.
- pycopm.utils.parser_deck._handle_props(dck: ConfigViaDeck, vicinity: VicinityMaps, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Handle the PROPS section and its supported operations.
- pycopm.utils.parser_deck._handle_regions(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Replace the REGIONS content with generated include files.
- pycopm.utils.parser_deck._handle_segmented_wells(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str, wellcind: list) bool
Update COMPDAT, COMPSEGS, and COMPLUMP records for the modified grid.
- pycopm.utils.parser_deck._handle_source(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update SOURCE grid indices for the modified grid.
- pycopm.utils.parser_deck._handle_welldims(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Update WELLDIMS for a refined grid.
- pycopm.utils.parser_deck._handle_wells(dck: ConfigViaDeck, kwr: _ParserState, modified_deck: list[str], nrwo: str, hv: bool) bool
Update well-head grid indices and activate completion handlers.
- pycopm.utils.parser_deck._handle_welsegs(kwr: _ParserState, modified_deck: list[str], nrwo: str) bool
Filter WELSEGS records by wells retained in the submodel.
- pycopm.utils.parser_deck._include_contains_endbox(dck: ConfigViaDeck, nrwo: str) bool
Return whether an included file contains ENDBOX.
- pycopm.utils.parser_deck._mark_multiplier_keyword(deck_line: str, mults: NDArray) NDArray
Set the corresponding flag if a multiplier keyword is found.
- pycopm.utils.parser_deck._scan_deck_file(dck: ConfigViaDeck, file_path: str | Path) tuple[list[str], bool, NDArray]
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:
Resolved include paths, whether the main deck contains
MULTFLT, and flags forMULTX,MULTX-,MULTY,MULTY-,MULTZ, andMULTZ-.- Return type:
includes, has_main_multflt, multipliers
- pycopm.utils.parser_deck.find_multiplier_keywords(dck: ConfigViaDeck) tuple[bool, NDArray]
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:
Whether the main deck contains
MULTFLTand directional multiplier flags in x, x-, y, y-, z, and z- order.- Return type:
has_main_multflt, multipliers
- pycopm.utils.parser_deck.process_deck(dck: ConfigViaDeck, vicinity: VicinityMaps) tuple[list[str], list[int]]
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:
Rewritten deck lines and coarse cells containing well completions.
- Return type:
modified_deck, well_cell_indices