[petsc-dev] A prototype for multi-physics coupling

Jed Brown jed at 59A2.org
Fri Nov 26 13:23:51 CST 2010


I encourage you to take a look at src/snes/examples/tutorials/ex28.c.  It
solves the following coupled system [*]

 PDE (U):
     -(k u_x)_x = 1 on (0,1), subject to u(0) = 0, u(1) = 1
 Algebraic (K):
     exp(k) + k = u + 1/(1 + u_x^2)

and each part separately, with identical assembly code.  An analytic
Jacobian is available in all cases.  Change between solving individual
physics and coupled with -problem_type 0,1,2.  The assembly interface is
particularly notable because the same code can also assemble into a MatNest,
which is based, on Dave May's "Block" matrix from PETScExt.  The primary
advantage of MatNest is that getting the submatrices used in a fieldsplit
preconditioner is trivially cheap.  Currently DMGetMatrix_Composite_Nest
does not allocate off-diagonal blocks so we are limited to additive
fieldsplits, but when we sort out the preallocation API, this code will work
with the other fieldsplit variants.

  cd src/snes/examples/tutorials && make ex28
  mpiexec -n 2 ./ex28 -da_grid_x 100 -{snes,ksp}_converged_reason
-snes_monitor_short -problem_type 2 -pack_dm_mat_type nest -snes_mf_operator
-pc_type fieldsplit -pc_fieldsplit_type additive -fieldsplit_u_pc_type ml
-fieldsplit_k_pc_type jacobi

This assembles directly into the "best" structure for FieldSplit to work
with, there are no intermediate copies.  Note that if the submatrices have
extra structure, like (S)BAIJ, you can use them inside the blocks and use
MatSetValuesBlockedLocal for assembly.  This blocked assembly will also work
when you want to assemble the whole thing and use a direct solver, as in

  mpiexec -n 2 ./ex28 -da_grid_x 100 -{snes,ksp}_converged_reason
-snes_monitor_short -problem_type 2 -pc_type lu
-pc_factor_mat_solver_package mumps

Jed

[*] I have no idea if this "physics" is stable.  I think it is not based on
floating-point errors at very high resolution, but if you keep problem size
under 1000 or so, the solution does not blow up.  Suggestions for something
of similar form, with interesting nonlinearities and a not completely boring
solution profile, are certainly welcome.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101126/a653d8f7/attachment.html>


More information about the petsc-dev mailing list