Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## Re: [Libmesh-users] (no subject)

 Re: [Libmesh-users] (no subject) From: Roy Stogner - 2008-10-01 15:41:07 ```On Wed, 1 Oct 2008, John Peterson wrote: > Static may not even be required. I think a single system with 3 > different matrix assembly "branches" is what you want. John is probably exactly right. In the worst case, if one of your systems has a constant matrix, having to reassemble it over and over again will waste a few CPU cycles... but even then it may be worth it to save the memory cost of the entire matrix. > for (qp) > for (i) > for (j) > switch (system_num) // A variable you define to order the 3 systems > case 1: > K(i,j) += something; break; > case 2: > K(i,j) += something else; break; > end switch > end j > end i > end qp I think putting the switch statement outside the for loops is slightly more efficient, if matrix assembly time ever becomes a noticeable issue (as it did for one app of mine). > I've done this in the past to assemble different right-hand side > vectors depending on whether I was solving the main system or an > auxiliary arclength continuation system of equations. It should be > straightforward to extend that to the matrix assembly itself as in the > pseudocode above. It is straightforward, and I have no excuse for not thinking of it and mentioning it myself. From my first shear thinning flow code: void assemble_stokes (EquationSystems& es, const std::string& system_name) { if (find_vorticity) { assemble_vorticity(es, system_name); return; } assemble_stokes() built the residual and jacobian of the Navier-Stokes system to solve; assemble_vorticity built a linear system to project the vorticity into the same smooth space for plotting. --- Roy ```