15c6c1daeSBarry Smith 2af0996ceSBarry Smith #include <petsc/private/viewerimpl.h> /*I "petscsys.h" */ 3e04113cfSBarry Smith #include <petscviewersaws.h> 45c6c1daeSBarry Smith 55c6c1daeSBarry Smith /*@C 6d45a07a7SBarry Smith PetscViewerSAWsOpen - Opens an SAWs PetscViewer. 75c6c1daeSBarry Smith 85c6c1daeSBarry Smith Collective on MPI_Comm 95c6c1daeSBarry Smith 105c6c1daeSBarry Smith Input Parameters: 11ec957eceSBarry Smith . comm - the MPI communicator 125c6c1daeSBarry Smith 135c6c1daeSBarry Smith Output Parameter: 145c6c1daeSBarry 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 245c6c1daeSBarry Smith Fortran Note: 255c6c1daeSBarry Smith This routine is not supported in Fortran. 265c6c1daeSBarry Smith 275c6c1daeSBarry Smith 285c6c1daeSBarry Smith Notes: 29e04113cfSBarry Smith Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the SAWs viewer allows 30e04113cfSBarry 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 31e04113cfSBarry Smith PetscObjectSAWsViewOff(). 3238dc1537SBarry Smith 33*a8d69d7bSBarry Smith Information about the SAWs is available via https://bitbucket.org/saws/saws 345c6c1daeSBarry Smith 35e04113cfSBarry Smith .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PETSC_VIEWER_SAWS_(), PetscObjectSAWsBlock(), 36e04113cfSBarry Smith PetscObjectSAWsViewOff(), PetscObjectSAWsTakeAccess(), PetscObjectSAWsGrantAccess() 375c6c1daeSBarry Smith 385c6c1daeSBarry Smith @*/ 39e04113cfSBarry Smith PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm,PetscViewer *lab) 405c6c1daeSBarry Smith { 415c6c1daeSBarry Smith PetscErrorCode ierr; 425c6c1daeSBarry Smith 435c6c1daeSBarry Smith PetscFunctionBegin; 445c6c1daeSBarry Smith ierr = PetscViewerCreate(comm,lab);CHKERRQ(ierr); 45e04113cfSBarry Smith ierr = PetscViewerSetType(*lab,PETSCVIEWERSAWS);CHKERRQ(ierr); 465c6c1daeSBarry Smith PetscFunctionReturn(0); 475c6c1daeSBarry Smith } 48bfb97211SBarry Smith 49bfb97211SBarry Smith /*@C 50e04113cfSBarry Smith PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer 51bfb97211SBarry Smith 52bfb97211SBarry Smith Collective on PetscObject 53bfb97211SBarry Smith 54bfb97211SBarry Smith Input Parameters: 55bfb97211SBarry Smith + obj - the Petsc variable 56bfb97211SBarry Smith Thus must be cast with a (PetscObject), for example, 57bfb97211SBarry Smith PetscObjectSetName((PetscObject)mat,name); 58e04113cfSBarry Smith - viewer - the SAWs viewer 59bfb97211SBarry Smith 60bfb97211SBarry Smith Level: advanced 61bfb97211SBarry Smith 62bfb97211SBarry Smith Concepts: publishing object 63bfb97211SBarry Smith 64d45a07a7SBarry Smith Developer Note: Currently this is called only on rank zero of PETSC_COMM_WORLD 65d45a07a7SBarry Smith 66d45a07a7SBarry Smith The object must have already been named before calling this routine since naming an 67d45a07a7SBarry Smith object can be collective. 68d45a07a7SBarry Smith 69d45a07a7SBarry Smith 70e04113cfSBarry Smith .seealso: PetscObjectSetName(), PetscObjectSAWsViewOff() 71bfb97211SBarry Smith 72bfb97211SBarry Smith @*/ 73e04113cfSBarry Smith PetscErrorCode PetscObjectViewSAWs(PetscObject obj,PetscViewer viewer) 74bfb97211SBarry Smith { 75bfb97211SBarry Smith PetscErrorCode ierr; 762657e9d9SBarry Smith char dir[1024]; 77d45a07a7SBarry Smith PetscMPIInt rank; 78bfb97211SBarry Smith 79bfb97211SBarry Smith PetscFunctionBegin; 80bfb97211SBarry Smith PetscValidHeader(obj,1); 81ec957eceSBarry Smith if (obj->amsmem) PetscFunctionReturn(0); 82d45a07a7SBarry Smith ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr); 83d45a07a7SBarry Smith if (rank) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Should only be being called on rank zero"); 84d45a07a7SBarry Smith if (!obj->name) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Object must already have been named"); 85bfb97211SBarry Smith 8656f85f32SBarry Smith obj->amsmem = PETSC_TRUE; 872657e9d9SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/Class",obj->name);CHKERRQ(ierr); 882657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&obj->class_name,1,SAWs_READ,SAWs_STRING)); 892657e9d9SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/Type",obj->name);CHKERRQ(ierr); 902657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&obj->type_name,1,SAWs_READ,SAWs_STRING)); 91d50831c4SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/__Id",obj->name);CHKERRQ(ierr); 922657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&obj->id,1,SAWs_READ,SAWs_INT)); 93d50831c4SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Objects/%s/__ParentID",obj->name);CHKERRQ(ierr); 942657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&obj->parentid,1,SAWs_READ,SAWs_INT)); 95bfb97211SBarry Smith PetscFunctionReturn(0); 96bfb97211SBarry Smith } 97