Thanks Matt. Are you allowed to insert the same column multiple times in one call to MatSetValues though?<br><br><br><br><div class="gmail_quote">On Tue, Sep 25, 2012 at 4:58 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Sep 25, 2012 at 5:56 PM, John Mousel <span dir="ltr"><<a href="mailto:john.mousel@gmail.com" target="_blank">john.mousel@gmail.com</a>></span> wrote:<br>
</div><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
To be more clear, I do the following:<br><br><preallocate><br><insert 0's where I want columns><br><flush><br><insert real entries><br><flush><br><clean up special rows by adding corrections to coefficients><br>
<br>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?<br>
</blockquote><div><br></div></div><div>Just once. This is exactly how we operate with DMCreateMatrix(). You can test it in any of the examples, like SNES ex5.</div><div><br></div><div> Matt</div><div class="im"><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
John <br><br><br><div class="gmail_quote">On Tue, Sep 25, 2012 at 4:50 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Tue, Sep 25, 2012 at 5:44 PM, John Mousel <span dir="ltr"><<a href="mailto:john.mousel@gmail.com" target="_blank">john.mousel@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>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?<br>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.<br>
<br>New nonzero at (8045,60) caused a malloc!<br></blockquote><div><br></div></div><div>You have to be more specific. It sounds like what you are doing is</div><div><br></div><div><preallocate></div><div><put in some nonzeros></div>
<div><assemble></div><div><try to put in more nonzeros></div><div><br></div><div>This will not work since assembly squeezes out extra space. Why are you assembling in between?</div><div>If you need to clear buffers, you can just to MAT_ASSEMBLY_FLUSH.</div>
<div><br></div><div> Matt</div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>
Could someone clarify how this works. <br><span><font color="#888888"><br>John<br>
</font></span></blockquote></div></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</font></span></font></span></blockquote></div><br>
</blockquote></div></div><div class="HOEnZb"><div class="h5"><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</div></div></blockquote></div><br>