diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 6d9c1dde8dc5167fa584572e85fa006509f65d25..93b68e7e6f2bc75e8cb9b6346d280573d58d2200 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -301,6 +301,17 @@ def boundary_predicates(measure, subdomain_id): visitor = get_visitor(measure, subdomain_id) subdomain_data = visitor(subdomain_data, do_predicates=True) + # Often, boundary predicates are just nested conditionals. We try to find + # out which of these are unfulfillable in the first place. + def possible_values(expr): + if isinstance(expr, prim.If): + return set(possible_values(expr.then)).union(possible_values(expr.else_)) + else: + return set({expr}) + + if subdomain_id not in possible_values(subdomain_data): + return frozenset({False}) + p = prim.Comparison(subdomain_data, '==', subdomain_id) # Try to find conditions that are always 0 or always 1 @@ -308,7 +319,7 @@ def boundary_predicates(measure, subdomain_id): try: eval = evaluate(p) if not eval: - predicates.append(False) + return frozenset({False}) except: predicates.append(p)