## [Libmesh-users] CouplingMatrix

 [Libmesh-users] CouplingMatrix From: Derek Gaston - 2008-08-19 18:20:07 ```Anyone have an example showing how to properly use a CouplingMatrix? I have several variables in my system, but I only want to allocate the diagonal blocks (ie, solve the system completely decoupled). It appears that the CouplingMatrix will do this... but I can't quite figure out the correct sequence of calls needed in order to use a CouplingMatrix... Thanks! Derek ```

### Thread view

 [Libmesh-users] CouplingMatrix From: Derek Gaston - 2008-08-19 18:20:07 ```Anyone have an example showing how to properly use a CouplingMatrix? I have several variables in my system, but I only want to allocate the diagonal blocks (ie, solve the system completely decoupled). It appears that the CouplingMatrix will do this... but I can't quite figure out the correct sequence of calls needed in order to use a CouplingMatrix... Thanks! Derek ```
 Re: [Libmesh-users] CouplingMatrix From: Benjamin Kirk - 2008-08-22 18:02:15 ```> Anyone have an example showing how to properly use a CouplingMatrix? No current example, but I can describe it pretty easy... > I have several variables in my system, but I only want to allocate the > diagonal blocks (ie, solve the system completely decoupled). It appears that > the CouplingMatrix will do this... but I can't quite figure out the correct > sequence of calls needed in order to use a CouplingMatrix... If *all* the variables are decoupled, would you not want to put them in different systems? In any case, the CouplingMatrix should allow you to do this. When you add the variables to the system, then create a CouplingMatrix and give the DofMap its address (the dof_coupling pointer is there for your use). Fill the CouplingMatrix such that the diagonals are 1, the other entries 0. This says each variable couples to itself only. You need to do this before the EquationSystems is initialized, so that the dof distribution code sees your coupling matrix. The only remaining thing then is in your matrix assembly code you need to build and fill only the diagonal blocks of the element matrix as well. (That is, impose the same coupling on your element matrix, otherwise the insertion will allocate a lot of memory and waste your efforts. Let me know if it is still not clear -- ex11 could be easily hacked to show this since there is no Kuv/Kvu coupling in the Stokes equations. -Ben ```
 Re: [Libmesh-users] CouplingMatrix From: Derek Gaston - 2008-08-22 18:17:13 ```Thanks Ben, that's what I needed. On Aug 22, 2008, at 12:02 PM, Benjamin Kirk wrote: > If *all* the variables are decoupled, would you not want to put them > in > different systems? Heh - I thought that would come up. As usual, I'm asking about one thing in order to accomplish something else. In our JFNK code we use the system matrix as a preconditioner using - snes_mf_operator. What we do is only fill in approximate jacobians for the diagonal blocks... then we hit that with something (usually AMG) and use it as a preconditioner. This turns out to work pretty well in most circumstances (depending on how approximate your approximations are and how tightly coupled all of your physics is... as you are obviously throwing away the coupling sensitivities in your preconditioner). So, I really did need a way of just preserving the block diagonals... but it does all need to be in one big matrix (as that's what's _actually_ being solved). BTW - The Trilinos integration is going pretty well... I'm working on the solve steps now (getting segfaults for some reason). Hopefully I'll get it worked out and checked in this afternoon. Thanks again, Derek ```

## Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks