1 2 #include <petsc/private/viewerimpl.h> /*I "petscsys.h" */ 3 #include <petscviewersaws.h> 4 5 /*@C 6 PetscViewerSAWsOpen - Opens an SAWs `PetscViewer`. 7 8 Collective; No Fortran Support 9 10 Input Parameters: 11 . comm - the MPI communicator 12 13 Output Parameter: 14 . lab - the `PetscViewer` 15 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 21 22 Level: advanced 23 24 Notes: 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()`. 28 29 Information about the SAWs is available via https://bitbucket.org/saws/saws 30 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 PetscFunctionBegin; 37 PetscCall(PetscViewerCreate(comm, lab)); 38 PetscCall(PetscViewerSetType(*lab, PETSCVIEWERSAWS)); 39 PetscFunctionReturn(PETSC_SUCCESS); 40 } 41 42 /*@C 43 PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer 44 45 Collective 46 47 Input Parameters: 48 + obj - the `PetscObject` variable. Thus must be cast with a (`PetscObject`), for example, `PetscObjectSetName`((`PetscObject`)mat,name); 49 - viewer - the SAWs viewer 50 51 Level: advanced 52 53 Note: 54 The object must have already been named before calling this routine since naming an 55 object can be collective. 56 57 Developer Note: 58 Currently this is called only on rank zero of `PETSC_COMM_WORLD` 59 60 .seealso: [](sec_viewers), `PetscViewer`, `PetscObject`, `PetscObjectSetName()`, `PetscObjectSAWsViewOff()` 61 @*/ 62 PetscErrorCode PetscObjectViewSAWs(PetscObject obj, PetscViewer viewer) 63 { 64 char dir[1024]; 65 PetscMPIInt rank; 66 67 PetscFunctionBegin; 68 PetscValidHeader(obj, 1); 69 if (obj->amsmem) PetscFunctionReturn(PETSC_SUCCESS); 70 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank)); 71 PetscCheck(rank == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Should only be being called on rank zero"); 72 PetscCheck(obj->name, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Object must already have been named"); 73 74 obj->amsmem = PETSC_TRUE; 75 PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Class", obj->name)); 76 PetscCallSAWs(SAWs_Register, (dir, &obj->class_name, 1, SAWs_READ, SAWs_STRING)); 77 PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Type", obj->name)); 78 PetscCallSAWs(SAWs_Register, (dir, &obj->type_name, 1, SAWs_READ, SAWs_STRING)); 79 PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/__Id", obj->name)); 80 PetscCallSAWs(SAWs_Register, (dir, &obj->id, 1, SAWs_READ, SAWs_INT)); 81 PetscFunctionReturn(PETSC_SUCCESS); 82 } 83