Skip to content
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

Optimize Node Processing in ROM Basis Setting #12240

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

SADPR
Copy link
Contributor

@SADPR SADPR commented Apr 2, 2024

Description

This PR introduces performance optimizations to the node processing logic in rom_analysis.py, specifically for setting the Reduced Order Model (ROM) basis. The original implementation, which iterated over all nodes using np.where within a loop, was suboptimal for large datasets.

Changes

File Modified

  • rom_analysis.py

Key Modifications

  • Implemented a preprocessing step to create a dictionary (node_id_to_index), mapping each node ID to its index in the node_ids array. This optimizes the retrieval of node indices during the main processing loop.
  • Updated the loop over nodes to leverage the node_id_to_index mapping for efficient index lookup, thereby reducing computational overhead.

Benefits

  • Performance Improvement: Significant reduction in computation time, especially beneficial for large models with numerous nodes.

Additional Notes

  • The changes maintain the existing functionality while greatly enhancing performance, particularly in large-scale applications.
  • Care was taken to ensure compatibility with the rest of the rom_analysis.py module.

@SADPR SADPR requested a review from a team as a code owner April 2, 2024 12:06
@SADPR SADPR added FastPR This Pr is simple and / or has been already tested and the revision should be fast ROM labels Apr 2, 2024
@SADPR SADPR added this to In progress in ROM Application Project via automation Apr 2, 2024
Copy link
Member

@Rbravo555 Rbravo555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. You use a python dictionary as a mapping, instead of using np.where

@Rbravo555 Rbravo555 merged commit 5690728 into master Apr 2, 2024
11 checks passed
@Rbravo555 Rbravo555 deleted the Kratos_ROM_SetROMBASIS branch April 2, 2024 14:18
ROM Application Project automation moved this from In progress to Done Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FastPR This Pr is simple and / or has been already tested and the revision should be fast ROM
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants