Infer Action Dimensions From Restart File Information - #5308
Conversation
|
jenkins build this please |
1ac6c5e to
e0c6a6c
Compare
|
jenkins build this please |
There was a problem hiding this comment.
Pull request overview
This PR makes restart loading more robust by deriving ACTIONX-related dimensions (and some other restart metadata) directly from restart header arrays instead of relying on Runspec, and it introduces a new RstState::load() overload that only needs an optional PVT-table count.
Changes:
- Update restart header/state loading to infer ACTIONX dimensions and start-time information from INTEHEAD/DOUBHEAD, enabling removal of the
Runspecdependency in the primaryRstState::load()path. - Extend INTEHEAD/LOGIHEAD vector item definitions and header parsing to include ACTIONX sizing fields and a temperature flag.
- Adjust restart-related tests and minor related refactors/cleanup (including initialization and formatting tweaks).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_rst.cpp | Update RstHeader construction to no longer require Runspec. |
| tests/test_InteHEAD.cpp | Update RstHeader construction in tests to match new API. |
| tests/test_AggregateWellData.cpp | Update RstHeader construction in tests to match new API. |
| opm/output/eclipse/VectorItems/logihead.hpp | Add explicit LOGIHEAD indices for temperature flags. |
| opm/output/eclipse/VectorItems/intehead.hpp | Add explicit INTEHEAD indices for ACTIONX sizing fields. |
| opm/output/eclipse/LogiHEAD.cpp | Use named LOGIHEAD indices instead of numeric literals for TEMP flags. |
| opm/output/eclipse/InteHEAD.hpp | Remove variousUDQ_ACTIONXParam() from public interface. |
| opm/output/eclipse/InteHEAD.cpp | Fold ACTIONX-related INTEHEAD sizing values into actionParam() and simplify MAXSPRLINE calculation. |
| opm/output/eclipse/CreateInteHead.cpp | Stop calling removed variousUDQ_ACTIONXParam(). |
| opm/io/eclipse/rst/well.cpp | Switch tracer/temperature handling to be restart-header driven and modernize extraction logic. |
| opm/io/eclipse/rst/state.hpp | Add new RstState::load() overload and remove Runspec dependency from action restoration helpers. |
| opm/io/eclipse/rst/state.cpp | Implement new load() overload and refactor ACTIONX restore logic to use header-derived sizing. |
| opm/io/eclipse/rst/header.hpp | Remove stored Runspec from RstHeader; add ACTIONX sizing + inferred start-time fields. |
| opm/io/eclipse/rst/header.cpp | Populate new header fields, including inferred start times from DOUBHEAD. |
| opm/input/eclipse/Schedule/OilVaporizationProperties.hpp | Minor formatting and default-initialization cleanup for members. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
340db33 to
90246d9
Compare
90246d9 to
15a7ede
Compare
|
jenkins build this please |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
opm/io/eclipse/rst/state.cpp:784
- Action/condition array dimensions are now taken from restart header fields (
action_*_size,max_action_conditions) and immediately used to computesubspan()sizes and indexed inRstAction::Condition::valid()/RstActionconstruction. If any of these header values are 0/negative or inconsistent with the expected condition sizes, this can lead to UB/out-of-bounds reads before any exception is thrown (e.g.Condition::valid()indexesiacn[...]without a size check). Add sanity checks (>= expected minimums and consistent withVectorItems::{IACN,SACN,ZACN}::ConditionSize) and fail fast with a clear error if the restart header is malformed/unsupported.
const auto iacn_cond_size = static_cast<std::size_t>(this->header.action_iacn_size);
const auto sacn_cond_size = static_cast<std::size_t>(this->header.action_sacn_size);
const auto zacn_cond_size = static_cast<std::size_t>(this->header.action_zacn_size);
const auto iacn_action_size = this->header.max_action_conditions * iacn_cond_size;
const auto sacn_action_size = this->header.max_action_conditions * sacn_cond_size;
const auto zacn_action_size = this->header.max_action_conditions * zacn_cond_size;
1239089 to
9819373
Compare
Very good. In that case, I'll mark this PR as "ready for review" by a human reviewer. |
|
jenkins build this please |
PRs OPM#2651 and OPM#2663 added a "Runspec" argument to the restart loader as a means of inferring the maximum number of actions, the number of conditions per action and other essential pieces of information needed to correctly interpret the *ACT and *ACN restart file arrays. While this practice has served us well in the interim, it's strictly speaking somewhat fragile. A restarted simulation run is allowed to increase these dimensions compared to the base run and in that case we'd be basing our offsets on out-of-bounds values. This commit switches to loading the base run's action dimensions directly from the pertinent INTEHEAD array items which, in turn, enables removing the Runspec argument to RstState::load(). We still need the run's number of tabulated PVT regions in order to correctly load the oil vaporisation properties, but I want to push the scattering to the client side at some point in the future. For now we add a new overload of RstState::load() function that takes the number of PVT regions as an optional<int>--defaulting to nullopt which we treat as a single PVT region--and make the overload taking the Runspec argument call the other overload. The Runspec overload will be marked "deprecated" once all downstream users have been converted to the new overload. The one compromise that we have to add here is a floating-point based derivation of each actions "start" time. We would previously infer this from the Runspec argument's START value, but this is no longer available. Instead we use a calculation based on the RstHeader's "sim_time()" and the SimTim element of DOUBHEAD. Other derivations may be possible, but this appears sufficiently accurate for now. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
9819373 to
42b8012
Compare
|
jenkins build this please |
|
PR approved and build check is green. I'll merge into master. |
PR OPM/opm-common#5308 added an overload of RstState::load() that does not require a "Runspec" argument. While we do have such an object here the restart file loading mechanism should not depend on the dimensions set in the restarted run. Restarted runs may increase such dimensions, e.g., the number of actions or conditions per action, so it's better to not provide those values in any way. We still pass the run's number of PVT tables as an argument to load(). This will be subject to future removal once load() supports this mode.
PRs #2651 and #2663 added a
Runspecargument to the restart loader as a means of inferring the maximum number of actions, the number of conditions per action and other essential pieces of information needed to correctly interpret the *ACT and *ACN restart file arrays. While this practice has served us well in the interim, it's strictly speaking somewhat fragile. A restarted simulation run is allowed to increase these dimensions compared to the base run and in that case we'd be basing our offsets on out-of-bounds values.This commit switches to loading the base run's action dimensions directly from the pertinent INTEHEAD array items which, in turn, enables removing the
Runspecargument toRstState::load().We still need the run's number of tabulated PVT regions in order to correctly load the oil vaporisation properties, but I want to push the scattering to the client side at some point in the future. For now we add a new overload of RstState::load() function that takes the number of PVT regions as anoptional<int>–defaulting tonulloptwhich we treat as a single PVT region–and make the overload taking theRunspecargument call the other overload. TheRunspecoverload will be marked "deprecated" once all downstream users have been converted to the new overload.The one compromise that we have to add here is a floating-point based derivation of each actions "start" time. We would previously infer this from the
Runspecargument's START value, but this is no longer available. Instead we use a calculation based on theRstHeader'ssim_time()and theSimTimelement of DOUBHEAD. Other derivations may be possible, but this appears sufficiently accurate for now.