improve API for linear operators
At the moment there is no way to construct a linear operator with the exception of calling assemble
on an operator. There is also no way to reuse an existing linear operator (i.e. reassemble) except when using a scheme
which holds a reference to an operator which is returned when calling assemble
. Issues:
-
scheme
andoperator
behave differently when callingassemble
- constructing a linear operator on the python side and passing that to a
jacobian
type method would make ownership and usage more transparent - in the case of
petsc4py
's SNES implementation reusing an existing linear operator is part of the required API - now a copy is required
Possible solutions:
- add a
create.operator("linear",dspace,rspace,[storage])
function that builds a module for the linear operator - at the moment the linear operator is exported together with thescheme
andoperator
. This approach could speed up compilations ofscheme/operator
but would increase (perhaps) compilation time when using the linear operators. In this case a newjacobian
method would be introduced, possibly the existingassemble
method would be removed (same problem as returning a new df in thesolve
method. Instead of a neejacobian
method one could also add atarget
argument to the existingassemble
. - add a
operator.linearOperator([storage])
method to construct a new linear operator. In this case no additional module is generated. Same argument forjacobian/assemble
as above.