Commits

Jed Brown  committed 401b765

Mat: remove 'vec' member of MatNullSpace

We no longer support out-of-place removal, so this field is only
relevant in MatNullSpaceTest. Might as well simplify the data structure
and free the memory earlier.

  • Participants
  • Parent commits d019563

Comments (0)

Files changed (2)

File include/petsc-private/matimpl.h

   PetscInt       n;
   Vec*           vecs;
   PetscScalar*   alpha;                 /* for projections */
-  Vec            vec;                   /* for out of place removals */
   PetscErrorCode (*remove)(MatNullSpace,Vec,void*);  /* for user provided removal function */
   void*          rmctx;                 /* context for remove() function */
 };

File src/mat/interface/matnull.c

   sp->n        = n;
   sp->vecs     = 0;
   sp->alpha    = 0;
-  sp->vec      = 0;
   sp->remove   = 0;
   sp->rmctx    = 0;
 
   PetscValidHeaderSpecific((*sp),MAT_NULLSPACE_CLASSID,1);
   if (--((PetscObject)(*sp))->refct > 0) {*sp = 0; PetscFunctionReturn(0);}
 
-  ierr = VecDestroy(&(*sp)->vec);CHKERRQ(ierr);
   ierr = VecDestroyVecs((*sp)->n,&(*sp)->vecs);CHKERRQ(ierr);
   ierr = PetscFree((*sp)->alpha);CHKERRQ(ierr);
   ierr = PetscHeaderDestroy(sp);CHKERRQ(ierr);
   ierr = PetscOptionsGetBool(NULL,"-mat_null_space_test_view",&flg1,NULL);CHKERRQ(ierr);
   ierr = PetscOptionsGetBool(NULL,"-mat_null_space_test_view_draw",&flg2,NULL);CHKERRQ(ierr);
 
-  if (!sp->vec) {
-    if (n) {
-      ierr = VecDuplicate(sp->vecs[0],&sp->vec);CHKERRQ(ierr);
-    } else {
-      ierr = MatGetVecs(mat,&sp->vec,NULL);CHKERRQ(ierr);
-    }
+  if (n) {
+    ierr = VecDuplicate(sp->vecs[0],&l);CHKERRQ(ierr);
+  } else {
+    ierr = MatGetVecs(mat,&l,NULL);CHKERRQ(ierr);
   }
-  l = sp->vec;
 
   ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)sp),&viewer);CHKERRQ(ierr);
   if (sp->has_cnst) {
   }
 
   if (sp->remove) SETERRQ(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Cannot test a null space provided as a function with MatNullSpaceSetFunction()");
+  ierr = VecDestroy(&l);CHKERRQ(ierr);
   if (isNull) *isNull = consistent;
   PetscFunctionReturn(0);
 }