Skip to content

Commit 5379a00

Browse files
committed
#422: Begin experimenting with VTDataWriter to pass data to vt-tv
1 parent eb706ff commit 5379a00

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

config/test-vt-tv.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Specify input
2+
from_data:
3+
data_stem: ../data/nolb-8color-16nodes-11firstphases/data
4+
phase_ids:
5+
- 0
6+
- 1
7+
- 2
8+
- 3
9+
- 4
10+
- 5
11+
- 6
12+
- 7
13+
- 8
14+
- 9
15+
- 10
16+
check_schema: False
17+
18+
# Specify work model
19+
work_model:
20+
name: AffineCombination
21+
parameters:
22+
alpha: 1.0
23+
beta: 1.0e-08
24+
gamma: 0.0
25+
26+
# Specify algorithm
27+
algorithm:
28+
name: PhaseStepper
29+
30+
# Specify output
31+
output_dir: ../output
32+
output_file_stem: output_file
33+
LBAF_Viz:
34+
x_ranks: 8
35+
y_ranks: 4
36+
z_ranks: 1
37+
object_jitter: 0.5
38+
rank_qoi: work
39+
object_qoi: load
40+
save_meshes: True
41+
force_continuous_object_qoi: True
42+
43+
write_JSON:
44+
compressed: False
45+
suffix: json
46+
communications: True
47+
offline_LB_compatible: True

src/lbaf/Applications/LBAF_app.py

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import importlib
77
import yaml
88

9+
import tv
10+
911
# pylint:disable=C0413:wrong-import-position
1012
# Use lbaf module from source if lbaf package is not installed
1113
if importlib.util.find_spec('lbaf') is None:
@@ -570,6 +572,13 @@ def run(self):
570572
self.__parameters.object_qoi
571573
]
572574

575+
# Serialize data to JSON-formatted string
576+
json_str = self.__json_writer.serialize_phases(phases)
577+
print(json_str)
578+
579+
# Pass string to vt-tv for rendering
580+
tv.process_json(json_str)
581+
573582
# Instantiate and execute visualizer
574583
visualizer = Visualizer(
575584
self.__logger,

src/lbaf/IO/lbsVTDataWriter.py

+27
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ def __create_tasks(self, rank_id, objects, migratable):
6868
tasks.append(task_data)
6969
return tasks
7070

71+
def serialize_phases(self, phases) -> str:
72+
"""Serialize rank for list of phase instances data in a JSON-formatted string."""
73+
for p in phases.values():
74+
p_id = p.get_id()
75+
for rank in p.get_ranks():
76+
r_id = rank.get_id()
77+
78+
# Initialize output dict
79+
output = {
80+
"metadata": {
81+
"type": "LBDatafile",
82+
"rank": r_id},
83+
"phases": []}
84+
85+
# Iterate over phases
86+
for p_id, phase in phases.items():
87+
# Create data to be outputted for current phase
88+
self.__logger.debug(f"Serializing phase {p_id} for rank {r_id}")
89+
phase_data = {"id": p_id}
90+
phase_data["tasks"] = self.__create_tasks(
91+
r_id, rank.get_migratable_objects(), migratable=True) + self.__create_tasks(
92+
r_id, rank.get_sentinel_objects(), migratable=False)
93+
output["phases"].append(phase_data)
94+
95+
# Serialize and return JSON payload
96+
serial_json = json.dumps(output, separators=(',', ':'))
97+
return serial_json
7198

7299
def _json_writer(self, rank_phases_double) -> str:
73100
"""Write one JSON per rank for list of phase instances."""

0 commit comments

Comments
 (0)