/*@C MatFDColoringView - Views a finite difference coloring context. Collective on MatFDColoring Input Parameters: + c - the coloring context - viewer - visualization context Level: intermediate Notes: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) . PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. - PETSC_VIEWER_DRAW_WORLD - graphical display of nonzero structure Notes: Since PETSc uses only a small number of basic colors (currently 33), if the coloring involves more than 33 then some seemingly identical colors are displayed making it look like an illegal coloring. This is just a graphical artifact. .seealso: MatFDColoringCreate() .keywords: Mat, finite differences, coloring, view @*/ PetscErrorCode MatFDColoringView(MatFDColoring c,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i,j; PetscBool isdraw,iascii; PetscViewerFormat format; PetscFunctionBegin; PetscValidHeaderSpecific(c,MAT_FDCOLORING_CLASSID,1); if (!viewer) { ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)c),&viewer);CHKERRQ(ierr); } PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(c,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr); if (isdraw) { ierr = MatFDColoringView_Draw(c,viewer);CHKERRQ(ierr); } else if (iascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)c,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Error tolerance=%g\n",(double)c->error_rel);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Umin=%g\n",(double)c->umin);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Number of colors=%D\n",c->ncolors);CHKERRQ(ierr); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format != PETSC_VIEWER_ASCII_INFO) { PetscInt row,col,nz; nz = 0; for (i=0; i<c->ncolors; i++) { ierr = PetscViewerASCIIPrintf(viewer," Information for color %D\n",i);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Number of columns %D\n",c->ncolumns[i]);CHKERRQ(ierr); for (j=0; j<c->ncolumns[i]; j++) { ierr = PetscViewerASCIIPrintf(viewer," %D\n",c->columns[i][j]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," Number of rows %D\n",c->nrows[i]);CHKERRQ(ierr); for (j=0; j<c->nrows[i]; j++) { row = c->matentry[nz].row; col = c->matentry[nz++].col; ierr = PetscViewerASCIIPrintf(viewer," %D %D \n",row,col);CHKERRQ(ierr); } } } ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); }
/*@C MatFDColoringView - Views a finite difference coloring context. Collective on MatFDColoring Input Parameters: + c - the coloring context - viewer - visualization context Level: intermediate Notes: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) . PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. - PETSC_VIEWER_DRAW_WORLD - graphical display of nonzero structure Notes: Since PETSc uses only a small number of basic colors (currently 33), if the coloring involves more than 33 then some seemingly identical colors are displayed making it look like an illegal coloring. This is just a graphical artifact. .seealso: MatFDColoringCreate() .keywords: Mat, finite differences, coloring, view @*/ PetscErrorCode MatFDColoringView(MatFDColoring c,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i,j; PetscBool isdraw,iascii; PetscViewerFormat format; PetscFunctionBegin; PetscValidHeaderSpecific(c,MAT_FDCOLORING_CLASSID,1); if (!viewer) { ierr = PetscViewerASCIIGetStdout(((PetscObject)c)->comm,&viewer);CHKERRQ(ierr); } PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(c,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr); if (isdraw) { ierr = MatFDColoringView_Draw(c,viewer);CHKERRQ(ierr); } else if (iascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)c,viewer,"MatFDColoring Object");CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Error tolerance=%G\n",c->error_rel);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Umin=%G\n",c->umin);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Number of colors=%D\n",c->ncolors);CHKERRQ(ierr); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format != PETSC_VIEWER_ASCII_INFO) { for (i=0; i<c->ncolors; i++) { ierr = PetscViewerASCIIPrintf(viewer," Information for color %D\n",i);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Number of columns %D\n",c->ncolumns[i]);CHKERRQ(ierr); for (j=0; j<c->ncolumns[i]; j++) { ierr = PetscViewerASCIIPrintf(viewer," %D\n",c->columns[i][j]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," Number of rows %D\n",c->nrows[i]);CHKERRQ(ierr); for (j=0; j<c->nrows[i]; j++) { ierr = PetscViewerASCIIPrintf(viewer," %D %D \n",c->rows[i][j],c->columnsforrow[i][j]);CHKERRQ(ierr); } } } ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); } else { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Viewer type %s not supported for MatFDColoring",((PetscObject)viewer)->type_name); } PetscFunctionReturn(0); }