[petsc-users] DMComposite and Matrix construction
Barry Smith
bsmith at mcs.anl.gov
Wed Jul 29 12:52:21 CDT 2015
To start, immediately after you have created the matrix do what it says call
> MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE)
this will allow you to build your matrix and work fine for modest size problems. For larger problems (only when you have your code running and solving the problem you want) you need to add in more preallocation information. But to do it now would be premature optimization.
Barry
> On Jul 29, 2015, at 11:51 AM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
>
> That’s generating malloc errors:
>
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Argument out of range
> [0]PETSC ERROR: New nonzero at (10,0) caused a malloc
> Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check
>
> I suspect this is because DMCreateMatrix is picking a sparsity pattern which is not consistent with what I need.
>
> -gideon
>
>> On Jul 28, 2015, at 10:10 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>
>>
>> DMCreateMatrix() ?
>>
>>
>>> On Jul 28, 2015, at 9:02 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
>>>
>>> I’m working with a DMComposite where I have a DMRedundant with 2 parameters, and then a standard DMDACreate with some number of entires that I would like to have distributed. For concreteness, suppose it is
>>>
>>> DMCompositeCreate(PETSC_COMM_WORLD, &packer);
>>> DMRedundantCreate(PETSC_COMM_WORLD, 0, 2, &p_dm);
>>> DMCompositeAddDM(packer,p_dm);
>>> DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE, nx, 1, 1, NULL,&u_dm);
>>> DMCompositeAddDM(packer,u_dm);
>>> DMCreateGlobalVector(packer,&U);
>>>
>>> Now, I would like to construct a matrix for this problem that can be used for computing Jacobians in a nonlinear solve. Is there a way to get the matrix size to layout in a “useful” way, in the sense that the first process, which owns the two degrees of freedom of p_dm and the first N0 number of the rows of u_dm, controls the corresponding N0+2 rows of the matrix, and analgously for the second process has the next N1 rows of the u_dm vector, and has the next N1 rows of the matrix?
>>>
>>> -gideon
>>>
>>
>
More information about the petsc-users
mailing list