[petsc-users] MatSetValues on same column multiple times

John Mousel john.mousel at gmail.com
Tue Sep 25 17:01:12 CDT 2012


Thanks Matt. Are you allowed to insert the same column multiple times in
one call to MatSetValues though?



On Tue, Sep 25, 2012 at 4:58 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Tue, Sep 25, 2012 at 5:56 PM, John Mousel <john.mousel at gmail.com>wrote:
>
>> To be more clear, I do the following:
>>
>> <preallocate>
>> <insert 0's where I want columns>
>> <flush>
>> <insert real entries>
>> <flush>
>> <clean up special rows by adding corrections to coefficients>
>>
>> What I want to clarify is if I touch the same column more than once, say
>> I'm looping over neighbors in an octree mesh, and it's just easier to
>> insert them multiple times as I find them for fluxes in different
>> directions instead of finding one exact coefficient for each neighbor, how
>> much preallocation would I need to specify? The number of times it gets
>> touched, or just one?
>>
>
> Just once. This is exactly how we operate with DMCreateMatrix(). You can
> test it in any of the examples, like SNES ex5.
>
>     Matt
>
>
>> John
>>
>>
>> On Tue, Sep 25, 2012 at 4:50 PM, Matthew Knepley <knepley at gmail.com>wrote:
>>
>>> On Tue, Sep 25, 2012 at 5:44 PM, John Mousel <john.mousel at gmail.com>wrote:
>>>
>>>>
>>>> If I'm adding to a particular column in multiple passes, do I need to
>>>> preallocate enough memory for each pass, or just 1 for each column in the
>>>> row?
>>>> Right now I'm drastically over-allocating, and I'm trying to reduce
>>>> this. If I give the true number of columns in the row, I keep getting new
>>>> entry errors.
>>>>
>>>> New nonzero at (8045,60) caused a malloc!
>>>>
>>>
>>> You have to be more specific. It sounds like what you are doing is
>>>
>>> <preallocate>
>>> <put in some nonzeros>
>>> <assemble>
>>> <try to put in more nonzeros>
>>>
>>> This will not work since assembly squeezes out extra space. Why are you
>>> assembling in between?
>>> If you need to clear buffers, you can just to MAT_ASSEMBLY_FLUSH.
>>>
>>>    Matt
>>>
>>>
>>>> I have it spit into phases where I set zeros in the non-zero pattern,
>>>> then I come back and fill in entries in a bulk pass, and then do a second
>>>> pass to clean up entries in special rows.
>>>> Could someone clarify how this works.
>>>>
>>>> John
>>>>
>>>
>>>
>>>
>>> --
>>> 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
>>>
>>
>>
>
>
> --
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120925/6b3224a8/attachment-0001.html>


More information about the petsc-users mailing list