BarryFSmith avatar BarryFSmith committed 6ca9cac

cleanup some docs
error out if KSPSetDM() is used but not made inactive or DMKSPSetComputeOperators() is not called

Comments (0)

Files changed (2)

src/ksp/ksp/interface/iterativ.c

 +  ksp - the preconditioner context
 -  dm - the dm
 
+   Notes: If this is used then the KSP will attempt to use the DM to create the matrix and use the routine
+          set with DMKSPSetComputeOperators(). Use KSPSetDMActive(dm,PETSC_FALSE) to instead use the matrix
+          you've provided with KSPSetOperators().
+
    Level: intermediate
 
 
-.seealso: KSPGetDM(), KSPSetDM(), KSPGetDM()
+.seealso: KSPGetDM(), KSPSetDMActive(), DMKSPSetComputeOperators()
 @*/
 PetscErrorCode  KSPSetDM(KSP ksp,DM dm)
 {
    Notes:
    By default KSPSetDM() sets the DM as active, call KSPSetDMActive(dm,PETSC_FALSE); after KSPSetDM(dm) to not have the KSP object use the DM to generate the matrices
 
-.seealso: KSPGetDM(), KSPSetDM(), KSPGetDM()
+.seealso: KSPGetDM(), KSPSetDM(), SNESSetDM()
 @*/
 PetscErrorCode  KSPSetDMActive(KSP ksp,PetscBool flg)
 {
    Level: intermediate
 
 
-.seealso: KSPSetDM(), KSPSetDM(), KSPGetDM()
+.seealso: KSPSetDM(), KSPGetDM()
 @*/
 PetscErrorCode  KSPGetDM(KSP ksp,DM *dm)
 {

src/ksp/ksp/interface/itfunc.c

     }
 
     if (ksp->setupstage != KSP_SETUP_NEWRHS) {
-      ierr = KSPGetOperators(ksp,&A,&B,NULL);CHKERRQ(ierr);
       if (kdm->ops->computeoperators) {
+        ierr = KSPGetOperators(ksp,&A,&B,NULL);CHKERRQ(ierr);
         ierr = (*kdm->ops->computeoperators)(ksp,A,B,&stflg,kdm->operatorsctx);CHKERRQ(ierr);
-      }
-      ierr = KSPSetOperators(ksp,A,B,stflg);CHKERRQ(ierr);
+        ierr = KSPSetOperators(ksp,A,B,stflg);CHKERRQ(ierr);
+      } else SETERRQ(PetscObjectComm((PetscObject)ksp),PETSC_ERR_ARG_WRONGSTATE,"You called KSPSetDM() but did not use DMKSPSetComputeOperators() or KSPSetDMActive(dm,PETSC_FALSE);");
     }
   }
 
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 ProjectModifiedEvent.java.
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.