Commit 80667fc4 authored by Mark Olesen's avatar Mark Olesen

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.
parent d8824950
...@@ -28,6 +28,7 @@ License ...@@ -28,6 +28,7 @@ License
#include "stringOps.H" #include "stringOps.H"
#include "OSHA1stream.H" #include "OSHA1stream.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "sigFpe.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include <vtkCPDataDescription.h> #include <vtkCPDataDescription.h>
...@@ -79,6 +80,23 @@ Foam::label Foam::functionObjects::catalystFunctionObject::expand ...@@ -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); scripts.resize(nscript);
return nscript; return nscript;
...@@ -252,6 +270,12 @@ bool Foam::functionObjects::catalystFunctionObject::execute() ...@@ -252,6 +270,12 @@ bool Foam::functionObjects::catalystFunctionObject::execute()
return false; 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()) if (!adaptor_.valid())
{ {
adaptor_.reset(new catalyst::coprocess()); adaptor_.reset(new catalyst::coprocess());
...@@ -295,6 +319,11 @@ bool Foam::functionObjects::catalystFunctionObject::execute() ...@@ -295,6 +319,11 @@ bool Foam::functionObjects::catalystFunctionObject::execute()
adaptor_().process(dataq, outputs); adaptor_().process(dataq, outputs);
} }
// Avoid compiler complaint about unused variable.
// - manually restore old SIGFPE state
sigFpeHandling.restore();
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment