Skip to content

Commit 3935abb

Browse files
committed
Prevent nested FSP as I dunno how to get matrix blocks
1 parent 89899fe commit 3935abb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/numerics/petsc_preconditioner.C

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ void PetscPreconditioner<T>::set_petsc_aux_data(PC & pc, System & sys, const uns
173173
PCType pc_type = nullptr;
174174
LibmeshPetscCallA(comm, PCGetType(pc, &pc_type));
175175

176+
// Get the nesting level of this PC's KSP
177+
PetscInt level;
178+
LibmeshPetscCallA(comm, PCGetKSPNestLevel(pc, &level));
179+
176180
// Check if hypre ams/ads, otherwise we quit with nothing to do
177181
if (pc_type && std::string(pc_type) == PCHYPRE)
178182
{
@@ -205,7 +209,7 @@ void PetscPreconditioner<T>::set_petsc_aux_data(PC & pc, System & sys, const uns
205209
set_hypre_ads_data(pc, sys, v);
206210
}
207211
}
208-
else if (pc_type && std::string(pc_type) == PCFIELDSPLIT)
212+
else if (pc_type && std::string(pc_type) == PCFIELDSPLIT && level == 0)
209213
{
210214
// Annoyingly, if using Schur complement preconditioning, we need to call PCSetUp()
211215
auto pmatrix = cast_ptr<PetscMatrixBase<T> *>(sys.request_matrix("System Matrix"));
@@ -219,6 +223,10 @@ void PetscPreconditioner<T>::set_petsc_aux_data(PC & pc, System & sys, const uns
219223
KSP * subksps;
220224
LibmeshPetscCallA(comm, PCFieldSplitGetSubKSP(pc, &n_splits, &subksps));
221225

226+
// We assume a one-to-one map between splits and variables
227+
if (sys.n_vars() != n_splits)
228+
return;
229+
222230
// Get the sub PC context for each split and recursively call this function
223231
for (auto s : make_range(n_splits))
224232
{

0 commit comments

Comments
 (0)