Skip to content

Commit

Permalink
Allow post-processing to continue on error
Browse files Browse the repository at this point in the history
  • Loading branch information
sayerhs committed Jan 25, 2024
1 parent 8675b91 commit 160bd73
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions caelus/post/funcobj/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
class PostProcessing:
"""Main entry point for accessing OpenFOAM ``postProcessing`` data."""

def __init__(self, casedir=None, func_dict=None):
def __init__(
self, casedir=None, func_dict=None, raise_on_error: bool = False
):
"""
If the function object dictionary is not provided as an argument, the
class will attempt to infer the functions activated in ``controlDict``
Expand All @@ -71,6 +73,7 @@ class will attempt to infer the functions activated in ``controlDict``
Args:
casedir (path): Path to the case directory (default: cwd)
func_dict (CaelusDict): Function objects dictionary
raise_on_error (bool): Raise exception if some objects fail to process
"""
#: Absolute path to the case directory
Expand All @@ -95,8 +98,15 @@ class will attempt to infer the functions activated in ``controlDict``
)
continue

fcls = _func_obj_map[ftype]
fobj[k] = fcls(k, v, casedir=self.casedir)
try:
fcls = _func_obj_map[ftype]
fobj[k] = fcls(k, v, casedir=self.casedir)
except Exception:
_lgr.exception(
"Failed to parse function object entry: %s (%s)", k, ftype
)
if raise_on_error:
raise
self.func_objects = fobj

def filter(self, func_type):
Expand Down

0 comments on commit 160bd73

Please sign in to comment.