reynolds.foam package

Submodules

reynolds.foam.cmd_runner module

reynolds.foam.start module

class reynolds.foam.start.FoamRunner

Bases: object

A class to start the OpenFoam runtime environment.

This works by loading the openfoam env variables into the python os.environ thereby allowing openfoam tools such as blockMesh and various solvers to be executed using a python process.

This is a platform dependent class that supports linux and macOS only as the process of loading openfoam env variables is different on the two supported platforms.

__init__()

Initializes the runner with:

  1. Foam path: which is path to the openfoam installation
  2. Source path: which is the path to the openfoam bash script to source openfoam env variables.

The foam path and source path are setup as per the os platform.

shell_source(script)

Updates the environment with variables sourced from openfoam bash script.

Parameters:script – The path to the openform etc/bashrc script to be sourced
Returns:True if env sourced succesfully. False otherwise.
start()

Starts the openfoam environment as such on the following os platforms:

  1. macOS: Loads the openfoam sparsebundle and sources the openfoam env variables.
  2. linux: Sources the openfoam env variables.
Returns:True if the process was successful, else False on macOs and linux AssertionError for any other non supported os platform.

Module contents