diff --git a/MathLib/LinAlg/PETSc/PETScTools.cpp b/MathLib/LinAlg/PETSc/PETScTools.cpp index d9be8871b73249d3aad848f3d0f438328bdd39f0..6988492e9ca888547305b819386e21ab5dd3c30b 100644 --- a/MathLib/LinAlg/PETSc/PETScTools.cpp +++ b/MathLib/LinAlg/PETSc/PETScTools.cpp @@ -24,6 +24,16 @@ void applyKnownSolution(PETScMatrix& A, PETScVector& b, PETScVector& x, { A.finalizeAssembly(); +#ifndef NDEBUG + if (std::any_of(vec_knownX_id.begin(), vec_knownX_id.end(), + [](PetscInt const i) { return i < 0; })) + { + OGS_FATAL( + "Found negative indices in the vector of Dirichlet boundary " + "conditions."); + } +#endif // NDEBUG + A.setRowsColumnsZero(vec_knownX_id); A.finalizeAssembly();