[petsc-dev] Suggestions for MatProductCreate()

Lisandro Dalcin dalcinl at gmail.com
Mon Mar 23 16:11:11 CDT 2020


On Mon, 23 Mar 2020 at 17:57, hzhang at mcs.anl.gov <hzhang at mcs.anl.gov> wrote:

> Lisandro:
>
>> MatProductSetFromOptions() is not really setting any options. It looks
>> like the correct name for this API is MatProductSetUp(). In any case, it
>> looks like both SetFromOptions() and SetUp() should be provided.
>>
>
> Not all product and matrix types enable algorithmic options. For those who
> do have options,
> MatProductSetFromOptions_mattype_producttype() enables it.
> See MatProductSetFromOptions_MPIAIJ_AB().
>

I have to insist, you should separate SetFromOptions() from SetUp(). For
many types, SetFromOptions may be empty (you can even use a NULL pointer to
handle these cases), but the rest of the code that does setup stuff (that
is, preparing the data structures) should go SetUp() routines.
This design pattern is used everywhere in PETSc. That's the proper way to
do it, IMHO. This way is the one that gives maximum flexibility to power
users/developers, because some times developers may want to configure
objects with some parameters, and do a SetUp() without calling
SetFromOptions() to prevent users to mess up with the parameters the
developer carefully chose.



-- 
Lisandro Dalcin
============
Research Scientist
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200324/89dd936e/attachment.html>


More information about the petsc-dev mailing list