diff --git a/src/ksp/pc/impls/fieldsplit/fieldsplit.c b/src/ksp/pc/impls/fieldsplit/fieldsplit.c index f4e1e35ea1e..295cc477d85 100644 --- a/src/ksp/pc/impls/fieldsplit/fieldsplit.c +++ b/src/ksp/pc/impls/fieldsplit/fieldsplit.c @@ -1661,6 +1661,26 @@ static PetscErrorCode PCSetFromOptions_FieldSplit(PetscOptionItems *PetscOptions PetscCall(PetscOptionsInt("-pc_fieldsplit_gkb_maxit","Maximum allowed number of iterations","PCFieldSplitGKBMaxit",jac->gkbmaxit,&jac->gkbmaxit,NULL)); PetscCall(PetscOptionsBool("-pc_fieldsplit_gkb_monitor","Prints number of GKB iterations and error","PCFieldSplitGKB",jac->gkbmonitor,&jac->gkbmonitor,NULL)); } + /* + In the initial call to this routine the sub data structures do not exist so we cannot call KSPSetFromObjects() on them yet. + Instead the calls are made in PCSetUp_FieldSplit(). After the initial call we can and do call KSPSetFromObjects() on the + sub-data structures in case changes were made in the options database + + There could be a negative side effect of calling this KSPSetFromOptions() below. + + If one captured the PetscObjectState of the options database one could skip these calls if the database has not changed + */ + if (jac->issetup) { + PC_FieldSplitLink ilink = jac->head; + if (jac->type == PC_COMPOSITE_SCHUR) { + if (jac->kspupper) PetscCall(KSPSetFromOptions(jac->kspupper)); + if (jac->kspschur) PetscCall(KSPSetFromOptions(jac->kspschur)); + } + while (ilink) { + PetscCall(KSPSetFromOptions(ilink->ksp)); + ilink = ilink->next; + } + } PetscOptionsHeadEnd(); PetscFunctionReturn(0); }