ibfoamrig.core.CaseManager#

class ibfoamrig.core.CaseManager(cases=())[source]#

Bases: Mapping[str, FoamCase]

A read-only mapping from case labels to cases, in insertion order.

classmethod from_paths(paths, *, distribution='org')[source]#

Creates cases from mapping of labels to case directories.

Parameters:
Returns:

The manager holding one case per entry.

Raises:

CaseNotFoundError – If a path is not a directory.

Return type:

Self

select(labels)[source]#

Returns a manager holding only some of the cases.

Parameters:

labels (Iterable[str]) – Labels of the cases to keep, in order to keep them.

Returns:

A new manager with the selected cases.

Raises:
Return type:

Self

run(script, *args, labels=None)[source]#

Runs a script in each case, one after another.

Stops at the first case whose script fails.

Parameters:
  • script (StrPath) – Path to the script, a relative path is resolved against each case directory, see FoamCase.run.

  • *args (str) – Command-line arguments passed to the script.

  • labels (Iterable[str] | None) – Labels of the cases to run in, in order. If None, all cases are used.

Raises:
map(function, *, labels=None)[source]#

Applies a function to each case, keyed by case label.

Typical use is collecting data from all cases for one plot:

def profile(case: FoamCase) -> pl.DataFrame:
    cells = case.field_data(table)
    return cells.project_line(start, end, tol).frame

profiles = manager.map(profile)
Parameters:
  • function (Callable[[FoamCase], T]) – Called with each case, its result is stored under the case label.

  • labels (Iterable[str] | None) –

    Labels of the cases to use, in order. If None, all cases are

    used.

Returns:

The results by case label, in case order.

Raises:
  • KeyError – If a label does not exist.

  • Exception – Any exception raised by function, with a note naming the case it failed for.

Return type:

dict[str, T]