1*ffeef943SBarry Smith #include <petsc/private/viewerimpl.h> /*I "petscsys.h" I*/
2*ffeef943SBarry Smith #include <petscviewersaws.h> /*I "petscviewersaws.h" I*/
35c6c1daeSBarry Smith
4*ffeef943SBarry Smith /*@
5811af0c4SBarry Smith PetscViewerSAWsOpen - Opens an SAWs `PetscViewer`.
65c6c1daeSBarry Smith
7cf53795eSBarry Smith Collective; No Fortran Support
85c6c1daeSBarry Smith
920f4b53cSBarry Smith Input Parameter:
10ec957eceSBarry Smith . comm - the MPI communicator
115c6c1daeSBarry Smith
125c6c1daeSBarry Smith Output Parameter:
13811af0c4SBarry Smith . lab - the `PetscViewer`
145c6c1daeSBarry Smith
155c6c1daeSBarry Smith Options Database Keys:
16f7b25cf6SBarry Smith + -saws_port <port number> - port number where you are running SAWs client
17f7b25cf6SBarry Smith . -xxx_view saws - publish the object xxx
183f423023SBarry 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
19f7b25cf6SBarry Smith the user unblocks the problem with an external tool that access the object with SAWS
205c6c1daeSBarry Smith
215c6c1daeSBarry Smith Level: advanced
225c6c1daeSBarry Smith
233f423023SBarry Smith Notes:
24c410d8ccSBarry Smith Unlike other viewers that only access the object being viewed on the call to `XXXView`(object,viewer) the SAWs viewer allows
25e04113cfSBarry 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
26811af0c4SBarry Smith `PetscObjectSAWsViewOff()`.
2738dc1537SBarry Smith
28a8d69d7bSBarry Smith Information about the SAWs is available via https://bitbucket.org/saws/saws
295c6c1daeSBarry Smith
30d1f92df0SBarry Smith .seealso: [](sec_viewers), `PetscViewerDestroy()`, `PetscViewerStringSPrintf()`, `PETSC_VIEWER_SAWS_()`, `PetscObjectSAWsBlock()`,
31db781477SPatrick Sanan `PetscObjectSAWsViewOff()`, `PetscObjectSAWsTakeAccess()`, `PetscObjectSAWsGrantAccess()`
325c6c1daeSBarry Smith @*/
PetscViewerSAWsOpen(MPI_Comm comm,PetscViewer * lab)33d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscViewerSAWsOpen(MPI_Comm comm, PetscViewer *lab)
34d71ae5a4SJacob Faibussowitsch {
355c6c1daeSBarry Smith PetscFunctionBegin;
369566063dSJacob Faibussowitsch PetscCall(PetscViewerCreate(comm, lab));
379566063dSJacob Faibussowitsch PetscCall(PetscViewerSetType(*lab, PETSCVIEWERSAWS));
383ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
395c6c1daeSBarry Smith }
40bfb97211SBarry Smith
41*ffeef943SBarry Smith /*@
42e04113cfSBarry Smith PetscObjectViewSAWs - View the base portion of any object with an SAWs viewer
43bfb97211SBarry Smith
44c3339decSBarry Smith Collective
45bfb97211SBarry Smith
46bfb97211SBarry Smith Input Parameters:
47dde44402SBarry Smith + obj - the `PetscObject` variable. It must be cast with a (`PetscObject`), for example, `PetscObjectSetName`((`PetscObject`)mat,name);
48e04113cfSBarry Smith - viewer - the SAWs viewer
49bfb97211SBarry Smith
50bfb97211SBarry Smith Level: advanced
51bfb97211SBarry Smith
52811af0c4SBarry Smith Note:
53d45a07a7SBarry Smith The object must have already been named before calling this routine since naming an
54d45a07a7SBarry Smith object can be collective.
55d45a07a7SBarry Smith
56aec76313SJacob Faibussowitsch Developer Notes:
57c410d8ccSBarry Smith Currently this is called only on MPI rank 0 of `PETSC_COMM_WORLD`
58bfb97211SBarry Smith
59dde44402SBarry Smith .seealso: [](sec_viewers), `PetscViewer`, `PetscObject`, `PetscObjectSetName()`
60bfb97211SBarry Smith @*/
PetscObjectViewSAWs(PetscObject obj,PetscViewer viewer)61d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscObjectViewSAWs(PetscObject obj, PetscViewer viewer)
62d71ae5a4SJacob Faibussowitsch {
632657e9d9SBarry Smith char dir[1024];
64d45a07a7SBarry Smith PetscMPIInt rank;
65bfb97211SBarry Smith
66bfb97211SBarry Smith PetscFunctionBegin;
67bfb97211SBarry Smith PetscValidHeader(obj, 1);
683ba16761SJacob Faibussowitsch if (obj->amsmem) PetscFunctionReturn(PETSC_SUCCESS);
699566063dSJacob Faibussowitsch PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
70c5853193SPierre Jolivet PetscCheck(rank == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Should only be being called on rank zero");
715f80ce2aSJacob Faibussowitsch PetscCheck(obj->name, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Object must already have been named");
72bfb97211SBarry Smith
7356f85f32SBarry Smith obj->amsmem = PETSC_TRUE;
749566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Class", obj->name));
75792fecdfSBarry Smith PetscCallSAWs(SAWs_Register, (dir, &obj->class_name, 1, SAWs_READ, SAWs_STRING));
769566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/Type", obj->name));
77792fecdfSBarry Smith PetscCallSAWs(SAWs_Register, (dir, &obj->type_name, 1, SAWs_READ, SAWs_STRING));
789566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(dir, 1024, "/PETSc/Objects/%s/__Id", obj->name));
79792fecdfSBarry Smith PetscCallSAWs(SAWs_Register, (dir, &obj->id, 1, SAWs_READ, SAWs_INT));
803ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
81bfb97211SBarry Smith }
82