|
82 | 82 | TimeAverageSurfaceProbeOutput, |
83 | 83 | TimeAverageVolumeOutput, |
84 | 84 | UserDefinedField, |
85 | | - VolumeOutput, |
| 85 | + VolumeOutput, RenderOutputGroup, |
86 | 86 | ) |
87 | 87 | from flow360.component.simulation.primitives import ( |
88 | 88 | BOUNDARY_FULL_NAME_WHEN_NOT_FOUND, |
|
113 | 113 | replace_dict_key, |
114 | 114 | translate_setting_and_apply_to_all_entities, |
115 | 115 | translate_value_or_expression_object, |
116 | | - update_dict_recursively, |
117 | 116 | ) |
118 | 117 | from flow360.component.simulation.unit_system import LengthType |
119 | 118 | from flow360.component.simulation.user_code.core.types import ( |
@@ -596,56 +595,51 @@ def translate_render_output( |
596 | 595 | exclude_none=True, exclude_unset=True, by_alias=True |
597 | 596 | ) |
598 | 597 |
|
599 | | - materials = {} |
600 | | - |
601 | | - for name, material in render.materials.items(): |
602 | | - material = material.model_dump(exclude_none=True, exclude_unset=True, by_alias=True) |
603 | | - materials[name] = material |
604 | | - |
| 598 | + for render_group in render.groups: |
| 599 | + material = render_group.material.model_dump(exclude_none=True, exclude_unset=True, by_alias=True) |
605 | 600 | if "outputField" in material and material["outputField"] not in render.output_fields: |
606 | | - print(f"Adding material field: {material['outputField']}") |
607 | | - render.output_fields.append(material["outputField"]) |
608 | | - |
609 | | - print(f"Render output fields are: {render.output_fields}") |
610 | | - |
611 | | - print(f"Materials are: {materials}") |
| 601 | + render.output_fields.append(material["outputField"]) |
612 | 602 |
|
613 | 603 | translated_output = { |
| 604 | + "name": render.name, |
614 | 605 | "animationFrequency": render.frequency, |
615 | 606 | "animationFrequencyOffset": render.frequency_offset, |
616 | | - "surfaces": translate_setting_and_apply_to_all_entities( |
617 | | - [render], |
618 | | - RenderOutput, |
619 | | - translation_func=translate_output_fields, |
620 | | - to_list=False, |
621 | | - entity_type_to_include=Surface, |
622 | | - entity_list_attribute_name="surfaces" |
623 | | - ), |
624 | | - "slices": translate_setting_and_apply_to_all_entities( |
625 | | - [render], |
626 | | - RenderOutput, |
627 | | - translation_func=translate_output_fields, |
628 | | - to_list=False, |
629 | | - entity_injection_func=slice_injection_function, |
630 | | - entity_type_to_include=Slice, |
631 | | - entity_list_attribute_name="slices" |
632 | | - ), |
633 | | - "isoSurfaces": translate_setting_and_apply_to_all_entities( |
634 | | - [render], |
635 | | - RenderOutput, |
636 | | - translation_func=translate_output_fields, |
637 | | - to_list=False, |
638 | | - entity_injection_func=isosurface_injection_function, |
639 | | - entity_type_to_include=Isosurface, |
640 | | - entity_list_attribute_name="isosurfaces", |
641 | | - entity_injection_input_params=input_params, |
642 | | - ), |
| 607 | + "groups": [], |
643 | 608 | "camera": remove_units_in_dict(camera), |
644 | 609 | "lighting": remove_units_in_dict(lighting), |
645 | 610 | "environment": remove_units_in_dict(environment), |
646 | | - "materials": remove_units_in_dict(materials), |
| 611 | + "outputFields": translate_output_fields(render)["outputFields"] |
647 | 612 | } |
648 | 613 |
|
| 614 | + for render_group in render.groups: |
| 615 | + material = render_group.material.model_dump(exclude_none=True, exclude_unset=True, by_alias=True) |
| 616 | + translated_output["groups"].append({ |
| 617 | + "surfaces": translate_setting_and_apply_to_all_entities( |
| 618 | + [render_group], |
| 619 | + RenderOutputGroup, |
| 620 | + to_list=False, |
| 621 | + entity_type_to_include=Surface, |
| 622 | + entity_list_attribute_name="surfaces" |
| 623 | + ), |
| 624 | + "slices": translate_setting_and_apply_to_all_entities( |
| 625 | + [render_group], |
| 626 | + RenderOutputGroup, |
| 627 | + to_list=False, |
| 628 | + entity_injection_func=slice_injection_function, |
| 629 | + entity_type_to_include=Slice, |
| 630 | + entity_list_attribute_name="slices" |
| 631 | + ), |
| 632 | + "isoSurfaces": translate_setting_and_apply_to_all_entities( |
| 633 | + [render_group], |
| 634 | + RenderOutputGroup, |
| 635 | + to_list=False, |
| 636 | + entity_injection_func=isosurface_injection_function, |
| 637 | + entity_type_to_include=Isosurface, |
| 638 | + entity_list_attribute_name="isosurfaces", |
| 639 | + entity_injection_input_params=input_params, |
| 640 | + ), |
| 641 | + "material": remove_units_in_dict(material) |
| 642 | + }) |
649 | 643 | if render.transform: |
650 | 644 | transform = render.transform.model_dump( |
651 | 645 | exclude_none=True, exclude_unset=True, by_alias=True |
|
0 commit comments