[petsc-dev] DMCreateMatrix_Shell
Smith, Barry F.
bsmith at mcs.anl.gov
Sat Feb 9 13:33:28 CST 2019
> On Feb 9, 2019, at 1:27 PM, Stefano Zampini <stefano.zampini at gmail.com> wrote:
>
>
>
>> On Feb 9, 2019, at 10:19 PM, Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
>>
>>
>>
>>> On Feb 9, 2019, at 11:48 AM, Stefano Zampini <stefano.zampini at gmail.com> wrote:
>>>
>>>
>>>
>>>> On Feb 9, 2019, at 11:17 AM, Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
>>>>
>>>>
>>>> Hmm, why is this check wrong (though it may be incomplete)? Is there an example where it triggers an error when it shouldn’t?
>>>
>>> Suppose in SNESSetJacobian you don’t pass a matrix, and you don’t use a DM. DMShell will give you back an AIJ matrix by default.
>>> Then, In the callback, you call MatSetType (which I presume is legal) on the matrix, with a type different than {MPI | Seq}AIJ
>>> If you then call
>>> SNESGetDM(snes,&dm)
>>> DMCreateMatrix(dm,&A)\\ error!
>>
>> Right, this is exactly what it is suppose to do. Otherwise you request a new matrix type but it returns a matrix with the default AIJ matrix, which is wrong.
>>
>
> My point is that, instead of raising the error, it should return the matrix of the same type I have set in the callback
> I know I can call DMSetMatType in the callback, but on the other hand, isn’t DMShell supposed to obey user choices?
Sure the routine could somehow be completely reworked so that it doesn't have its current limitations and can actually return back new matrices depending on the type requested. My initial response was based on me thinking one could not simply remove the error check and get proper behavior, one has to rework the routine. I have no problem with the routine being reworked.
>
> And I still don’t understand why an AIJ is fine and, as Matt pointed out, a CUSPARSE is not. Are we discriminating? :-)
This is why the comment says it is "incomplete"; it doesn't have all those other checks it could have.
>
>> Barry
>>
>>>
>>>>
>>>> It is my understanding that the check is there to make sure if the user requested a particular matrix type then it won't return a different type that is unexpected for the user (the AIJ checks are just to handle MATAIJ vs MATSEQAIJ, MATMPIAIJ).
>>>>
>>>> Barry
>>>>
>>>>
>>>>> On Feb 8, 2019, at 5:29 AM, Stefano Zampini via petsc-dev <petsc-dev at mcs.anl.gov> wrote:
>>>>>
>>>>> I don’t understand the need of these checks (tacky and incomplete…, as per the comment)
>>>>>
>>>>> https://bitbucket.org/petsc/petsc/src/75aeaa18afd73be7f3020f94b788241b9e0ba3d7/src/dm/impls/shell/dmshell.c#lines-197
>>>>>
>>>>> Why are these checks needed? I’m inclined to remove these lines, but I would like some comments before doing it.
More information about the petsc-dev
mailing list