[petsc-dev] Two question about DM API

Smith, Barry F. bsmith at mcs.anl.gov
Fri Jul 5 01:11:07 CDT 2019


   Lisandro,

    Both plans look good to me. Remove DMCreateAggregates completely and reactor DMHasCreateInjection.

   Barry


> On Jul 4, 2019, at 9:32 AM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> 
> Dear Barry,
> 
> 1) Do we still need this? It is totally untested, from the docs it seems it may be redundant
> 
> $ git grep DMCreateAggregates
> include/petscdm.h:PETSC_EXTERN PetscErrorCode DMCreateAggregates(DM,DM,Mat*);
> src/dm/impls/da/dacreate.c:extern PetscErrorCode  DMCreateAggregates_DA(DM,DM,Mat*);
> src/dm/impls/da/dacreate.c:  da->ops->getaggregates               = DMCreateAggregates_DA;
> src/dm/impls/da/dainterp.c:PetscErrorCode  DMCreateAggregates_DA(DM dac,DM daf,Mat *rest)
> src/dm/interface/dm.c:   DMCreateAggregates - Gets the aggregates that map between
> src/dm/interface/dm.c:PetscErrorCode  DMCreateAggregates(DM dmc, DM dmf, Mat *rest)
> 
> 2) Why don't we implement DMHasCreateInjection_Default() this way?
> 
> static PetscErrorCode DMHasCreateInjection_Default(DM dm, PetscBool *flg)
> {
>   PetscFunctionBegin;
>   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
>   PetscValidPointer(flg,2);
>   *flg = dm->ops->getinjection ? PETSC_TRUE : PETSC_FALSE;
>   PetscFunctionReturn(0);
> }
> 
> This way we can keep the one in DMDA, perhaps the one in SNESVI, and remove all the other type specific implementations.
> 
> Or maybe even better, we should get rid of DMHasCreateInjection_Default(), and do things this simple and obvious way:
> 
> PetscErrorCode  DMHasCreateInjection(DM dm,PetscBool  *flg)
> {
>   PetscErrorCode ierr;
>   PetscFunctionBegin;
>   if (dm->ops->hascreateinjection) {
>     ierr = (*dm->ops->hascreateinjection)(dm,flg);CHKERRQ(ierr);
>   } else {
>     *flg = dm->ops->getinjection ? PETSC_TRUE : PETSC_FALSE;
>   }
>   PetscFunctionReturn(0);
> }
> 
> and of course rename m->ops->getinjection to dm->ops->createinjection, because the inconsistency offends my little mind.
>  
> Am I missing something about this one?
> 
> 
> -- 
> Lisandro Dalcin
> ============
> Research Scientist
> Extreme Computing Research Center (ECRC)
> King Abdullah University of Science and Technology (KAUST)
> http://ecrc.kaust.edu.sa/



More information about the petsc-dev mailing list