## [Libmesh-users] DenseMatrix::condense

 [Libmesh-users] DenseMatrix::condense From: li pan - 2006-03-23 11:37:53 ```Dear all, The penalty method was used to set boundary condition in ex13. Can I use DenseMatrix::condense() in stead of penalty method? Another simple question, how to calculate invert matrix in libmesh? best pan __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ```

 [Libmesh-users] DenseMatrix::condense From: li pan - 2006-03-23 11:37:53 ```Dear all, The penalty method was used to set boundary condition in ex13. Can I use DenseMatrix::condense() in stead of penalty method? Another simple question, how to calculate invert matrix in libmesh? best pan __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ```
 Re: [Libmesh-users] DenseMatrix::condense From: Roy Stogner - 2006-03-23 14:28:06 ```On Thu, 23 Mar 2006, li pan wrote: > The penalty method was used to set boundary condition > in ex13. Can I use DenseMatrix::condense() in stead of > penalty method? In general, not easily. Even if you know the nodal values implied by your boundary conditions (which may not be easy for non-Lagrange elements), what happens when you have boundary nodes that are on non-boundary elements? (picture a triangulated domain, for example, or an interior corner on a mesh of quads). You'd need to use condense() on every element matrix that included your boundary node, which means you'd have to store a per-node "I'm on the boundary" flag somewhere; libMesh only keeps track of boundary element sides. > Another simple question, how to calculate invert matrix in libmesh? There is no inverse, I'm afraid; nobody has needed anything more than linear system solves with DenseMatrix. It's rare that you really need a matrix inverse, but if you do you can call lu_solve() or cholesky_solve() with each of N unit vectors to build one. --- Roy ```
 Re: [Libmesh-users] DenseMatrix::condense From: Benjamin S. Kirk - 2006-03-23 15:01:27 ```On Thu, 2006-03-23 at 08:27 -0600, Roy Stogner wrote: > On Thu, 23 Mar 2006, li pan wrote: > > > The penalty method was used to set boundary condition > > in ex13. Can I use DenseMatrix::condense() in stead of > > penalty method? > > In general, not easily. Even if you know the nodal values implied by > your boundary conditions (which may not be easy for non-Lagrange > elements), what happens when you have boundary nodes that are on > non-boundary elements? (picture a triangulated domain, for example, > or an interior corner on a mesh of quads). You'd need to use > condense() on every element matrix that included your boundary node, > which means you'd have to store a per-node "I'm on the boundary" flag > somewhere; libMesh only keeps track of boundary element sides. > Agreed. You can use the condense method, but you have to avoid the pitfall Roy describes. However, the BoundaryInfo class does keep track of boundary nodes for the boundary sides it tracks. The only possible problem is when you have, for example, a corner node which lives on two sides with two separate BC ids. This does give you the option of using the condense method for Lagrange elements, but as Roy points out you can no longer restrict your boundary condition applications to elements with a side on the boundary. See http://libmesh.sourceforge.net/doxygen/classBoundaryInfo.html#a6 Now, since only level-0 elements have their side BCs stored then only their nodes will get added in this automatic way. But, as a preprocessing step, you could loop through all active elements on the boundary and add their nodes to the BoundaryInfo class. > > Another simple question, how to calculate invert matrix in libmesh? > > There is no inverse, I'm afraid; nobody has needed anything more than > linear system solves with DenseMatrix. It's rare that you really need > a matrix inverse, but if you do you can call lu_solve() or > cholesky_solve() with each of N unit vectors to build one. Roy's right here too ;-) To quote one of my professors, "we only invert matrices under the penalty of death." Also, multiple subsequent lu_solve()'s will only perform the O(n^3) factorization once and then just do a series of O(n^2) back substitutions. See http://libmesh.sourceforge.net/doxygen/classDenseMatrix.html#a19 -Ben ```