[petsc-dev] MatSetValuesStencil() and all that

Barry Smith bsmith at mcs.anl.gov
Fri Mar 19 16:37:51 CDT 2010


   MatSetValuesStencil() does a simple mapping of the stencil values  
to the local numbering and then calls MatSetValuesLocal().

   To extend this for "multiphysics" is I think pretty  
straightforward, the only difficulty will be getting all the indices  

   Currently a single stencil is attached to the matrix with  
MatSetStencil() what we will need to do is allow multiple stencils to  
be attached with multiple calls. Then we can add another field to  
MatStencil to indicate what "physics" you are putting values in  
associated with. Then the mappings in MatSetValuesStencil() (and  
blocked versions) need to be updated to properly handle the several  

   You will also need another argument (or maybe more than 1?) to  
MatSetStencil() to indicate where in the large matrix the new  
"physics" fits.

    To make the code simple I would make the mat->stencil field be an  
array of, say, 5 and introduce a mat->stencilcnt field to keep track  
of how many have been set so far. Then the new field in MatStencil  
would be used in the mapping code to select which mat->stencil[] to  
pull out.

    Can you take a look at the code and see if it is feasible for you  
to make these changes? Feel free to send email or come by my office  
with questions.


More information about the petsc-dev mailing list