From 80667fc4bf7d1ff8a0ec42103c0bfd13112dd5d6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 22 Jun 2018 01:09:44 +0200 Subject: [PATCH] ENH: disable SIGFPE handling in catalyst loop - if sigFpe is enabled within OpenFOAM, any errors in the Catalyst pipeline will potentially kill the entire simulation. - use the new sigFpe::ignore helper class to manage a local disabling of SIGFPE handling. --- src/catalyst/catalystFunctionObject.C | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/catalyst/catalystFunctionObject.C b/src/catalyst/catalystFunctionObject.C index 1c697e2..0472bae 100644 --- a/src/catalyst/catalystFunctionObject.C +++ b/src/catalyst/catalystFunctionObject.C @@ -28,6 +28,7 @@ License #include "stringOps.H" #include "OSHA1stream.H" #include "OSspecific.H" +#include "sigFpe.H" #include "addToRunTimeSelectionTable.H" #include @@ -79,6 +80,23 @@ Foam::label Foam::functionObjects::catalystFunctionObject::expand } } + const label nbad = (scripts.size() - nscript); + + if (nbad) + { + Warning + << nl + << "Could not resolve " << nbad << " of " << scripts.size() + << " catalyst scripts - check your input" << nl << nl; + } + + if (!nscript) + { + Warning + << nl + << "No catalyst scripts resolved - check your input" << nl << nl; + } + scripts.resize(nscript); return nscript; @@ -252,6 +270,12 @@ bool Foam::functionObjects::catalystFunctionObject::execute() return false; } + // Disable any floating point trapping so that errors in + // Catalyst pipelines do not kill the simulation + // TODO: report that errors occurred? + + sigFpe::ignore sigFpeHandling; //<- disable in local scope + if (!adaptor_.valid()) { adaptor_.reset(new catalyst::coprocess()); @@ -295,6 +319,11 @@ bool Foam::functionObjects::catalystFunctionObject::execute() adaptor_().process(dataq, outputs); } + + // Avoid compiler complaint about unused variable. + // - manually restore old SIGFPE state + sigFpeHandling.restore(); + return true; } -- GitLab