Skip to content

Conversation

@akaszynski
Copy link
Contributor

@akaszynski akaszynski commented Jan 1, 2021

This PR makes a few changes to ansys.dpf.core.plotter.Plotter. Some keyword arguments were added, along with some performance improvements when mapping an individual field to the global data array.

Previously, we had:

i = 0
scop_ids = field.scoping.ids
while i < size:
    ind = m_id_to_index[scop_ids[i]]
    overall_data[ind] = data[i]
   i += 1

This works quite well since python dictionaries (m_id_to_index) are quite fast. However, we can do a bit better by implementing a map and get, since those are implemented in C. Locally, this results in a 3x speedup in this section of code, which can be quite significant considering that it takes around ~60 ms prior to optimization for a 70k node model. For a 1M node model, estimated time savings for this method is around 570 ms.

New implementation is:

ind = list(map(m_id_to_index.get, field.scoping.ids))
overall_data[ind] = field.data

@akaszynski akaszynski requested a review from anslpa January 1, 2021 07:40
@akaszynski akaszynski merged commit 2e394f0 into master Jan 2, 2021
@akaszynski akaszynski deleted the fix/cleanup-plotter branch January 4, 2021 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants