BarryFSmith avatar BarryFSmith committed 5b35159

make KSP AMS monitor use default AMS communicator

Comments (0)

Files changed (3)


         rid    =
         if method == "YAML_AMS_Connect":
             if isinstance(response,list):
-              self.commname = str(response[1])
+#             Currently always connects to the zeroth communicator published, no way to connect to others.
+              self.commname = str(response[0])
               self.commname = str(response)
             if self.commname == 'No AMS publisher running':


   flg  = PETSC_FALSE;
   ierr = PetscOptionsBool("-ksp_monitor_ams","Publish KSP progress using AMS","KSPMonitorSet",flg,&flg,NULL);CHKERRQ(ierr);
   if (flg) {
-    char amscommname[256];
     void *ctx;
-    ierr = PetscSNPrintf(amscommname,sizeof(amscommname),"%sksp_monitor_ams",((PetscObject)ksp)->prefix ? ((PetscObject)ksp)->prefix : "");CHKERRQ(ierr);
-    ierr = KSPMonitorAMSCreate(ksp,amscommname,&ctx);CHKERRQ(ierr);
+    ierr = KSPMonitorAMSCreate(ksp,NULL,&ctx);CHKERRQ(ierr);
     ierr = KSPMonitorSet(ksp,KSPMonitorAMS,ctx,KSPMonitorAMSDestroy);CHKERRQ(ierr);
     ierr = KSPSetComputeSingularValues(ksp,PETSC_TRUE);CHKERRQ(ierr);


    Input Arguments:
 +  ksp - KSP to monitor
--  amscommname - name of AMS communicator to use
+-  amscommname - name of AMS communicator to use, if NULL uses default "PETSc" communicator
    Output Arguments:
 .  ctx - context for monitor
   KSPMonitor_AMS *mon;
-  ierr = PetscNewLog(ksp,KSPMonitor_AMS,&mon);CHKERRQ(ierr);
-  ierr      = PetscViewerAMSOpen(PetscObjectComm((PetscObject)ksp),amscommname,&mon->viewer);CHKERRQ(ierr);
+  ierr      = PetscNewLog(ksp,KSPMonitor_AMS,&mon);CHKERRQ(ierr);
+  if (!amscommname) {
+    mon->viewer = PETSC_VIEWER_AMS_(PetscObjectComm((PetscObject)ksp));
+    if (!mon->viewer) SETERRQ(PetscObjectComm((PetscObject)ksp),PETSC_ERR_PLIB,"Cannot create AMS default communicator");CHKERRQ(ierr);
+  } else {
+    ierr = PetscViewerAMSOpen(PetscObjectComm((PetscObject)ksp),amscommname,&mon->viewer);CHKERRQ(ierr);
+  }
   mon->amem = -1;
   *ctx = (void*)mon;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.