Init a (PETSc-) matrix

Asked by jau on 2014-06-20

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.

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
2014-06-20
Last reply:
2014-06-20
jau (j-a-u) said : #1

I should also add that
A.apply("add")
didn't solve the problem.

Johannes Ring (johannr) said : #2

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: http://fenicsproject.org/support/

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.