Skip to content

Commit 48ea74f

Browse files
Use ArrayAccess for entity_local_index (#615)
* Fix incorrect use of Symbol * Add check
1 parent 398ddae commit 48ea74f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ffcx/codegeneration/lnodes.py

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ class Symbol(LExprTerminal):
311311

312312
def __init__(self, name: str, dtype):
313313
assert isinstance(name, str)
314+
assert name.replace("_", "").isalnum()
314315
self.name = name
315316
self.dtype = dtype
316317

ffcx/codegeneration/symbols.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ def entity(self, entitytype, restriction):
7777
if entitytype == "cell":
7878
# Always 0 for cells (even with restriction)
7979
return L.LiteralInt(0)
80-
elif entitytype == "facet":
81-
postfix = "[0]"
80+
81+
entity_local_index = L.Symbol("entity_local_index", dtype=L.DataType.INT)
82+
if entitytype == "facet":
8283
if restriction == "-":
83-
postfix = "[1]"
84-
return L.Symbol("entity_local_index" + postfix, dtype=L.DataType.INT)
84+
return entity_local_index[1]
85+
else:
86+
return entity_local_index[0]
8587
elif entitytype == "vertex":
86-
return L.Symbol("entity_local_index[0]", dtype=L.DataType.INT)
88+
return entity_local_index[0]
8789
else:
8890
logging.exception(f"Unknown entitytype {entitytype}")
8991

0 commit comments

Comments
 (0)