[petsc-users] How to construct Jacobian for multicomponent problem ?

Christophe Ortiz christophe.ortiz at ciemat.es
Wed Sep 25 06:31:12 CDT 2013


Hi guys,

Please apologize if this question has already been raised in previous posts.

I am developing a code in fortran 90 to solve a 1D multicomponent problem.
For instance, something like

u_t = u_xx + R(u,v)
v_t = v_xx + R(u,v)

I have already implemented this for one component (u) and using DMDA. So
far no problem. It works fine.

Now I am trying to implement several components per node. Following example
ex22f.F, for the residual function I would have for node i (1D)

F(1,i) = ....
F(2,i) = ....

Now, I am not quite sure to understand how to construct the Jacobian when
there are various components. In this case, how is the vector in PETSc ?

Is it a long vector like (u0, u1, ..., umx-1 , v0, v1, ..., vmx-1) ?
Or is it (u0, v0, u1, v1, u2, v2, ....., umx-1, vmx-1) ?

I don't understand the order of the components of the Jacobian and how to
fill the matrix in that case.

For instance, for the first row of the Jacobian, should I calculate
dFu0/du0, dFu0/dFu1, ...., dFu0/dumx-1, dFu0/dv0, dFu0/dv1.....

or

dFu0/du0, dFu0/dv0, dFu0/du1, dFu0/dv1, ....

And then, which subroutine should I use to fill in the Matrix ? Simply
MatSetValues ?

Many thanks in advance for your help.

Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130925/07e1d846/attachment.html>


More information about the petsc-users mailing list