Skip to content

Rebind writer and linear solver when the grid or matrix object is replaced - #7295

Open
hnil wants to merge 4 commits into
OPM:masterfrom
hnil:pr/rebind-grid-and-matrix
Open

Rebind writer and linear solver when the grid or matrix object is replaced#7295
hnil wants to merge 4 commits into
OPM:masterfrom
hnil:pr/rebind-grid-and-matrix

Conversation

@hnil

@hnil hnil commented Aug 7, 2026

Copy link
Copy Markdown
Member

Two small robustness fixes for runs that rebuild the grid or the linear system mid-run (opm-flowgeomechanics does this for a growing fracture grid):

  • vtkmultiwriter: gridViewChanged(gridView) updates the stored view and forwards to gridChanged().
  • ISTLSolver: eraseMatrix() resets the stored matrix pointer, and initPrepare() notices when a different matrix object arrives and forces solver recreation.

Inert unless something actually replaces the grid or matrix; SPE1 unchanged.

hnil and others added 2 commits August 7, 2026 15:01
New gridViewChanged(gridView) updates the stored view and forwards to
gridChanged(), for writers whose grid is rebuilt during the run (e.g. a
growing fracture grid). Requires the stored view to be non-const.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
eraseMatrix() now resets the stored matrix pointer, and initPrepare()
detects that a different matrix object arrived (grid/system regenerated)
and forces solver recreation on the next shouldCreateSolver() query (kept
const; the one-shot trigger is mutable).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hnil hnil added the manual:enhancement This is an enhancement/improvent that needs to be documented in the manual label Aug 7, 2026
@hnil
hnil requested review from akva2 and atgeirr August 7, 2026 13:05
Comment thread opm/simulators/linalg/ISTLSolver.hpp
hnil and others added 2 commits August 7, 2026 16:49
Name the opm-flowgeomechanics use sites - the growing fracture grid for
gridViewChanged(), and the connection rebuild for eraseMatrix() - so the
two hooks do not read as unused API.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
matrix_ is initialised to nullptr in both constructors, so
matrix_ == nullptr implies &M != matrix_ and the separate firstcall
flag added nothing.  The else branch went with it: it only ran when
&M == matrix_, so its 'pointers should not change' throw could not
fire.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hnil

hnil commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

Right — matrix_ is nullptr-initialised in both constructors, so firstcall was implied by matrix_changed. Folded into one test.

That also made the else branch dead: it only ran when &M == matrix_, so its "pointers should not change" throw could never fire. Removed rather than left sitting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:enhancement This is an enhancement/improvent that needs to be documented in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants