[Libmesh-users] How does LibMesh assemble Stiffness Matrix and Right Load Vector? From: Shengli Xu - 2006-01-14 07:07 ```In Example 11: // Reposition the submatrices... The idea is this: // // - - - - // | Kuu Kuv Kup | | Fu | // Ke =3D | Kvu Kvv Kvp |; Fe =3D | Fv | // | Kpu Kpv Kpp | | Fv | // - - - - // // The \p DenseSubMatrix.repostition () member takes the // (row_offset, column_offset, row_size, column_size). // // Similarly, the \p DenseSubVector.reposition () member // takes the (row_offset, row_size) Kuu.reposition (u_var*n_u_dofs, u_var*n_u_dofs, n_u_dofs, n_u_dofs); Kuv.reposition (u_var*n_u_dofs, v_var*n_u_dofs, n_u_dofs, n_v_dofs); Kup.reposition (u_var*n_u_dofs, p_var*n_u_dofs, n_u_dofs, n_p_dofs); Kvu.reposition (v_var*n_v_dofs, u_var*n_v_dofs, n_v_dofs, n_u_dofs); Kvv.reposition (v_var*n_v_dofs, v_var*n_v_dofs, n_v_dofs, n_v_dofs); Kvp.reposition (v_var*n_v_dofs, p_var*n_v_dofs, n_v_dofs, n_p_dofs); Kpu.reposition (p_var*n_u_dofs, u_var*n_u_dofs, n_p_dofs, n_u_dofs); Kpv.reposition (p_var*n_u_dofs, v_var*n_u_dofs, n_p_dofs, n_v_dofs); Kpp.reposition (p_var*n_u_dofs, p_var*n_u_dofs, n_p_dofs, n_p_dofs); Fu.reposition (u_var*n_u_dofs, n_u_dofs); Fv.reposition (v_var*n_u_dofs, n_v_dofs); Fp.reposition (p_var*n_u_dofs, n_p_dofs); I don't understand these code. What are the structures of Total Dof Vector and Element Dof Vector? For example in 2D, the freedom of node is u , v. The total Dof Vector is like [u_1,u_2,...u_N, v_1, v_2,..., v_N], or like [u_1, v_1, u_2, v_2, ..., u_N, v_N], ( N is the node number). Suggestions: The examples are very usefully to help you understand libMesh. It was more better that the govering equation, the discrete finite element formulation are given. ShengliXu ```
 Re: [Libmesh-users] How does LibMesh assemble Stiffness Matrix and Right Load Vector? From: Roy Stogner - 2006-01-14 16:03 ```On Sat, 14 Jan 2006, Shengli Xu wrote: > In Example 11: > // Reposition the submatrices... The idea is this: > // - - - - > // | Kuu Kuv Kup | | Fu | > // Ke = | Kvu Kvv Kvp |; Fe = | Fv | > // | Kpu Kpv Kpp | | Fp | > // - - - - > I don't understand these code. The typo can't have helped. I've fixed it in the quote above and in CVS; the third component of the force vector should be Fp, not Fv. > What are the structures of Total Dof Vector and Element Dof Vector? The structure of the global DoF vector shouldn't matter to the assembly function; those dof_indices calls should give you the right global indices for your element degrees of freedom, and the add_matrix and add_vector routines should fill in the right global indices whether they're contiguous or scattered or out of order. For the element DoF vector, the indices are listed variable by variable, so they can be accessed with submatrix blocks as we do in the example code. > For example in 2D, the freedom of node is u , v. > The total Dof Vector is like [u_1,u_2,...u_N, v_1, v_2,..., v_N], or like > [u_1, v_1, u_2, v_2, ..., u_N, v_N], ( N is the node number). I think variable-by-variable indexing (the first example you listed) is the libMesh default for the global DoF vector as well. If you want to try out solvers that depend on node-by-node indexing (your second example), I think the command line option "--node_major_dofs" will do it. You could try printing out a small system matrix with and without this option to make sure it's working. --- Roy Stogner ```