mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Region expression: ensure halfspace followed by ( results in implicit & operator
This commit is contained in:
parent
50cafaf61c
commit
0e38755a0e
2 changed files with 9 additions and 0 deletions
|
|
@ -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)])
|
||||
|
|
|
|||
|
|
@ -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))'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue