diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index 03d29d5f329883c59d586fa4c1557c0eecdee9b1..ad40c3315dd726fb8562b4ed8774e73698375151 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -13,6 +13,10 @@ #include <chrono> #include <tclap/CmdLine.h> +#ifndef _WIN32 +#include <cfenv> +#endif // _WIN32 + #ifdef USE_PETSC #include <vtkMPIController.h> #include <vtkSmartPointer.h> @@ -85,6 +89,13 @@ int main(int argc, char *argv[]) "use unbuffered standard output"); cmd.add(unbuffered_cout_arg); +#ifndef _WIN32 // TODO: On windows floating point exceptions are not handled + // currently + TCLAP::SwitchArg enable_fpe_arg("", "enable-fpe", + "enables floating point exceptions"); + cmd.add(enable_fpe_arg); +#endif // _WIN32 + cmd.parse(argc, argv); // deactivate buffer for standard output if specified @@ -97,6 +108,12 @@ int main(int argc, char *argv[]) INFO("This is OpenGeoSys-6 version %s.", BaseLib::BuildInfo::git_describe.c_str()); +#ifndef _WIN32 // On windows this command line option is not present. + // Enable floating point exceptions + if (enable_fpe_arg.isSet()) + feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif // _WIN32 + BaseLib::RunTime run_time; run_time.start(); diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp index f5ef433565e803e7d0f9a1ee6141cdbe1ee3f51e..b82dda5dde67d9f265b189189bd81f991adfdbe8 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp @@ -9,6 +9,7 @@ #include "ConvergenceCriterionPerComponentDeltaX.h" #include <logog/include/logog.hpp> +#include <limits> #include "BaseLib/ConfigTree.h" #include "NumLib/DOF/LocalToGlobalIndexMap.h" @@ -54,7 +55,9 @@ void ConvergenceCriterionPerComponentDeltaX::checkDeltaX( INFO( "Convergence criterion, component %u: |dx|=%.4e, |x|=%.4e, " "|dx|/|x|=%.4e", - error_dx, global_component, norm_x, error_dx / norm_x); + error_dx, global_component, norm_x, + (norm_x == 0. ? std::numeric_limits<double>::quiet_NaN() + : (error_dx / norm_x))); satisfied_abs = satisfied_abs && error_dx < _abstols[global_component]; satisfied_rel =