Date: 2022-03-31T04:45:57+00:00

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:     Notes:
     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()

     37: @*/
     38: PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm,PetscViewer *lab)
     39: {
     40:   PetscViewerCreate(comm,lab);
     41:   PetscViewerSetType(*lab,PETSCVIEWERSAWS);
     42:   return 0;
     43: }

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

     48:    Collective on PetscObject

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

     56:    Level: advanced

     58:    Developer Note: Currently this is called only on rank zero of PETSC_COMM_WORLD

     60:    The object must have already been named before calling this routine since naming an
     61:    object can be collective.

     63: .seealso: PetscObjectSetName(), PetscObjectSAWsViewOff()

     65: @*/
     66: PetscErrorCode  PetscObjectViewSAWs(PetscObject obj,PetscViewer viewer)
     67: {
     68:   char        dir[1024];
     69:   PetscMPIInt rank;

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

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