[petsc-dev] Promote MatShellSetOperation() and MatShellSetContext() to Mat
Barry Smith
bsmith at mcs.anl.gov
Mon Jun 6 14:21:41 CDT 2011
On Jun 6, 2011, at 1:32 PM, Jed Brown wrote:
> On Mon, Jun 6, 2011 at 19:57, Barry Smith <bsmith at mcs.anl.gov> wrote:
> I am not yet comfortable with a MatSetApplicationContext() nor a VecSetApplicationContext(). I do think it makes sense to have a PCSetApplicationContext().
>
> Should the "solver" application contexts be unified in the following way.
>
> TSSetApplicationContext() calls SNESSetApplicationContext() calls KSPSetApplicationContext() calls PCSetApplicationContext(). And users with nonlinear problems call SNESSetApplicationContext() directly and linear problems call KSPSetApplicationContext() directly, of course.
>
> What about nested linear (or nonlinear) solvers? Does the app context get forwarded in at each level?
Yes, that is the whole point (in the same way I want DM's propagated down inside mulgrid and fieldsplit created subksps and pcs) So for example it can be set in the main program into the SNES (or TS) and is accessible deep inside some nested preconditioner that is a problem specific PC beasty thing.
> What happens when a component is accessed from multiple places?
Not sure what you mean by multiple places.
>
> I wonder if this forwarding should be made to not overwrite what is already there. That is, if the user sets it explicitly, then it will not be overwritten by a parent.
Hmm, yes this gets tricky. I general I think it should overwrite and the user needs to set it differently if they want after they set it on the outside. So they do TSSetApplicationContext() and then TSGetSNES, SNESGetKSP, KSPGetPC etc etc to change it down there.
>
>
> Meanwhile DMSetContext() is changed to DMSetApplicationContext(), while MatShellSetContext() remains MatShellSetContext(). Note that it does not have application in it because it is the MatShell context only.
>
> How should MatShellSetOperation behave? Should it error or do nothing when the matrix type is not MATSHELL?
Error
> If the current behavior is to be preserved, what is your recommended way to get a context into the function overloading a method on a non-MATSHELL Mat?
PetscObjectCompose()
If there is one particular pattern of a non-MATSHELL matrix needing a user provided function overloading on a regular basis we need to examine that pattern and see what is most appropriate.
Barry
Barry
More information about the petsc-dev
mailing list