Commits

Hong Zhang committed 22e94b5

add !usecoloring implementation for MatRARt_seqaij_seqaij(); bugfix for the test '-use_rart'

  • Participants
  • Parent commits c545920

Comments (0)

Files changed (2)

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

         for (level=pc_gamg->Nlevels-2; level>=0; level--) {
           /* the first time through the matrix structure has changed from repartitioning */
           if (pc_gamg->setup_count==2 && (pc_gamg->repart || level==0)) {
-            
             if (!rart) {
-            ierr = MatPtAP(dB,mglevels[level+1]->interpolate,MAT_INITIAL_MATRIX,1.0,&B);CHKERRQ(ierr);
+              ierr = MatPtAP(dB,mglevels[level+1]->interpolate,MAT_INITIAL_MATRIX,1.0,&B);CHKERRQ(ierr);
             } else { /* Use RARt */
               Mat R;
               ierr = MatTranspose(mglevels[level+1]->interpolate,MAT_INITIAL_MATRIX,&R);CHKERRQ(ierr);
             mglevels[level]->A = B;
           } else {
             ierr = KSPGetOperators(mglevels[level]->smoothd,NULL,&B,NULL);CHKERRQ(ierr);
-            ierr = MatPtAP(dB,mglevels[level+1]->interpolate,MAT_REUSE_MATRIX,1.0,&B);CHKERRQ(ierr);
+            if (!rart) {
+              ierr = MatPtAP(dB,mglevels[level+1]->interpolate,MAT_REUSE_MATRIX,1.0,&B);CHKERRQ(ierr);
+             } else { /* Use RARt */
+              Mat R;
+              ierr = MatTranspose(mglevels[level+1]->interpolate,MAT_INITIAL_MATRIX,&R);CHKERRQ(ierr);
+              ierr = MatRARt(dB, R, MAT_REUSE_MATRIX, 1.0, &B);CHKERRQ(ierr);
+              ierr = MatDestroy(&R);CHKERRQ(ierr);
+            } 
           }
           ierr = KSPSetOperators(mglevels[level]->smoothd,B,B,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
           dB   = B;

File src/mat/impls/aij/seq/matrart.c

   ierr   = PetscTime(&tf);CHKERRQ(ierr);
   etime += tf - t0;
 
+  /* ------ Use coloring ---------- */
   /* Create MatTransposeColoring from symbolic C=R*A*R^T */
   c       = (Mat_SeqAIJ*)(*C)->data;
   ierr    = PetscTime(&t0);CHKERRQ(ierr);
   ierr = PetscObjectQuery((PetscObject)C,"Mat_RARt",(PetscObject*)&container);CHKERRQ(ierr);
   if (!container) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Container does not exit");
   ierr = PetscContainerGetPointer(container,(void**)&rart);CHKERRQ(ierr);
-
+  
   /* Get dense Rt by Apply MatTransposeColoring to R */
   matcoloring = rart->matcoloring;
   Rt          = rart->Rt;
 PetscErrorCode MatRARt_SeqAIJ_SeqAIJ(Mat A,Mat R,MatReuse scall,PetscReal fill,Mat *C)
 {
   PetscErrorCode ierr;
+  PetscBool      usecoloring = PETSC_TRUE;
 
   PetscFunctionBegin;
+  ierr = PetscOptionsGetBool(NULL,"-matrart_color",&usecoloring,NULL);CHKERRQ(ierr);
+
+  if (!usecoloring) {
+    Mat Rt;
+    ierr = MatTranspose(R,MAT_INITIAL_MATRIX,&Rt);CHKERRQ(ierr); /* replace MAT_INITIAL_MATRIX with scall if !usecoloring is better */
+    ierr = MatMatMatMult(R,A,Rt,scall,fill,C);CHKERRQ(ierr);
+    ierr = MatDestroy(&Rt);CHKERRQ(ierr); 
+    PetscFunctionReturn(0);
+  }
+
+  /* use coloring */
   if (scall == MAT_INITIAL_MATRIX) {
     ierr = MatRARtSymbolic_SeqAIJ_SeqAIJ(A,R,fill,C);CHKERRQ(ierr);
   }