Skip to content

Commit 79e9874

Browse files
Better logic to guard against recalculating before setup
1 parent 49f126d commit 79e9874

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/solvers/petsc_nonlinear_solver.C

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,15 +1153,22 @@ void PetscNonlinearSolver<T>::check_reuse_operator_sizes(numeric_index_type new_
11531153
// preconditioner if the operator sizes has changed, regardless
11541154
// of what libmesh itself knows about the problem
11551155
//
1156-
if (!(this->_reuse_preconditioner) || !(this->_is_initialized))
1156+
if (!(this->_reuse_preconditioner) ||
1157+
!(this->_is_initialized) ||
1158+
!(_setup_reuse))
11571159
return;
11581160

1159-
if (!_setup_reuse)
1160-
return;
11611161

11621162
KSP ksp;
11631163
PetscErrorCode ierr = SNESGetKSP(_snes, &ksp);
11641164
LIBMESH_CHKERR(ierr);
1165+
1166+
PetscBool setup_A, setup_P;
1167+
ierr = KSPGetOperatorsSet(ksp, &setup_A, &setup_P);
1168+
LIBMESH_CHKERR(ierr);
1169+
if (!(setup_A && setup_P))
1170+
return;
1171+
11651172
Mat A;
11661173
Mat P;
11671174
ierr = KSPGetOperators(ksp, &A, &P);

0 commit comments

Comments
 (0)