Logs, Warning, Errors

Log messages from simulation functions

Simulation functions can log messages to both console display and files using the OpenFLUID_Logger feature:

The messages logged to files are put in a file named with the ID of the simulation function suffixed by .log, placed in the simulation output directory.

The OpenFLUID_Logger facility is the recommended way to log messages. Please avoid using std::cout or similar C++ facilities.

 bool runStep(const openfluid::base::SimulationStatus* /*SimStatus*/)
  openfluid::core::Unit* TU;

  OPENFLUID_Logger.get() << "This is a message to bost file and console" << std::endl;
  OPENFLUID_Logger.getFile() << "This is a message to file only" << std::endl;
  OPENFLUID_Logger.getStdout() << "This is a message to console only" << std::endl;

    OPENFLUID_Logger.get() << "TestUnits " << TU->getID() << std::endl;

  return true;

Raise warnings and errors

In order to trace error and warnings during the run of a simulation, simulation functions can raise error and warning messages to inform the framework that something wrong or critical had happened. An error stops the simulation the next time the OpenFLUID framework take the control, a warning does not stop the simulation. Error and warnings are reported in the simulation report (siminfo.out file). They both can be dated with the number of the time step when the warning or error occurs.

To raise a warning you can use OPENFLUID_RaiseWarning , to raise an error you can use OPENFLUID_RaiseError

As already mentioned, an error stops the simulation the next time the framework takes control of the simulation.

bool Myfunction::checkConsistency()
  openfluid::core::ScalarValue TmpValue;
  openfluid::core::Unit* SU;

    if (TmpValue <= 0)
      OPENFLUID_RaiseError("my.function","Wrong value for the MyProp distributed property on SU");
      return false;


  return true;

Generated using Doxygen 1.6.3
Creative Commons License Creative Commons By-NC-ND license