Init a (PETSc-) matrix

Asked by jau


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 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
However, since the standard assemble function works, this should be possible to do somehow.

Question information

English Edit question
DOLFIN Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
jau (j-a-u) said :

I should also add that
didn't solve the problem.

Revision history for this message
Johannes Ring (johannr) said :

FEniCS no longer uses Launchpad for Questions & Answers. Please consult the documentation on the FEniCS web page for where and how to (re)post your question:

Can you help with this problem?

Provide an answer of your own, or ask jau for more information if necessary.

To post a message you must log in.