/*@C PetscViewerDrawOpen - Opens a window for use as a PetscViewer. If you want to do graphics in this window, you must call PetscViewerDrawGetDraw() and perform the graphics on the PetscDraw object. Collective on MPI_Comm Input Parameters: + comm - communicator that will share window . display - the X display on which to open, or null for the local machine . title - the title to put in the title bar, or null for no title . x, y - the screen coordinates of the upper left corner of window, or use PETSC_DECIDE - w, h - window width and height in pixels, or may use PETSC_DECIDE or PETSC_DRAW_FULL_SIZE, PETSC_DRAW_HALF_SIZE, PETSC_DRAW_THIRD_SIZE, PETSC_DRAW_QUARTER_SIZE Output Parameters: . viewer - the PetscViewer Format Options: + PETSC_VIEWER_DRAW_BASIC - displays with basic format - PETSC_VIEWER_DRAW_LG - displays using a line graph Options Database Keys: PetscViewerDrawOpen() calls PetscDrawCreate(), so see the manual page for PetscDrawCreate() for runtime options, including + -draw_type x or null . -nox - Disables all x-windows output . -display <name> - Specifies name of machine for the X display . -geometry <x,y,w,h> - allows setting the window location and size - -draw_pause <pause> - Sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input). Level: beginner Note for Fortran Programmers: Whenever indicating null character data in a Fortran code, NULL_CHARACTER must be employed; using NULL is not correct for character data! Thus, NULL_CHARACTER can be used for the display and title input parameters. Concepts: graphics^opening PetscViewer Concepts: drawing^opening PetscViewer .seealso: PetscDrawCreate(), PetscViewerDestroy(), PetscViewerDrawGetDraw(), PetscViewerCreate(), PETSC_VIEWER_DRAW_, PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF @*/ PetscErrorCode PetscViewerDrawOpen(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscViewer *viewer) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerCreate(comm,viewer);CHKERRQ(ierr); ierr = PetscViewerSetType(*viewer,PETSCVIEWERDRAW);CHKERRQ(ierr); ierr = PetscViewerDrawSetInfo(*viewer,display,title,x,y,w,h);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C KSPGMRESMonitorKrylov - Calls VecView() for each direction in the GMRES accumulated Krylov space. Collective on KSP Input Parameters: + ksp - the KSP context . its - iteration number . fgnorm - 2-norm of residual (or gradient) - a viewers object created with PetscViewersCreate() Level: intermediate .keywords: KSP, nonlinear, vector, monitor, view, Krylov space .seealso: KSPMonitorSet(), KSPMonitorDefault(), VecView(), PetscViewersCreate(), PetscViewersDestroy() @*/ PetscErrorCode KSPGMRESMonitorKrylov(KSP ksp,PetscInt its,PetscReal fgnorm,void *dummy) { PetscViewers viewers = (PetscViewers)dummy; KSP_GMRES *gmres = (KSP_GMRES*)ksp->data; PetscErrorCode ierr; Vec x; PetscViewer viewer; PetscBool flg; PetscFunctionBegin; ierr = PetscViewersGetViewer(viewers,gmres->it+1,&viewer);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&flg);CHKERRQ(ierr); if (!flg) { ierr = PetscViewerSetType(viewer,PETSCVIEWERDRAW);CHKERRQ(ierr); ierr = PetscViewerDrawSetInfo(viewer,NULL,"Krylov GMRES Monitor",PETSC_DECIDE,PETSC_DECIDE,300,300);CHKERRQ(ierr); } x = VEC_VV(gmres->it+1); ierr = VecView(x,viewer);CHKERRQ(ierr); PetscFunctionReturn(0); }