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

 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:     Fortran Note:
 25:     This routine is not supported in Fortran.

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

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

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

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

 47:    Collective on obj

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

 53:    Level: advanced

 55:    Note:
 56:    The object must have already been named before calling this routine since naming an
 57:    object can be collective.

 59:    Developer Note:
 60:    Currently this is called only on rank zero of `PETSC_COMM_WORLD`

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

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

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