[petsc-users] error in petsc-dev

Hong Zhang hzhang at mcs.anl.gov
Tue Apr 24 19:58:02 CDT 2012


Mohammad :

>
> Is this also true with MatSetType()? petsc-dev seems to need it (3.2-p6
> does not) but it's not listed in the changes link ...
>
There is no change on  MatSetType(). The default type is aij.
You can check petsc examples,
e.g. petsc-dev/src/ksp/ksp/examples/tutorials/ex2.c

Hong

>
>
> On Tue, Apr 24, 2012 at 4:27 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:
>
>> Thanks Hong.
>>
>>
>> On Tue, Apr 24, 2012 at 4:25 PM, Hong Zhang <hzhang at mcs.anl.gov> wrote:
>>
>>> See
>>> http://www.mcs.anl.gov/petsc/documentation/changes/dev.html:
>>>
>>> You MUST now call MatXXXSetPreallocation() or MatSetUp() on any matrix
>>> you create directly (not using DMCreateMatrix()) before calling
>>> MatSetValues(), MatSetValuesBlocked() etc.
>>>
>>>
>>> On Tue, Apr 24, 2012 at 6:01 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:
>>>
>>>> Hi,
>>>>
>>>> While trying to figure out a problem, I came across the following
>>>> situation. Consider the following code:
>>>>
>>>> int main (int argc, char **argv){
>>>>
>>>>     PetscInitialize(&argc, &argv, (char*)0, help);
>>>>
>>>>
>>>>     Mat m;
>>>>
>>>>     MatCreate(PETSC_COMM_WORLD, &m);
>>>>
>>>>     MatSetSizes(m, 10, 10, PETSC_DECIDE, PETSC_DECIDE);
>>>>
>>>>     MatSetFromOptions(m);
>>>>
>>>>     MatAssemblyBegin(m, MAT_FINAL_ASSEMBLY);
>>>>
>>>>     MatAssemblyEnd(m, MAT_FINAL_ASSEMBLY);
>>>>
>>>>     MatView(m, PETSC_VIEWER_STDOUT_WORLD);
>>>>
>>>>     MatDestroy(&m);
>>>>
>>>>
>>>>     PetscFinalize();
>>>>
>>>>     return 0;
>>>>
>>>> }
>>>>
>>>>
>>>> This runs without any problem under 3.2-p6 but fails with petsc-dev:
>>>>
>>>> [0]PETSC ERROR: --------------------- Error Message
>>>> ------------------------------------
>>>> [0]PETSC ERROR: Object is in wrong state!
>>>> [0]PETSC ERROR: Must call MatXXXSetPreallocation() or MatSetUp() on
>>>> argument 1 "mat" before MatAssemblyBegin()!
>>>> [0]PETSC ERROR:
>>>> ------------------------------------------------------------------------
>>>>
>>>> Eventually I could fix this by adding MatSetUp(m) after setting the
>>>> options. Why do I need this in petsc-dev? Does this somehow preallocate the
>>>> matrix?
>>>>
>>> Yes.
>>>
>>> Hong
>>>
>>>>
>>>> Thanks,
>>>> Mohammad
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120424/90844ed2/attachment-0001.htm>


More information about the petsc-users mailing list