Hello
My goal is to assemble a system matrix A which is used in
solve(A, x, b)
from other matrices A1,...,An which are constructed as GenericMatrix by
Ak = assemble(inner(nabla_grad(u), nabla_grad(v)) * dx)
bc.apply(Ak)
The matrices A1,...,An posess the same sparsity structure.
In my understanding there is no way to add up generic matrices (am i wrong here?).
Since it is convinient for me to handle the matrix adding rowwise, i use uBLAS to get the CSR representation with
r, c, val = Ak.data()
and reassemble the matrix when i'm finished by
A_sps = scipy.sparse.crs_matrix((summedVals, r, c), dtype=np.float_)
A = assemble(inner(nabla_grad(u), nabla_grad(v)) * dx)
bc.apply(A)
A.zero()
A.set(A_sps, whole, whole)
similar as done here by setting the whole matrix and not just some blocks.
The reassembling step is very slow as it is already noted in loggs answer, however i don't understand his hints about the Assembler object.
Could someone please provide sample code for this?
Or is there a simpler way without scipys crs_matrix? As far as i understand i cannot set a GenericMatrix with CSR data?
Thanks