Commits

Stefano Zampini  committed 83b7cca

PCBDDC: Move creation of work vector on constraints

  • Participants
  • Parent commits dcedc2a

Comments (0)

Files changed (2)

File src/ksp/pc/impls/bddc/bddc.c

       ierr = VecDuplicate(vec1_V,&vec2_V);CHKERRQ(ierr);
     }
     if (n_constraints) {
-      ierr = VecCreate(PETSC_COMM_SELF,&vec1_C);CHKERRQ(ierr);
-      ierr = VecSetSizes(vec1_C,n_constraints,n_constraints);CHKERRQ(ierr);
-      ierr = VecSetType(vec1_C,impVecType);CHKERRQ(ierr);
-      ierr = VecDuplicate(vec1_C,&vec2_C);CHKERRQ(ierr);
-      ierr = VecDuplicate(vec1_C,&pcbddc->vec1_C);CHKERRQ(ierr);
+      ierr = VecDuplicate(pcbddc->vec1_C,&vec1_C);CHKERRQ(ierr);
+      ierr = VecDuplicate(pcbddc->vec1_C,&vec2_C);CHKERRQ(ierr);
     }
     /* Precompute stuffs needed for preprocessing and application of BDDC*/
     if (n_constraints) {

File src/ksp/pc/impls/bddc/bddcprivate.c

   ierr = PCBDDCGetPrimalConstraintsLocalIdx(pc,&n_constraints,NULL);CHKERRQ(ierr);
   local_primal_size = n_constraints+n_vertices;
   n_R = pcis->n-n_vertices;
-  /* parallel work vectors used in presolve */
+  /* parallel work vectors used in presolve. TODO: move outside */
   ierr = VecDuplicate(pcis->vec1_global,&pcbddc->original_rhs);CHKERRQ(ierr);
   ierr = VecDuplicate(pcis->vec1_global,&pcbddc->temp_solution);CHKERRQ(ierr);
   /* local work vectors */
   ierr = VecSetSizes(pcbddc->vec1_R,PETSC_DECIDE,n_R);CHKERRQ(ierr);
   ierr = VecSetType(pcbddc->vec1_R,impVecType);CHKERRQ(ierr);
   ierr = VecDuplicate(pcbddc->vec1_R,&pcbddc->vec2_R);CHKERRQ(ierr);
-  ierr = VecCreate(PETSC_COMM_SELF,&pcbddc->vec1_P);CHKERRQ(ierr);
+  ierr = VecCreate(PetscObjectComm((PetscObject)pcis->vec1_N),&pcbddc->vec1_P);CHKERRQ(ierr);
   ierr = VecSetSizes(pcbddc->vec1_P,PETSC_DECIDE,local_primal_size);CHKERRQ(ierr);
   ierr = VecSetType(pcbddc->vec1_P,impVecType);CHKERRQ(ierr);
+  if (n_constraints) {
+    ierr = VecCreate(PetscObjectComm((PetscObject)pcis->vec1_N),&pcbddc->vec1_C);CHKERRQ(ierr);
+    ierr = VecSetSizes(pcbddc->vec1_C,PETSC_DECIDE,n_constraints);CHKERRQ(ierr);
+    ierr = VecSetType(pcbddc->vec1_C,impVecType);CHKERRQ(ierr);
+  }
   PetscFunctionReturn(0);
 }