## libmesh-users

 [Libmesh-users] Questions about Example 13 From: Anurag Singh - 2007-07-16 20:45:58 Attachments: Message as HTML ```Hi, As per John's suggestion, I'm emailing it to the whole users list for some very simple questions on example 13: . We are solving the gov. equations for a lid driven cavity in 2D: rho*(v_i,0 + v_i,j*v_j) + p_i - mu*v_i_jj = 0 v_ii = 0 The FEM formulation of the above equations in example 13 is not clear to me. Can anyone help? Boundary conditions are implemented using penalty method. I couldn't figure out the exact formulation to figure how it's doing it. (I'm not very knowledgeable about FEM and trying to relate what I read in a book e.g. for say linearized burger's equation v_i,0 + vbar_j*v_i,j - nu*v_i,jj - f_i = 0 with generalized galerkin methods leads to the formulation (A + dt/2*(B+K)*V^n+1 = [A-dt/2*9B+K)]v^n + dt*(F + G)). (A is mass matrix, K is stiffness matrix etc. Now this is basically in the form A*u =B . which is then solved for u. The formulation is DST approximation. So basically how does the ex13 implementation translates to something like above. The book I'm referring is Computational Fluid Dynamics by T J Chung. I'm pretty sure it's quite simple and those who have done it can quickly scribble. I might be able to figure it out eventually as I get proficient in FEM but it would save me a lot of time if you folks can help me here. . The above should hopefully also answer how we have a terms like Kuu, Kup , Kuv etc. which are themselves matrices. . I wanted to compute Re of the flow but couldn't find the value of "nu" used in the problem? (L & u is 1 but don't know nu, 1/300 ??) Any help would be greatly appreciated. Unless I understand all this I'm finding it difficult to move on. Regards, Anurag ```
 [Libmesh-users] Questions about Example 13 From: John Peterson - 2007-07-16 22:33:09 ```Anurag Singh writes: > Hi, > > As per John's suggestion, I'm emailing it to the whole users list for some > very simple questions on example 13: > > > > . We are solving the gov. equations for a lid driven cavity in 2D: > > rho*(v_i,0 + v_i,j*v_j) + p_i - mu*v_i_jj = 0 > > v_ii = 0 > > > > The FEM formulation of the above equations in example 13 is not clear to me. > Can anyone help? The difference here may be that the problem is nonlinear, and you have solved only linear problems in the past? We have a general nonlinear problem F(U)=0 where U is a vector of FE coefficients. We use Newton's Method to arrive at the linearized equations J(U_{k})(U_{k+1} - U_{k}) = -F(U_{k}) J(U) is the Jacobian matrix of partial derivatives, U_{k} is Newton iterate k. Search for multi-variable Newton's Method if this looks foreign to you. The non-standard thing which is done in ex13 is to move part of the LHS of Newton's equation to the RHS as: J(U_{k}) U_{k+1} = -F(U_{k}) + J(U_{k}) U_{k} This might be why the right-hand side does not look familiar to you. The linearized equations are solved multiple times per timestep until the solution converges. The time discretization is a theta-scheme. Theta=1 is the same thing as backward (implicit) Euler. -John > > > Boundary conditions are implemented using penalty method. > > > > I couldn't figure out the exact formulation to figure how it's doing it. > > > > (I'm not very knowledgeable about FEM and trying to relate what I read in a > book e.g. for say linearized burger's equation v_i,0 + vbar_j*v_i,j - > nu*v_i,jj - f_i = 0 with generalized galerkin methods leads to the > formulation (A + dt/2*(B+K)*V^n+1 = [A-dt/2*9B+K)]v^n + dt*(F + G)). (A is > mass matrix, K is stiffness matrix etc. > > Now this is basically in the form A*u =B . which is then solved for u. The > formulation is DST approximation. > > > > So basically how does the ex13 implementation translates to something like > above. > > The book I'm referring is Computational Fluid Dynamics by T J Chung. > > I'm pretty sure it's quite simple and those who have done it can quickly > scribble. I might be able to figure it out eventually as I get proficient in > FEM but it would save me a lot of time if you folks can help me here. > > > > . The above should hopefully also answer how we have a terms like > Kuu, Kup , Kuv etc. which are themselves matrices. > > . I wanted to compute Re of the flow but couldn't find the value of > "nu" used in the problem? (L & u is 1 but don't know nu, 1/300 ??) > > > > Any help would be greatly appreciated. Unless I understand all this I'm > finding it difficult to move on. > > > > Regards, > > Anurag > ```
 Re: [Libmesh-users] Questions about Example 13 From: John Peterson - 2007-07-18 21:31:39 ```Looks like you sent the output of ex4 and the code for ex13. Can you send the exact modified code for ex4, and I will try running it and see what I get? Thanks, J Anurag Singh writes: > Thanks for all your support. Coming back to the time question I asked you > once and you mentioned that matrix assembly shouldn't take that much of > time. > > However I consistently see it taking up most of the time (in ex4 & ex13). I > have included the ex4 outputs and modified source of example 13 where I have > put log statements in ex13 to time the matrix insertion steps etc (no other > change). Also included is the ex13 output from my machine (note for ex13 I > restricted everything to one single step). Further solve() internally calls > the matrix assembly function, so net time of matrix solve (Ax=B solving) is > actually the total solve time as given here - assembly time? > > I'm not sure if something is wrong with my logging, or with the libmesh or > thatz the way it is(insertion takes up most of the time - unlikely). > > Please let me know. > > Regards, > Anurag > > -----Original Message----- > From: John Peterson [mailto:peterson@...] > Sent: Monday, July 16, 2007 6:33 PM > To: Anurag Singh > Cc: libmesh-users@...; peterson@... > Subject: Questions about Example 13 > > Anurag Singh writes: > > Hi, > > > > As per John's suggestion, I'm emailing it to the whole users list for > some > > very simple questions on example 13: > > > > > > > > . We are solving the gov. equations for a lid driven cavity in > 2D: > > > > rho*(v_i,0 + v_i,j*v_j) + p_i - mu*v_i_jj = 0 > > > > v_ii = 0 > > > > > > > > The FEM formulation of the above equations in example 13 is not clear to > me. > > Can anyone help? > > The difference here may be that the problem is nonlinear, and you have > solved > only linear problems in the past? We have a general nonlinear problem > > F(U)=0 > > where U is a vector of FE coefficients. We use Newton's Method to arrive > at the linearized equations > > J(U_{k})(U_{k+1} - U_{k}) = -F(U_{k}) > > J(U) is the Jacobian matrix of partial derivatives, U_{k} is Newton iterate > k. > Search for multi-variable Newton's Method if this looks foreign to you. > The non-standard thing which is done in ex13 is to move part of the LHS > of Newton's equation to the RHS as: > > J(U_{k}) U_{k+1} = -F(U_{k}) + J(U_{k}) U_{k} > > This might be why the right-hand side does not look familiar to you. > The linearized equations are solved multiple times per timestep until the > solution converges. The time discretization is a theta-scheme. Theta=1 > is the same thing as backward (implicit) Euler. > > > -John > > > > > > > Boundary conditions are implemented using penalty method. > > > > > > > > I couldn't figure out the exact formulation to figure how it's doing it. > > > > > > > > (I'm not very knowledgeable about FEM and trying to relate what I read in > a > > book e.g. for say linearized burger's equation v_i,0 + vbar_j*v_i,j - > > nu*v_i,jj - f_i = 0 with generalized galerkin methods leads to the > > formulation (A + dt/2*(B+K)*V^n+1 = [A-dt/2*9B+K)]v^n + dt*(F + G)). (A > is > > mass matrix, K is stiffness matrix etc. > > > > Now this is basically in the form A*u =B . which is then solved for u. > The > > formulation is DST approximation. > > > > > > > > So basically how does the ex13 implementation translates to something > like > > above. > > > > The book I'm referring is Computational Fluid Dynamics by T J Chung. > > > > I'm pretty sure it's quite simple and those who have done it can quickly > > scribble. I might be able to figure it out eventually as I get proficient > in > > FEM but it would save me a lot of time if you folks can help me here. > > > > > > > > . The above should hopefully also answer how we have a terms like > > Kuu, Kup , Kuv etc. which are themselves matrices. > > > > . I wanted to compute Re of the flow but couldn't find the value > of > > "nu" used in the problem? (L & u is 1 but don't know nu, 1/300 ??) > > > > > > > > Any help would be greatly appreciated. Unless I understand all this I'm > > finding it difficult to move on. > > > > > > > > Regards, > > > > Anurag > > ```
 Re: [Libmesh-users] Questions about Example 13 From: John Peterson - 2007-07-19 00:42:50 ```Anurag Singh writes: > Hi John, > One update, I checked my libmesh installation. The contrib folder (in the > libmesh folder) has a Laspack directory with all the source and object files > for apparently Laspack. > I don't have PETSc installed, so I assume libmesh is using Laspack, correct > me if wrong. Yes, you're using laspack. I just noticed that Laspack's add_matrix () routine contains a call to a virtual function in the interior of one of its loops. (The call to the add() function is virtual.) This could be fixed by replacing the virtual function call by the contents of the add() function itself. I should point out, however, that I tried running ex4 with Laspack, and still didn't see the extremely poor matrix insertion performance as you. On the other hand, since you are probably going to want to run in parallel eventually anyway, you're going to want PETSc. (Laspack does not work at all in parallel.) -John ```