CompWellEquations::invert() replaced a singular well matrix with the identity
only when detail::invertMatrix() threw Opm::NumericalProblem, which happens
just for the 4x4 block (three-component wells). For other sizes a singular
matrix either throws Dune::FMatrixError (generic path) or silently produces
inf/NaN (e.g. the 3x3 path used by two-component wells), so the fallback was
bypassed and the Newton update became NaN. Catch both exception types and
additionally detect a non-finite inverse.
Add tests/test_compwell_equations.cpp covering the Schur-complement
solve/recoverSolutionWell/apply against dense references, plus the singular
fallback for both the 4x4 (throws) and 3x3 (silent inf/NaN) paths.
Move the wellbore PT flash and the per-component mass computation out of
CompWell into standalone flashWellboreFluidState()/wellboreComponentMasses()
helpers (CompWellFlash.hpp), removing the duplicated mass loops in
calculateExplicitQuantities()/updateTotalMass(). This makes the
composition/pressure derivatives that flow through the flash unit-testable
without instantiating a Simulator.
Add tests/test_compwell_jacobian.cpp, which checks the AD derivatives of the
component masses, mass fractions and fluid density against central finite
differences. They agree to ~1e-7, confirming the previously-doubted
mass-fraction derivatives are in fact correct.
Remove trailing whitespace, add missing end-of-file newlines and add
the standard license header to the new ComponentName files.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The standard-flow main pulls in OPMRST (HDF5) save/load state through
SimulatorFullyImplicit, which requires the whole model and problem to be
serializable. Provide serializeOp for FlashPrimaryVariables (plain
FieldVector contents) and empty implementations for EmptyModel and
CompWellModel, where restart support is not implemented yet.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This is so that the new dune matrix work as expected: it requires to set the build mode each time a matrix is built and the sizes must be specified after setting the build mode. This is compatible with the current BCRSMatrix.
Improves readability and consistency of sparse matrix element access. This is as a preparation work for a new matrix from dune-istl.
* Use begin and end creator iterators accounting that they may be different types.
* Use iterator arithmetic instead of row implementation details.
* Use sparseRange idiom to loop over the row sparsity pattern.
* Avoid taking mutable references of rows, given that a matrix may return proxy objects.
* Do not assign an non-zero numeric value to the jacobian during its pattern creation.
* Include missing header for block vectors
Store a reference to the simulator's NewtonIterationContext in the
generic well model base class, and expose it through a new
iterationContext() accessor on the base.
The address of the iteration context is stable for the lifetime of
the simulator (it lives as a member of the problem object), and it
is mutated in-place during NLDD local solves, so a stored reference
correctly observes both global and local-solve state.
Drop the now-redundant iterCtx parameter from three method
signatures:
- BlackoilWellModelGeneric::updateAndCommunicateGroupData
- BlackoilWellModelNetworkGeneric::shouldBalance
- BlackoilWellModelNetworkGeneric::willBalanceOnNextIteration
The implementations read iter_ctx_ directly (or, for the network
class, via well_model_.iterationContext()). On the caller side,
several local `simulator_.problem().iterationContext()` lookups
become unused after the parameter drops and are removed.
Decorates inline helpers in blackoil*modules.hh, blackoilprimaryvariables.hh,
directionalmobility.hh, tpfalinearizer.hh, NewTranFluxModule.hpp,
TemperatureModel.hpp and BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp
with OPM_HOST_DEVICE, replaces a few raw `throw`s with OPM_THROW, and
switches static `FluidSystem::` accesses to instance-based
`fluidState.fluidSystem()` / `getFluidSystem()` so the same code works
when the fluid system lives on the device. Test
test_gpu_linear_two_phase_material.cu picks up the matching template
adjustments.
- Use its own fluidstate and Evaluation class to avoid having to add an extra derivative to the main equations
- Sotre the scaling factor to avoid calling the parameter all the time
The parameters can improve convergence for cases where wells jums between stop and open
Default is 99 i.e. by default we dont restrict ossiclations
We have two levels of parameters for this
The first is due restict the number in the inner iterations
(This functionality is already in the code)
--max-well-status-switch-in-inner-iter-wells
The second is to restrict the number during a time-step
--max-well-status-switch-iter-wells
The second could lead to wells being shut too early and should be
used more carefully
We add a cap on the number of allowed swichtes per local well solve.
The maximum number is given by --max-well-status-switch-in-inner-iter-wells=
Currently defaulted to 99. I.e. we basicly allow for unlimited switching