Closed ordinary-slim closed 5 months ago
The overload you require is already there, see https://github.com/multiphenics/multiphenicsx/blob/main/multiphenicsx/fem/petsc.py#L1213
You probably missed it because functools.singledispatch
is bad at producing documentation for overloaded methods, in the sense that it only shows the documentation of the first appearance in the code, neglecting all remaining overloads. Unfortunately, apart from moving away from functools.singledispatch
, there is not much we can do about this documentation issue. (I do think that dolfinx
would have the same documentation issue, but please confirm)
Sorry for the misunderstanding, I was reading the code but I did not understand that was actually overloading.
The
assemble_matrix
functions call firstcreate_matrix
then do the proper assembly through non-exposed functions.To avoid the overhead of reallocation for each call, I would like to add an optional argument
A : typing.Optional[petsc4py.petsc.mat] = None
to theassemble_matrix
functions and zero it pre-assembly if given, otherwise create the matrix and proceed.I think it is not necessary to check whether the matrix matches the bilinear form, bcs and restriction and leave this up to the user.
I can do the commit if you agree with this.