[petsc-users] DAE user-defined Jacobian based on discretized variables

Barry Smith bsmith at mcs.anl.gov
Thu May 6 13:37:16 CDT 2010


On May 6, 2010, at 1:33 PM, Li, Zhisong (lizs) wrote:

> Hello, Barry,
> 
> Thank you for your reply. It's very helpful.
> 
> I took some FEM courses before. For actual implementation, I think we still need to know the solution variable order corresponding to the global stiffness matrix. Here is a two-dimensional 3 DOF problem. We specify 3 equations for each grid point:
> 
> for (j = yints; j < yinte; j++) {     
>    for (i = xints;  i < xinte; i++) {
>         f[j][i].u =.......;
>         f[j][i].v =......;
>         f[j][i].p =....;     }   } 
> 
> f is actually a 3-dimensional array. How can we know its order? Whether it's 
> 
> [f[0][0].u, f[0][1].u, ... f[9][9].u; f[0][0].v, f[0][1].v,...f[9][9].v; f[0][0].p, f[0][1].p,...f[9][9].p]  
> 
> or  
> 
> [f[0][0].u, f[0][0].v, f[0][0].p;   f[0][1].u, f[0][1].v, f[0][1].p; .....  ]
> 
> or any other order? 
> 
> What's the default ordering in PETSc for this case? Based on the i, j loop priority? We need to know these info in order to assemble the stiffness matrix.

   That is totally up to you. So long as you use the same ordering everywhere you can use any that you want. We highly recommend the second ordering where the u,v,p are stored interlaced.

   Barry

> 
> 
> Thank you.
> 
> 
> Zhisong Li
> 
> 
> 
> 
> 
> On May 5, 2010, at 8:46 PM, Li, Zhisong (lizs) wrote:
> 
> 
> 
>  You need to assemble the Jacobian in the usual finite element way. That assembled Jacobian is what is passed to the set Jacobian routines. (see any finite element book on assembling the global stiffness matrix from element stiffness matrices).
> 
> 
>   Barry
> 



More information about the petsc-users mailing list