Skip to content

feat: add export result as vtp files #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c0796cd
add method to allow export simulation result as vtp files
Jun 25, 2025
a35eca1
chore: adding changelog file 643.added.md [dependabot-skip]
pyansys-ci-bot Jun 25, 2025
697a846
handle photometric result and radiometric data in xmp text
Jun 28, 2025
f28bfd4
put warning for spectral xmp
Jun 28, 2025
e1a895e
fix issue export 3d sensor uses sensor_paths rather finding all 3d se…
Jun 28, 2025
4497a07
fix 3d sensor to handle different measurement settings
Jun 28, 2025
22c6165
support spectral data summing all the values into single data table
Jun 29, 2025
e12d961
update to use COM API method
Jun 29, 2025
6162dd0
Merge branch 'main' into feat/export-vtp
pluAtAnsys Jun 30, 2025
3b267b3
add support when set_type_radiometric for 3d sensor
Jun 30, 2025
890257f
add unittest for export 3d sensor result as vtp
Jun 30, 2025
2a94a39
fix typo issue for checking spectral type.
Jun 30, 2025
cab2f13
use point_data
Jun 30, 2025
f341830
change the name to avoid confusing between radiance or irradiance res…
Jun 30, 2025
1f5b421
refactor the spectral data text file reading
Jun 30, 2025
e5aee3f
add unittest for irradiance xmp to vtp files
Jun 30, 2025
9af23a7
add skip for unittest as COM API is used as not available on docker
Jun 30, 2025
24f6b0b
typo
Jun 30, 2025
d4e855a
fix issue when reading 3d sensor txt file when certain measurements a…
Jul 1, 2025
a95f09f
fix issue when having multiple layers in xm3
Jul 1, 2025
96dc8f4
fix reading multiple layers info in 3d sensor text
Jul 1, 2025
dddb835
add support exporting vtp when running compute_GPU
Jul 3, 2025
6243071
Merge branch 'main' into feat/export-vtp
pluAtAnsys Jul 4, 2025
e450a1a
Merge remote-tracking branch 'origin/feat/export-vtp' into feat/expor…
Jul 4, 2025
acaec43
avoid using .path in the result processing
Jul 4, 2025
c997976
use _find_correct_result rather than using .path
Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/643.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add export result as vtp files
63 changes: 59 additions & 4 deletions src/ansys/speos/core/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
import warnings

from ansys.api.speos.job.v2 import job_pb2
from ansys.api.speos.job.v2.job_pb2 import Result
from ansys.api.speos.scene.v2 import scene_pb2 as messages
from ansys.api.speos.simulation.v1 import simulation_template_pb2
from ansys.speos.core.generic.general_methods import min_speos_version

# from ansys.speos.core.geo_ref import GeoRef
from ansys.speos.core.kernel.job import ProtoJob
from ansys.speos.core.kernel.proto_message_utils import protobuf_message_to_str
from ansys.speos.core.kernel.scene import ProtoScene
Expand Down Expand Up @@ -265,14 +264,57 @@ def export(self, export_path: Union[str, Path]) -> None:
"Selected simulation is not the first simulation feature, it can't be exported."
)

def compute_CPU(self, threads_number: Optional[int] = None) -> List[job_pb2.Result]:
def _export_vtp(self) -> List[Path]:
"""Export the simulation results into vtp files.

Returns
-------
List[Path]
list of vtp paths.

"""
vtp_files = []
from ansys.speos.core import Face
from ansys.speos.core.sensor import Sensor3DIrradiance, SensorIrradiance
from ansys.speos.core.workflow.open_result import export_xm3_vtp, export_xmp_vtp

sensor_paths = self.get(key="sensor_paths")
for feature in self._project._features:
if feature._name not in sensor_paths:
continue
match feature:
case SensorIrradiance():
xmp_data = feature.get(key="result_file_name")
exported_vtp = export_xmp_vtp(self, xmp_data)
vtp_files.append(exported_vtp)
case Sensor3DIrradiance():
xm3_data = feature.get(key="result_file_name")
geo_paths = feature.get(key="geo_paths")
geos_faces = [
self._project.find(name=geo_path, feature_type=Face)[0]._face
for geo_path in geo_paths
]
exported_vtp = export_xm3_vtp(self, geos_faces, xm3_data)
vtp_files.append(exported_vtp)
case _:
warnings.warn(
"feature {} result currently not supported".format(feature._name),
stacklevel=2,
)
return vtp_files

def compute_CPU(
self, threads_number: Optional[int] = None, export_vtp: Optional[bool] = False
) -> tuple[list[Result], list[Path]] | list[Result]:
"""Compute the simulation on CPU.

Parameters
----------
threads_number : int, optional
The number of threads used.
By default, ``None``, means the number of processor available.
export_vtp: bool, optional
True to generate vtp from the simulation results.

Returns
-------
Expand All @@ -287,18 +329,31 @@ def compute_CPU(self, threads_number: Optional[int] = None) -> List[job_pb2.Resu
)

self.result_list = self._run_job()
if export_vtp:
vtp_files = self._export_vtp()
return self.result_list, vtp_files
return self.result_list

def compute_GPU(self) -> List[job_pb2.Result]:
def compute_GPU(
self, export_vtp: Optional[bool] = False
) -> tuple[list[Result], list[Path]] | list[Result]:
"""Compute the simulation on GPU.

Parameters
----------
export_vtp: bool, optional
True to generate vtp from the simulation results.

Returns
-------
List[ansys.api.speos.job.v2.job_pb2.Result]
List of simulation results.
"""
self._job.job_type = ProtoJob.Type.GPU
self.result_list = self._run_job()
if export_vtp:
vtp_files = self._export_vtp()
return self.result_list, vtp_files
return self.result_list

def _run_job(self) -> List[job_pb2.Result]:
Expand Down
Loading