On Wed 2008-04-09 15:10, Barry Smith wrote: > > Jed, > > The Mat coloring code can also be used directly, not through SNES. Once > you have > the coloring for the matrix (you can get that with MatGetColoring(), of > course, this assumes > you have already set a nonzero pattern for your matrix)). Call > MatFDColoringCreate() > then MatFDColoringSetFunction(), MatFDColoringSetFromOptions() and then > MatFDColoringApply().
Cool, I tried this and I can confirm that it is generating the correct matrix (by comparing entries with the output of -snes_fd) but unfortunately the matrix entries of the spectral operator corresponding to neighbors are actually not a very good approximation of the full operator. Bummer. It looks like I'm stuck with formulating the problem twice, once for the spectral operators and once for the FD/FE preconditioner. Thanks for the help. Jed > On Apr 9, 2008, at 2:13 PM, Jed Brown wrote: >> I'm trying to improve the preconditioning of my spectral collocation >> method for >> non-Newtonian incompressible Stokes flow. My current algorithm uses >> MatShell >> for the full Jacobian as well as each of its blocks [A B1'; B2 0] and the >> Schur >> complement S = -B2*A*B1'. I needed a preconditioner for A so I thought >> I'd >> solve the same problem using finite differences on the Chebyshev nodes. >> In >> reality, the stencil is really ugly in 3D so I just used a simpler >> elliptic >> operator. This works okay, but it's performance decays significantly as I >> increase the continuation parameter. Also, dealing with general boundary >> conditions is rather tricky and it seems to be a much weaker >> preconditioner when >> I have mixed boundary conditions. To rectify this, I tried a finite >> element >> discretization on the Chebyshev nodes (using Q1 elements). This must be >> scaled >> by the inverse (lumped) mass matrix due to the collocation nature of the >> spectral method. Strangely, even though it captures all the terms in the >> Jacobian, it is slightly weaker than the finite difference version. At >> least it >> is less error-prone and boundary conditions are easier to get right. >> Regardless, forming the explicit matrix separately from the spectral >> matrix >> causes a duplication of concepts that have to be kept in sync. So I >> started >> thinking, the spectral matrix is pretty cheap to apply a few times, so >> perhaps I >> can use a coloring to compute a sparse approximation. However, the >> documentation I found is using the function from the SNES context to form >> the >> matrix. In my case, the entire Jacobian doesn't help, I just want an >> approximation of A. (A itself is full, but implemented via FFT.) What is >> the >> correct way to do this? Should I just stick with finite differences or >> finite >> elements? >> >> Also, any ideas for preconditioning S? It's condition number also grows >> significantly with the continuation parameter. >> >> Thanks, >> >> Jed > -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20080409/793844d4/attachment.pgp>
