[petsc-users] Matrix reuse with changing structure
Barry Smith
bsmith at mcs.anl.gov
Tue Mar 15 13:01:43 CDT 2016
> On Mar 15, 2016, at 12:56 PM, Smith, Kevin R. <Kevin.R.Smith at jhuapl.edu> wrote:
>
>
> Barry - Yeah, I suspected it was doing this. In my original implementation I would get allocation errors.
You need to call a MatSetOption() to tell the matrix that it is allowed to allocate new nonzeros.
>
> Matt - Thanks, I will try this solution out.
>
> Thanks for your help,
>
> Kevin
>
> -----Original Message-----
> From: Barry Smith [mailto:bsmith at mcs.anl.gov]
> Sent: Tuesday, March 15, 2016 1:48 PM
> To: Matthew Knepley
> Cc: Smith, Kevin R.; petsc-users at mcs.anl.gov
> Subject: Re: [petsc-users] Matrix reuse with changing structure
>
>
>> On Mar 15, 2016, at 12:28 PM, Matthew Knepley <knepley at gmail.com> wrote:
>>
>> On Tue, Mar 15, 2016 at 12:24 PM, Smith, Kevin R. <Kevin.R.Smith at jhuapl.edu> wrote:
>> Hello,
>>
>>
>>
>> Is it possible to reuse a sparse matrix and not reuse its non-zero structure? I have a matrix whose sparse structure changes each time. I’m hoping to avoid destroying and allocating new matrices each time the structure changes.
>
> Sure you can just add new nonzero locations at a later time. But it won't take out any current entries even if they are zero. So effectively the nonzero structure grows over time.
>
> Barry
>
>>
>>
>> Hmm, I can't find a toplevel API that does this (it would be something like MatReset()). You can get this effect using
>>
>> MatSetType(A, MATSHELL)
>> MatSetType(A, <type you had before>)
>>
>> A little messy but it will work.
>>
>> Thanks,
>>
>> Matt
>>
>>
>>
>> Thanks,
>>
>> Kevin
>>
>>
>>
>>
>> --
>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
>> -- Norbert Wiener
>
More information about the petsc-users
mailing list