Xiaoxu Wang xiwang at
Tue Oct 3 13:03:53 CDT 2006

The error is at line 1023 of "plog.c".
An unhandled exception of type 'System.NullReferenceException' occurred 
in Unknown Module.

Additional information: Object reference not set to an instance of an 

The matrix I am trying to initialize is the stiffness matrix K of finite 
element methods. Later the dynamical system is solved as  (I + Dt*K) 
U(t+1) = U(t) + Dt.F(t) by calling KSPSolve. Any idea how to set the 
number of local rows?  I am running the code on PC now, but want to keep 
MatCreateMPIAIJ in it.  

----- Original Message ----- From: "Barry Smith" <bsmith at>
To: <petsc-users at>
Sent: Tuesday, October 03, 2006 8:32 AM
Subject: Re: MatCreateMPIAIJ

> On Mon, 2 Oct 2006, Xiaoxu Wang wrote:
>> Hi,
>>      I am a beginner on PETSC. This is my question about 
>> MatCreateMPIAIJ. I
>> have a sparse matrix and only know the total number of nonzeros each 
>> row. The
>> number of local rows and the number of local columns has been set to
>> PETSC_DECIDE. Therefore I don't know the size of each portion and it 
>> is hard
>> to tell d_nnz and o_nnz. I use the total number of nunzeros as d_nnz 
>> and get
>> an allocation error.
>   It would be helpful to know the exact error message:
>>  How to deal  with  this problem?  Should  I  explicitly
>> specify the number of local rows and the number of local columns and 
>> calculate
>> d_nnz and o_nnz? Or let PETSC decide the number of local rows and the 
>> number
>> of local columns, and  then use another function to get these values? 
>> Any
>> other better solution?
>   You should specifically set the number of local rows and columns and 
> then
> compute the values of d_nnz and o_nnz. How you determine d_nnz and 
> o_nnz is
> problem dependent and depends on what type of discretization you are 
> using:
> finite differences, elements etc.
>   Barry
>> Thanks a lot,
>> Xiaoxu

More information about the petsc-users mailing list