Actual source code: amsopen.c


  2: #include <petsc/private/viewerimpl.h>
  3: #include <petscviewersaws.h>

  5: /*@C
  6:     PetscViewerSAWsOpen - Opens an SAWs `PetscViewer`.

  8:     Collective; No Fortran Support

 10:     Input Parameters:
 11: .   comm - the MPI communicator

 13:     Output Parameter:
 14: .   lab - the `PetscViewer`

 16:     Options Database Keys:
 17: +   -saws_port <port number> - port number where you are running SAWs client
 18: .   -xxx_view saws - publish the object xxx
 19: -   -xxx_saws_block - blocks the program at the end of a critical point (for KSP and SNES it is the end of a solve) until
 20:                     the user unblocks the problem with an external tool that access the object with SAWS

 22:     Level: advanced

 24:     Note:
 25:     Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the SAWs viewer allows
 26:     one to view the object asynchronously as the program continues to run. One can remove SAWs access to the object with a call to
 27:     `PetscObjectSAWsViewOff()`.

 29:     Information about the SAWs is available via https://bitbucket.org/saws/saws

 31: .seealso: [](sec_viewers), `PetscViewerDestroy()`, `PetscViewerStringSPrintf()`, `PETSC_VIEWER_SAWS_()`, `PetscObjectSAWsBlock()`,
 32:           `PetscObjectSAWsViewOff()`, `PetscObjectSAWsTakeAccess()`, `PetscObjectSAWsGrantAccess()`
 33: @*/
 34: PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm, PetscViewer *lab)
 35: {
 36:   PetscViewerCreate(comm, lab);
 37:   PetscViewerSetType(*lab, PETSCVIEWERSAWS);
 38:   return 0;
 39: }

 41: /*@C
 42:    PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer

 44:    Collective

 46:    Input Parameters:
 47: +  obj - the `PetscObject` variable. Thus must be cast with a (`PetscObject`), for example, `PetscObjectSetName`((`PetscObject`)mat,name);
 48: -  viewer - the SAWs viewer

 50:    Level: advanced

 52:    Note:
 53:    The object must have already been named before calling this routine since naming an
 54:    object can be collective.

 56:    Developer Note:
 57:    Currently this is called only on rank zero of `PETSC_COMM_WORLD`

 59: .seealso: [](sec_viewers), `PetscViewer`, `PetscObject`, `PetscObjectSetName()`, `PetscObjectSAWsViewOff()`
 60: @*/
 61: PetscErrorCode PetscObjectViewSAWs(PetscObject obj, PetscViewer viewer)
 62: {
 63:   char        dir[1024];
 64:   PetscMPIInt rank;

 67:   if (obj->amsmem) return 0;
 68:   MPI_Comm_rank(PETSC_COMM_WORLD, &rank);

 72:   obj->amsmem = PETSC_TRUE;
 73:   PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Class", obj->name);
 74:   SAWs_Register, (dir, &obj->class_name, 1, SAWs_READ, SAWs_STRING);
 75:   PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Type", obj->name);
 76:   SAWs_Register, (dir, &obj->type_name, 1, SAWs_READ, SAWs_STRING);
 77:   PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/__Id", obj->name);
 78:   SAWs_Register, (dir, &obj->id, 1, SAWs_READ, SAWs_INT);
 79:   return 0;
 80: }