Problem: User calls SNESSetDM() instead of SNESSetFunction(), then calls SNESVISetVariableBounds(). The latter function checks for snes->vec_func and errors.
We can't make SNESSetDM() create vec_func because (a) it is only logically collective and (b) the DM might not be set up yet. We can't call SNESSetUp() because that requires snes->vec_sol to have been created (with a confusing error message about aliasing). We can work around this by adding a new function SNESSetSolution(), but that's an awkward interface and SNESSetUp() does other things like call SNESSetUp_VI() which doesn't have the bounds yet. It would be simple and consistent (I think) for SNESGetFunction() to create vec_func if it is requested, does not already exist, and can be created. Then we can simply call SNESGetFunction(snes,&snes->vec_func,PETSC_NULL,PETSC_NULL); before checking whether vec_func is available yet. The problem with this is that SNESGetFunction() is currently Not Collective, and this would make it collective in that case. If it's not acceptable for SNESGetFunction() to create vec_func, then we need something like SNESSetUpFunction() that is collective and ensures that vec_func exists. I'd rather not add this extra API if it's not necessary. What should we do? (I'm asking in such a verbose way because I think we see similar issues in other places, so we can reuse the solution here in other places.) Also, why does SNESVISetVariableBounds() call SNESSetType(snes,SNSVIRS)? I didn't think we ever did this, but Barry wrote this line as part of the huge http://petsc.cs.iit.edu/petsc/petsc-dev/rev/31c8ce41 , so I don't know what to think. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20111221/568bc30f/attachment.html>
