diff --git a/openmc/region.py b/openmc/region.py index 8efee7c4ec..56926187dd 100644 --- a/openmc/region.py +++ b/openmc/region.py @@ -106,6 +106,11 @@ class Region(ABC): # If special character appears immediately after a non-operator, # create a token with the appropriate half-space if i_start >= 0: + # When an opening parenthesis appears after a non-operator, + # there's an implicit intersection operator between them + if expression[i] == '(': + tokens.append(' ') + j = int(expression[i_start:i]) if j < 0: tokens.append(-surfaces[abs(j)]) diff --git a/tests/unit_tests/test_region.py b/tests/unit_tests/test_region.py index e759827606..8537e3b806 100644 --- a/tests/unit_tests/test_region.py +++ b/tests/unit_tests/test_region.py @@ -204,3 +204,7 @@ def test_from_expression(reset): # Make sure ")(" is handled correctly r = openmc.Region.from_expression('(-1|2)(2|-3)', surfs) assert str(r) == '((-1 | 2) (2 | -3))' + + # Opening parenthesis immediately after halfspace + r = openmc.Region.from_expression('1(2|-3)', surfs) + assert str(r) == '(1 (2 | -3))'