Barry, I agree that an array of stencils makes sense, and at introducing each stencil we would have the user indicate the name of the model it is associated with. Then every call to MatSetValuesStencil would have an optional argument for the model name, or more likely we'd make a MatSetValuesStencilMP rather than overloading MatSetValuesStencil.
It will probably be striaghtforward to say where in the large matrix the new physics fits, but I don't think it's trivial to handle the indices for the off-diagonal blocks because the coupling could be arbitrarily complicated. I'll take a look at this and see what I can do. -Mike ----- Original Message ----- From: "Barry Smith" <[email protected]> To: "Mike McCourt" <mccomic at mcs.anl.gov>, "Lois Curfman McInnes" <curfman at mcs.anl.gov>, "For users of the development version of PETSc" <petsc-dev at mcs.anl.gov> Sent: Friday, March 19, 2010 4:37:51 PM GMT -06:00 US/Canada Central Subject: MatSetValuesStencil() and all that Mike, 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 right. 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 "physics". 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. Barry
