[petsc-dev] Overzealous guards in DMGetInjection_DA

Jed Brown jed at 59A2.org
Mon Feb 21 15:37:29 CST 2011


  ierr =
DMDAGetInfo(dac,&dimc,&Mc,&Nc,&Pc,&mc,&nc,&pc,&dofc,&sc,&wrapc,&stc);CHKERRQ(ierr);
  ierr =
DMDAGetInfo(daf,&dimf,&Mf,&Nf,&Pf,&mf,&nf,&pf,&doff,&sf,&wrapf,&stf);CHKERRQ(ierr);
  if (dimc != dimf)
SETERRQ2(((PetscObject)daf)->comm,PETSC_ERR_ARG_INCOMP,"Dimensions of DMDA
do not match %D %D",dimc,dimf);CHKERRQ(ierr);
  if (dofc != doff)
SETERRQ2(((PetscObject)daf)->comm,PETSC_ERR_ARG_INCOMP,"DOF of DMDA do not
match %D %D",dofc,doff);CHKERRQ(ierr);
  if (sc != sf)
SETERRQ2(((PetscObject)daf)->comm,PETSC_ERR_ARG_INCOMP,"Stencil width of
DMDA do not match %D %D",sc,sf);CHKERRQ(ierr);
  if (wrapc != wrapf)
SETERRQ(((PetscObject)daf)->comm,PETSC_ERR_ARG_INCOMP,"Periodic type
different in two DMDAs");CHKERRQ(ierr);
  if (stc != stf)
SETERRQ(((PetscObject)daf)->comm,PETSC_ERR_ARG_INCOMP,"Stencil type
different in two DMDAs");CHKERRQ(ierr);
  if (Mc < 2) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Coarse grid
requires at least 2 points in x direction");
  if (dimc > 1 && Nc < 2)
SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Coarse grid requires at
least 2 points in y direction");
  if (dimc > 2 && Pc < 2)
SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Coarse grid requires at
least 2 points in z direction");

Several of these are not necessary. DMGetInjection_DA_3D:

  ierr = DMDAGetInfo(dac,0,&Mx,&My,&Mz,0,0,0,0,0,&pt,0);CHKERRQ(ierr);
  ierr = DMDAGetInfo(daf,0,&mx,&my,&mz,0,0,0,&dof,0,0,0);CHKERRQ(ierr);

Seems silly to fail when not necessary. I'm inclined to move the guards into
the specific implementation so that only the necessary amount of consistency
needs to be checked. How about getting rid of DMGetInjection_DA entirely and
just set the appropriate ops slot?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110221/5c2aa85f/attachment.html>


More information about the petsc-dev mailing list