Skip to content

Commit 5b583a1

Browse files
committed
Add support for jit mappings
1 parent d0a8529 commit 5b583a1

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

preciceconfigvisualizer/common.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,49 @@ def lookupParticipantColor(name):
262262
color=lookupParticipantColor(pfrom),
263263
style="dashed",
264264
)
265+
266+
jit_to = {}
267+
jit_from = {}
268+
269+
# mappings
270+
for child in elem.iterchildren():
271+
# register mappings
272+
if child.tag.startswith("mapping:"):
273+
mkind = child.tag[child.tag.find(":") + 1 :]
274+
275+
# Save jit mappings for read/write data annotations
276+
if "from" not in child.attrib:
277+
jit_to[child.attrib.get("to")] = mkind
278+
continue
279+
280+
if "to" not in child.attrib:
281+
jit_from[child.attrib.get("from")] = mkind
282+
continue
283+
284+
# Normal mapping
285+
mfrom = name + "-" + child.attrib.get("from")
286+
mto = name + "-" + child.attrib.get("to")
287+
if mappings == "full":
288+
addEdge(participant, mfrom, mto, label=quote(mkind), color=color)
289+
elif mappings == "merged":
290+
e = getEdge(participant, mto, mfrom)
291+
if e is None:
292+
addEdge(participant, mfrom, mto, color=color)
293+
else:
294+
e.set_dir("both")
295+
265296
# read-data
266297
for read in elem.findall("read-data"):
267298
mesh = read.attrib["mesh"]
268299
meshNode = f"{name}-{mesh}"
269300
data = read.attrib["name"]
270301
if data_access == "full":
302+
label = data + f" (JIT {jit_from[mesh]})" if mesh in jit_from else ""
271303
addEdge(
272304
participant,
273305
meshNode,
274306
name,
275-
label=quote(data),
307+
label=label,
276308
tooltip=dataType[data],
277309
color=color,
278310
)
@@ -288,11 +320,12 @@ def lookupParticipantColor(name):
288320
meshNode = f"{name}-{mesh}"
289321
data = write.attrib["name"]
290322
if data_access == "full":
323+
label = data + f" (JIT {jit_to[mesh]})" if mesh in jit_to else ""
291324
addEdge(
292325
participant,
293326
name,
294327
meshNode,
295-
label=quote(data),
328+
label=label,
296329
tooltip=dataType[data],
297330
color=color,
298331
)
@@ -320,22 +353,6 @@ def lookupParticipantColor(name):
320353
)
321354
addEdge(participant, meshNode, wpnode, color=color)
322355

323-
# other children
324-
for child in elem.iterchildren():
325-
# register mappings
326-
if child.tag.startswith("mapping:"):
327-
mkind = child.tag[child.tag.find(":") + 1 :]
328-
mfrom = name + "-" + child.attrib["from"]
329-
mto = name + "-" + child.attrib["to"]
330-
if mappings == "full":
331-
addEdge(participant, mfrom, mto, label=quote(mkind), color=color)
332-
elif mappings == "merged":
333-
e = getEdge(participant, mto, mfrom)
334-
if e is None:
335-
addEdge(participant, mfrom, mto, color=color)
336-
else:
337-
e.set_dir("both")
338-
339356
# master
340357
if child.tag.startswith("master:"):
341358
kind = child.tag[child.tag.find(":") + 1 :]

0 commit comments

Comments
 (0)