Hi,
I'm trying to create a sparse matrix that has the same sparsity pattern as a standard mass matrix but which I can't assemble using UFL. When I use uBLASSparseMatrix everything works fine since uBLAS supports random insertion and no sparsity pattern is needed. For PETSc however, I'm currently trying to do the following (where I have given the form "a" generated with ffc in order to provide the sparsity pattern)
PETScMatrix A;
AssemblerBase ab;
ab.init_global_tensor(A, a);
The assembly procedure then sets the values using
A.setitem(std::make_pair(i,j), value)
and causes the error (during runtime):
*** Error: Unable to successfully call PETSc function 'MatSetValues'.
*** Reason: PETSc error code is: 63.
and more precisely
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Argument out of range!
[0]PETSC ERROR: New nonzero at (84,84) caused a malloc!
I should also methion that the size of the matrix is large enough, since A.size(0) and A.size(1) each outputs 289. If I use assemble(A,a) and then A.zero() instead of above code (using init_global_tensor), it works fine (but requires an useless assembly). I guess I'm missing something in the init procedure?
Thank's for any help!!
PS: During my search I've seen that it might be possible to set the option
MatSetOption(*A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
However, since the standard assemble function works, this should be possible to do somehow. I should also add that
A.apply("add")
didn't solve the problem.
Question also asked here: https://answers.launchpad.net/dolfin/+question/250532