[petsc-users] error in petsc-dev

Hong Zhang hzhang at mcs.anl.gov
Tue Apr 24 18:25:14 CDT 2012


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/5fe51ea2/attachment.htm>


More information about the petsc-users mailing list