15c6c1daeSBarry Smith 2af0996ceSBarry Smith #include <petsc/private/viewerimpl.h> /*I "petscsys.h" */ 3e04113cfSBarry Smith #include <petscviewersaws.h> 45c6c1daeSBarry Smith 55c6c1daeSBarry Smith /*@C 6811af0c4SBarry Smith PetscViewerSAWsOpen - Opens an SAWs `PetscViewer`. 75c6c1daeSBarry Smith 8*cf53795eSBarry Smith Collective; No Fortran Support 95c6c1daeSBarry Smith 105c6c1daeSBarry Smith Input Parameters: 11ec957eceSBarry Smith . comm - the MPI communicator 125c6c1daeSBarry Smith 135c6c1daeSBarry Smith Output Parameter: 14811af0c4SBarry Smith . lab - the `PetscViewer` 155c6c1daeSBarry Smith 165c6c1daeSBarry Smith Options Database Keys: 17f7b25cf6SBarry Smith + -saws_port <port number> - port number where you are running SAWs client 18f7b25cf6SBarry Smith . -xxx_view saws - publish the object xxx 19e04113cfSBarry Smith - -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 20f7b25cf6SBarry Smith the user unblocks the problem with an external tool that access the object with SAWS 215c6c1daeSBarry Smith 225c6c1daeSBarry Smith Level: advanced 235c6c1daeSBarry Smith 24811af0c4SBarry Smith Note: 25e04113cfSBarry Smith Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the SAWs viewer allows 26e04113cfSBarry Smith one to view the object asynchronously as the program continues to run. One can remove SAWs access to the object with a call to 27811af0c4SBarry Smith `PetscObjectSAWsViewOff()`. 2838dc1537SBarry Smith 29a8d69d7bSBarry Smith Information about the SAWs is available via https://bitbucket.org/saws/saws 305c6c1daeSBarry Smith 31db781477SPatrick Sanan .seealso: `PetscViewerDestroy()`, `PetscViewerStringSPrintf()`, `PETSC_VIEWER_SAWS_()`, `PetscObjectSAWsBlock()`, 32db781477SPatrick Sanan `PetscObjectSAWsViewOff()`, `PetscObjectSAWsTakeAccess()`, `PetscObjectSAWsGrantAccess()` 335c6c1daeSBarry Smith @*/ 34d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm, PetscViewer *lab) 35d71ae5a4SJacob Faibussowitsch { 365c6c1daeSBarry Smith PetscFunctionBegin; 379566063dSJacob Faibussowitsch PetscCall(PetscViewerCreate(comm, lab)); 389566063dSJacob Faibussowitsch PetscCall(PetscViewerSetType(*lab, PETSCVIEWERSAWS)); 395c6c1daeSBarry Smith PetscFunctionReturn(0); 405c6c1daeSBarry Smith } 41bfb97211SBarry Smith 42bfb97211SBarry Smith /*@C 43e04113cfSBarry Smith PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer 44bfb97211SBarry Smith 45c3339decSBarry Smith Collective 46bfb97211SBarry Smith 47bfb97211SBarry Smith Input Parameters: 48811af0c4SBarry Smith + obj - the `PetscObject` variable. Thus must be cast with a (`PetscObject`), for example, `PetscObjectSetName`((`PetscObject`)mat,name); 49e04113cfSBarry Smith - viewer - the SAWs viewer 50bfb97211SBarry Smith 51bfb97211SBarry Smith Level: advanced 52bfb97211SBarry Smith 53811af0c4SBarry Smith Note: 54d45a07a7SBarry Smith The object must have already been named before calling this routine since naming an 55d45a07a7SBarry Smith object can be collective. 56d45a07a7SBarry Smith 57811af0c4SBarry Smith Developer Note: 58811af0c4SBarry Smith Currently this is called only on rank zero of `PETSC_COMM_WORLD` 59bfb97211SBarry Smith 60811af0c4SBarry Smith .seealso: `PetscViewer`, `PetscObject`, `PetscObjectSetName()`, `PetscObjectSAWsViewOff()` 61bfb97211SBarry Smith @*/ 62d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscObjectViewSAWs(PetscObject obj, PetscViewer viewer) 63d71ae5a4SJacob Faibussowitsch { 642657e9d9SBarry Smith char dir[1024]; 65d45a07a7SBarry Smith PetscMPIInt rank; 66bfb97211SBarry Smith 67bfb97211SBarry Smith PetscFunctionBegin; 68bfb97211SBarry Smith PetscValidHeader(obj, 1); 69ec957eceSBarry Smith if (obj->amsmem) PetscFunctionReturn(0); 709566063dSJacob Faibussowitsch PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank)); 71c5853193SPierre Jolivet PetscCheck(rank == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Should only be being called on rank zero"); 725f80ce2aSJacob Faibussowitsch PetscCheck(obj->name, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Object must already have been named"); 73bfb97211SBarry Smith 7456f85f32SBarry Smith obj->amsmem = PETSC_TRUE; 759566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Class", obj->name)); 76792fecdfSBarry Smith PetscCallSAWs(SAWs_Register, (dir, &obj->class_name, 1, SAWs_READ, SAWs_STRING)); 779566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Type", obj->name)); 78792fecdfSBarry Smith PetscCallSAWs(SAWs_Register, (dir, &obj->type_name, 1, SAWs_READ, SAWs_STRING)); 799566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/__Id", obj->name)); 80792fecdfSBarry Smith PetscCallSAWs(SAWs_Register, (dir, &obj->id, 1, SAWs_READ, SAWs_INT)); 81bfb97211SBarry Smith PetscFunctionReturn(0); 82bfb97211SBarry Smith } 83