Commits

Lisandro Dalcin committed a1e1626

Add error checking to IGAElementNext()

  • Participants
  • Parent commits 5f0d4bd

Comments (0)

Files changed (1)

   PetscInt *width = element->width;
   PetscInt *ID    = element->ID;
   PetscInt index,coord;
+  PetscErrorCode ierr;
   /* */
   element->nvec = 0;
   element->nmat = 0;
     index = (index - coord) / width[i];
     ID[i] = coord + start[i];
   }
-  IGAElementBuildMapping(element);
-  IGAElementBuildGeometry(element);
-  IGAElementBuildFix(element);
+#undef  CHKERR_RETURN
+#define CHKERR_RETURN(n,r) do{if(PetscUnlikely(n)){CHKERRCONTINUE(n);return(r);}}while(0)
+  ierr = IGAElementBuildMapping(element);  CHKERR_RETURN(ierr,PETSC_FALSE);
+  ierr = IGAElementBuildGeometry(element); CHKERR_RETURN(ierr,PETSC_FALSE);
+  ierr = IGAElementBuildFix(element);      CHKERR_RETURN(ierr,PETSC_FALSE);
+#undef  CHKERR_RETURN_FALSE
   return PETSC_TRUE;
 }
 
 {
   PetscFunctionBegin;
   PetscValidPointer(element,1);
-  element->index = -1;
+  if (PetscUnlikely(element->index != -1)) {
+    element->index = -1;
+    PetscFunctionReturn(PETSC_ERR_PLIB);
+  }
   PetscFunctionReturn(0);
 }