PyFoam.Execution.BasicRunner module

Run a OpenFOAM command

class PyFoam.Execution.BasicRunner.BasicRunner(argv=None, silent=False, logname=None, compressLog=False, lam=None, server=False, restart=False, noLog=False, logTail=None, remark=None, jobId=None, parameters=None, writeState=True, echoCommandLine=None)[source]

Bases: object

Base class for the running of commands

When the command is run the output is copied to a LogFile and (optionally) standard-out

The argument list assumes for the first three elements the OpenFOAM-convention:

<cmd> <dir> <case>

The directory name for outputs is therefor created from <dir> and <case>

Provides some handle-methods that are to be overloaded for additional functionality

__dict__ = dict_proxy({'runOK': <function runOK>, 'stopWithoutWrite': <function stopWithoutWrite>, '__module__': 'PyFoam.Execution.BasicRunner', 'writeLastSeen': <function writeLastSeen>, 'writeNowTime': <function writeNowTime>, '_writeStopAt': <function _writeStopAt>, '__dict__': <attribute '__dict__' of 'BasicRunner' objects>, 'stopGracefully': <function stopGracefully>, 'logName': <function logName>, 'appendTailLine': <function appendTailLine>, 'writeResults': <function writeResults>, 'writeTheState': <function writeTheState>, 'getSolutionDirectory': <function getSolutionDirectory>, '__weakref__': <attribute '__weakref__' of 'BasicRunner' objects>, '__init__': <function __init__>, 'writeStartTime': <function writeStartTime>, 'lineHandle': <function lineHandle>, 'stopAtNextWrite': <function stopAtNextWrite>, 'startHandle': <function startHandle>, 'stopHandle': <function stopHandle>, 'start': <function start>, 'writeTailLog': <function writeTailLog>, 'addEndTrigger': <function addEndTrigger>, 'writeToStateFile': <function writeToStateFile>, '__doc__': 'Base class for the running of commands\n\n When the command is run the output is copied to a LogFile and\n (optionally) standard-out\n\n The argument list assumes for the first three elements the\n OpenFOAM-convention:\n\n <cmd> <dir> <case>\n\n The directory name for outputs is therefor created from <dir> and\n <case>\n\n Provides some handle-methods that are to be overloaded for\n additional functionality'})
__init__(argv=None, silent=False, logname=None, compressLog=False, lam=None, server=False, restart=False, noLog=False, logTail=None, remark=None, jobId=None, parameters=None, writeState=True, echoCommandLine=None)[source]
Parameters:argv – list with the tokens that are the command line

if not set the standard command line is used :param silent: if True no output is sent to stdout :param logname: name of the logfile :param compressLog: Compress the logfile into a gzip :param lam: Information about a parallel run :param server: Whether or not to start the network-server :type lam: PyFoam.Execution.ParallelExecution.LAMMachine :param noLog: Don’t output a log file :param logTail: only the last lines of the log should be written :param remark: User defined remark about the job :param parameters: User defined dictionary with parameters for

documentation purposes
Parameters:
  • jobId – Job ID of the controlling system (Queueing system)
  • writeState – Write the state to some files in the case
  • echoCommandLine – Prefix that is printed with the command line. If unset nothing is printed
__module__ = 'PyFoam.Execution.BasicRunner'
__weakref__

list of weak references to the object (if defined)

_writeStopAt(value, message)[source]

Write stopAt to stop the run gracefully

addEndTrigger(f)[source]
Parameters:f – A function that is to be executed at the end of the simulation
appendTailLine(line)[source]

Append lines to the tail of the log

getSolutionDirectory(archive=None)[source]
Returns:The directory of the case
Return type:PyFoam.RunDictionary.SolutionDirectory
Parameters:archive – Name of the directory for archiving results
lineHandle(line)[source]

called every time a new line is read

logName()[source]

Get the name of the logfiles

runOK()[source]

checks whether the run was successful

start()[source]

starts the command and stays with it till the end

startHandle()[source]

to be called before the program is started

stopAtNextWrite()[source]

Tells the runner to stop at the next write

stopGracefully()[source]

Tells the runner to stop at the next convenient time

stopHandle()[source]

called after the program has stopped

stopWithoutWrite()[source]

Tells the runner to stop without writing

writeLastSeen()[source]
writeNowTime(force=False)[source]
writeResults()[source]

Writes the next possible time-step

writeStartTime()[source]

Write the real time the run was started at

writeTailLog()[source]

Write the last lines to the log

writeTheState(state, always=True)[source]

Write the current state the run is in

writeToStateFile(fName, message)[source]

Write a message to a state file

class PyFoam.Execution.BasicRunner.BasicRunnerCheck[source]

Bases: object

A small class that does primitve checking for BasicRunner Duplicates other efforts, but ….

__dict__ = dict_proxy({'__dict__': <attribute '__dict__' of 'BasicRunnerCheck' objects>, '__module__': 'PyFoam.Execution.BasicRunner', '__init__': <function __init__>, 'getCreateTime': <function getCreateTime>, 'getTime': <function getTime>, '__weakref__': <attribute '__weakref__' of 'BasicRunnerCheck' objects>, 'controlDictRead': <function controlDictRead>, '__doc__': 'A small class that does primitve checking for BasicRunner\n Duplicates other efforts, but ....', 'floatRegExp': '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?'})
__init__()[source]

x.__init__(…) initializes x; see help(type(x)) for signature

__module__ = 'PyFoam.Execution.BasicRunner'
__weakref__

list of weak references to the object (if defined)

controlDictRead(line)[source]

Was the controlDict reread?

floatRegExp = '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?'
getCreateTime(line)[source]

Does this line contain mesh time information?

getTime(line)[source]

Does this line contain time information?

PyFoam.Execution.BasicRunner.calcLogname(logname, argv)[source]
PyFoam.Execution.BasicRunner.findRestartFiles(logfile, sol)[source]
PyFoam.Execution.BasicRunner.restoreControlDict(ctrl, runner)[source]

Timed function to avoid time-stamp-problems