Documentation for aiofoam

class aiofoam.Case(path: Path | str)

An OpenFOAM case.

Parameters:

path – The path to the case directory.

async clean(*, script: bool = True, check: bool = False, env: Mapping[str, str] | None = None) None

Clean this case.

Parameters:
  • script – If True, use an (All)clean script if it exists. If False, ignore any clean scripts.

  • check – If True, raise a RuntimeError if the clean script returns a non-zero exit code.

  • env – Environment variables to set for the clean script. If None, use the current environment.

async clone(dest: Path | str) Case

Clone this case (make a clean copy).

Parameters:

dest – The destination path.

async cmd(args: Sequence[str | Path] | str | Path, *, parallel: bool = False, check: bool = True, cpus: int = 0, env: Mapping[str, str] | None = None) str

Execute a command in the context of this case.

Parameters:
  • args – The command to execute. If a sequence, the first element is the command and the rest are arguments. If a string, the command is executed in a shell.

  • parallel – If True, run the command in parallel using mpiexec.

  • check – If True, raise a RuntimeError if the command returns a non-zero exit code.

  • cpus – The number of CPUs to reserve for the command. The command will wait until the requested number of CPUs is available.

  • env – Environment variables to set for the command. If None, use the current environment.

async copy(dest: Path | str) Case

Make a copy of this case.

Parameters:

dest – The destination path.

property name: str

The name of the case.

async run(*, script: bool = True, parallel: bool | None = None, cpus: int | None = None, check: bool = True, env: Mapping[str, str] | None = None) str

Run this case.

Parameters:
  • script – If True, use an (All)run(-parallel) script if it exists. If False, ignore any run scripts.

  • parallel – If True, run in parallel. If False, run in serial. If None, autodetect whether to run in parallel.

  • cpus – The number of CPUs to reserve for the run. The run will wait until the requested number of CPUs is available. If None, autodetect the number of CPUs to reserve.

  • check – If True, raise a RuntimeError if any command returns a non-zero exit code.

  • env – Environment variables to set for the run script or commands. If None, use the current environment.

to_pyfoam() SolutionDirectory

Create a PyFoam SolutionDirectory from this case. Requires PyFoam to be installed.

Indices and tables