FS#175 Replace assert by NumericalProblem
Metadata
Description
In the Box assembler dumux/implicit/box/boxassembler.hh:306 we have a test whether all entries are finite. I like the test and it already helped me finding bugs. Unfortunately it breaks the execution if the test fails. In many cases it would be better to try a smaller time step.
The following patch would implement this behavior and improve the error message.
Any objections?
Philipp proposed this behavoir when we talked the last time about this topic.
--- dumux/dumux/implicit/box/boxassembler.hh (revision 9943)
+++ dumux/dumux/implicit/box/boxassembler.hh (working copy)
@@ -24,6 +24,7 @@
#ifndef DUMUX_BOX_ASSEMBLER_HH
#define DUMUX_BOX_ASSEMBLER_HH
+#include <dumux/common/exceptions.hh>
#include <dumux/implicit/common/implicitassembler.hh>
#include <dumux/parallel/vertexhandles.hh>
@@ -302,8 +303,12 @@
// update the right hand side
this->residual_[globI] += this->model_().localJacobian().residual(i);
- for (int j = 0; j < this->residual_[globI].dimension; ++j)
- assert(std::isfinite(this->residual_[globI][j]));
+ for (int j = 0; j < this->residual_[globI].dimension; ++j) {
+ if (!std::isfinite(this->residual_[globI][j])) {
+ DUNE_THROW(NumericalProblem,
+ \"residual_[\" << globI << \"][\" << j << \" is not finite\");
+ }
+ }
if (this->enableJacobianRecycling_()) {
this->storageTerm_[globI] +=
this->model_().localJacobian().storageTerm(i);