Skip to content

feat: using dpf instead of reader in "results" module #1300

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

Open
wants to merge 184 commits into
base: main
Choose a base branch
from

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Jul 27, 2022

As the title.

The key is to replace the class ansys-mapdl-reader.rst.Result by some class which provides the same interface. The complete lists of functions in that class are:

Show list of Result class functions

ELEMENT_INDEX_TABLE_KEYS
ELEMENT_RESULT_NCOMP
__annotations__
__class__
__del__
__delattr__
__dict__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__module__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__sizeof__
__str__
__subclasshook__
__weakref__
_animate_point_scalars
_animate_time_solution
_bc_header
_cfile
_element_map
_element_solution_header
_extract_element_components
_extract_node_components
_extract_surface_element_result
_is_cyclic
_is_distributed
_is_main
_is_thermal
_load_element_table
_load_materials
_load_section_data
_map_flag
_nodal_result
_nodal_solution_result
_nodfor
_nodstr
_plot_nodal_result
_plot_point_scalars
_read_components
_read_result_header
_result_nitem
_result_pointers
_result_solution_header
_result_solution_header_ext
_solution_header
_store_mesh
animate_nodal_displacement
animate_nodal_solution
animate_nodal_solution_set
available_results
cs_4x4
cylindrical_nodal_stress
element_components
element_lookup
element_solution_data
element_stress
filename
materials
mesh
n_results
n_sector
nodal_acceleration
nodal_boundary_conditions
nodal_displacement
nodal_elastic_strain
nodal_input_force
nodal_plastic_strain
nodal_reaction_forces
nodal_solution
nodal_static_forces
nodal_stress
nodal_temperature
nodal_thermal_strain
nodal_time_history
nodal_velocity
node_components
overwrite_element_solution_record
overwrite_element_solution_records
parse_coordinate_system
parse_step_substep
pathlib_filename
plot
plot_cylindrical_nodal_stress
plot_element_result
plot_nodal_displacement
plot_nodal_elastic_strain
plot_nodal_plastic_strain
plot_nodal_solution
plot_nodal_stress
plot_nodal_temperature
plot_nodal_thermal_strain
plot_principal_nodal_stress
principal_nodal_stress
read_record
result_dof
save_as_vtk
section_data
solution_info
text_result_table
time_values
version
write_tables

However, I'm planning to migrate only the public ones:

Core

  • Launch DPF when running in container This should not be part of PyMAPDL since if it is local, it will be automatically detected, and if it is remote, we should not own that resource. It could be something for PyMAPDL developers.
  • Global switch for DPF/Reader
  • Mesh class needs to be recreated. This class is different (but with similar API) to the one we are using in MapdlGrpc class.
  • Can we get the hostname of the machine where DPF is running using DPF operators? https://dpf.docs.pyansys.com/version/stable/api/ansys/dpf/core/server_types/GrpcServer.html#overview

To migrate

Next PRs

Mesh object

Plotting PR

  • animate_nodal_displacement
  • animate_nodal_solution
  • animate_nodal_solution_set
  • plot
  • plot_cylindrical_nodal_stress
  • plot_element_result
  • plot_nodal_displacement
  • plot_nodal_elastic_strain
  • plot_nodal_plastic_strain
  • plot_nodal_solution
  • plot_nodal_stress
  • plot_nodal_temperature
  • plot_nodal_thermal_strain
  • plot_principal_nodal_stress

VTK PR

  • save_as_vtk
    This is going to require a separate package.

To not migrate.

A NotImplementedError will be raised.

  • cs_4x4 - I couldn't make it work locally, so I'm not porting it. It will raise a not implemented error.
  • solution_info
    It doesn't make sense to be ported, because of this type of information is hidden in DPF.
     >>> rst.solution_info(0)
            {'cgcent': [],
             'fatjack': [],
             'timfrq': 44.85185724963714,
             'lfacto': 1.0,
             'lfactn': 1.0,
             'cptime': 3586.4873046875,
             'tref': 71.6,
  • text_result_table
    Used for the text in the plots. Not porting it.
  • write_tables: Write binary tables to ASCII.
  • read_record: Read a record from the opened file. Records are hidden in DPF.
  • overwrite_element_solution_record: DPF cannot write solution files.
  • overwrite_element_solution_records: DPF cannot write solution files.

There are many methods which are duplicate from mapdl.post_processing, I will probably redirect one to another (I don't know which one should prevail, probably post-processing).

Summary by Sourcery

Replace the legacy reader‐based results interface with a new DPF backend: introduce a global switch to toggle backends, implement and expose the DPFResult class with migrated public APIs using ansys-dpf-core, update test infrastructure and CI workflows to support DPF testing, and refine misc, launcher, and pytest utilities to accommodate the change.

New Features:

  • Introduce a DPF-based result backend controlled by a new use_reader_backend switch in MAPDL.
  • Add a new DPFResult class under ansys.mapdl.core.reader.result migrating public result APIs to use ansys-dpf-core.
  • Expose utility functions get_ip and parse_ip_route for IP detection and switch GRPC/Docker connection logic.

Bug Fixes:

  • Strip whitespace from output of MapdlGrpc.sys and clarify assertion error when reusing MAPDL instances.

Enhancements:

  • Improve pytest reporting by truncating long messages and wrapping lines, and include PYMAPDL_ADDITIONAL_SWITCHES in headers.
  • Enhance mapdl.result file‐path handling to create isolated temp directories and enrich FileNotFoundError messages.
  • Refactor IP‐route parsing and unify _parse_ip_route usage in launcher and misc modules.

CI:

  • Introduce TEST_DPF_BACKEND environment variable in CI workflows to enable/disable DPF tests.

Documentation:

  • Add a changelog entry for the new DPF‐based results module.

Tests:

  • Add comprehensive DPFResult tests in tests/test_result.py and update fixtures for test_dpf_backend.
  • Adjust tests/conftest.py, tests/common.py, and test launcher to integrate DPF backend testing.

@germa89 germa89 self-assigned this Jul 27, 2022
@codecov
Copy link

codecov bot commented Aug 5, 2022

Codecov Report

Attention: Patch coverage is 59.09091% with 27 lines in your changes missing coverage. Please review.

Project coverage is 85.50%. Comparing base (27d26c4) to head (55fd609).
Report is 1 commits behind head on main.

❌ Your patch check has failed because the patch coverage (59.09%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1300      +/-   ##
==========================================
- Coverage   89.17%   85.50%   -3.67%     
==========================================
  Files         187      189       +2     
  Lines       14970    15619     +649     
==========================================
+ Hits        13349    13355       +6     
- Misses       1621     2264     +643     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akaszynski
Copy link
Collaborator

Fundamentally, this all needs to be moved to DPF-Post and DPF post needs to have an even simpler API.

Right now we have:

  • DPF-Core
  • DPF-Post
  • MAPDL-Post
  • Legacy reader

I'd rather not make a 5th. There's a potential new hire that will work for the PyAnsys team on DPF-Post and I'd like him to work on this along with you.

germa89 added 30 commits June 19, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD Related with CICD, Github Actions, etc DO NOT MERGE Not ready to be merged yet maintenance General maintenance of the repo (libraries, cicd, etc) new feature Request or proposal for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants