ibfoamrig.core.CaseManager#
- class ibfoamrig.core.CaseManager(cases=())[source]#
-
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:
distribution (Distribution) – OpenFOAM distribution of all cases.
- Returns:
The manager holding one case per entry.
- Raises:
CaseNotFoundError – If a path is not a directory.
- Return type:
- 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:
KeyError – If a label does not exist.
ValueError – If a label is repeated.
- Return type:
- run(script, *args, labels=None)[source]#
Runs a script in each case, one after another.
Stops at the first case whose script fails.
- Parameters:
- Raises:
KeyError – If a label does not exist.
FileNotFoundError – If the script is missing in a case.
ScriptError – If the script fails, the message names the case.
- 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:
- Returns:
The results by case label, in case order.
- Raises:
- Return type: