<div class="gmail_quote">On Fri, Jul 1, 2011 at 17:19, TAY wee-beng <span dir="ltr">&lt;<a href="mailto:zonexo@gmail.com">zonexo@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":2yd">Currently, I write in the matrix at each substep. I doubt this is the best.</div></blockquote><div><br></div><div>Profile (perhaps with -log_summary, you may have to register a stage around your assembly function) and see how much time is spent in assembly. If it&#39;s not too much, then don&#39;t worry about it. If it is too much of the run time, use a fine-grained profiler to see where the time is being spent. Sometimes you can adjust mesh traversal to get better memory performance, or to remove other inefficiencies. If it is still too much, think about how you can use blocking, for example, to solve each velocity component at once (fewer independent assemblies, fewer synchronization points). If it is still too much, then perhaps consider alternatives below.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":2yd"> I am thinking of:<br>
<br>
1. Instead of creating 2 matrices for x and y, I create 6, 2 for each substep. The off-diagonal elements are always the same. I only use MatDiagonalSet to change the diagonal elements for each matrix at different time steps<br>
</div></blockquote><div><br></div><div>This uses a lot more memory.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":2yd">
<br>
or<br>
<br>
2. I only create 2 matrices. At each substep, I multiply the matrices by a constant, so that off-diagonal elements at one substep is equal to that of another. Then I use MatDiagonalSet to do the same as above.</div></blockquote>
</div><br><div>If you can compute the diagonal without traversing the mesh, then this makes sense.</div>