Add CMake infrastructure to simplify building and running Python tests:
- Add `python_tests` target: builds only Python modules and test files
Usage: `ninja python_tests`
- Add test fixtures: running `ctest -R python_basic` now automatically
builds the required Python modules first via FIXTURES_REQUIRED
This allows one to quickly iterate on Python tests without building
unrelated C++ test binaries.
Change auto to const auto& when accessing rescoup() to avoid unnecessary
copy of ReservoirCoupling::CouplingInfo object. The ptr_member::operator()()
returns a const reference, but auto deduces the value type, triggering
copy constructor overhead.
Performance improvements:
* Eliminates copy constructor/destructor calls
* Reduces memory allocation during method execution
* Improves cache efficiency
* Consistent with usage patterns elsewhere in codebase
Addresses performance concern from code review about unintended
copy operations.
Introduce a thin proxy class that encapsulates reservoir coupling
master/slave pointers and provides mode queries (isMaster/isSlave)
that work regardless of MPI availability.
Benefits:
- Mode queries can be called without #ifdef guards
- Member variables no longer need #ifdef protection
- Centralizes MPI-conditional includes in one header
- Consumer code becomes cleaner and more readable
Files changed:
- New: opm/simulators/wells/rescoup/RescoupProxy.hpp
- Modified: BlackoilWellModel.hpp, GuideRateHandler.hpp,
GroupStateHelper.hpp to use the proxy pattern
The proxy is non-owning (just holds pointers) and copyable.
Setter methods remain guarded since they use MPI-only types.
- Remove the print...() functions that only wrote partial information.
If this is needed it may be done by extracting from the export...()
output instead.
- Move the export...() functions to a separate file. Keeping the
top-level function though, and the logic it contained relating to
avoiding re-writing the sparsity pattern.
- Make the implementation safer by removing all use of sprintf().
Uses the example models provided in PR OPM/opm-tests#1441.
These are INIT file only tests because the simulation models in
the two example cases aren't particularly interesting.
Certain example models don't have meaningful dynamic results, but
we'd still like to be able to automatically update the static result
files like EGRID and INIT. This commit adds such support under the
assumption that those test cases have names that match the pattern
*compareECLInitFiles*
While here, also adapt the existing Norne-based INIT file test to
use this file update mechanism instead of its original special case
treatment.
If the reference file does not exist, then this is typically a new
file type or a new case. If the updated file does not exist, then
this is typically because the case no longer generates that
particular file type. If neither the reference nor the update
exists, then that is typically an error that should have been caught
earlier. We nevertheless emit a line into 'data_diff' in this case.
In particular, separate the individual "update" cases out to
per-case helper functions:
- updateFullSimulationResults -- Common case. Updates all file
types (EGRID, INIT, RFT, SMSPEC, UNSMRY, UNRST) for both base
runs and restarted runs.
- updateRestartResults -- Updates all file types for restarted
runs only.
- updateDamarisResults -- Updates Damaris-related file types.
- updateNorneInitFiles -- Updates INIT and EGRID files for the
Norne case as needed.
While here, also switch to a 'while read' loop for processing
'LastTestsFailed.log' to avoid a needless use of 'cat' and add
rudimentary script and function documentation. Finally, switch to
using 'printf' instead of an 'echo' loop to generate the commit
message's list of changed test cases.
The addback calculation at local_reduction_level was using the
accumulated efficiency factor (from entity to control group) instead
of the partial efficiency factor (from entity to local_reduction_level).
This caused incorrect constraint violations when checking higher-level
group constraints. The fix computes the partial efficiency by multiplying
efficiency factors from local_reduction_level down to the entity.
This test exposes a bug in GroupStateHelper::checkGroupConstraintsProd()
where the addback calculation uses the accumulated efficiency factor
instead of the partial efficiency factor at local_reduction_level.
Test setup:
- Group hierarchy: FIELD -> PLAT (E=0.9) -> MANI (E=0.8) / MANI2 (E=0.7)
- MANI has individual ORAT control, PLAT has guide rate
- WELL-A produces 10000 SM3/day under MANI
The bug causes:
- Addback uses 0.72 (E_MANI * E_PLAT) instead of 0.8 (E_MANI)
- This results in scale = 0.9465 (false constraint violation)
- Correct calculation would give scale = 1.0288 (no violation)
The test currently passes with the buggy expected values. A subsequent
commit will fix the bug and update the test expectations.