Skip to content

add head_array() methods for unstructured computation of heads#139

Merged
dbrakenhoff merged 5 commits into
devfrom
headgrid_unstructured
Jun 24, 2026
Merged

add head_array() methods for unstructured computation of heads#139
dbrakenhoff merged 5 commits into
devfrom
headgrid_unstructured

Conversation

@dbrakenhoff

Copy link
Copy Markdown
Contributor
  • steady and transient models
  • make headgrid use head_array under the hood.

- steady and transient models
- make headgrid use head_array under the hood.
@dbrakenhoff dbrakenhoff requested a review from mbakker7 June 18, 2026 14:14
@dbrakenhoff dbrakenhoff self-assigned this Jun 18, 2026
@dbrakenhoff dbrakenhoff added the enhancement New feature or request label Jun 18, 2026
@dbrakenhoff

Copy link
Copy Markdown
Contributor Author

test fail fixed in #138

…_map)

- remove storeinputs to allow pickling
- add velocity_array methods
- refactor head_array and velocity_array to use multiprocessing in parallel branch.
- only support tqdm progressbars or nothing
- parallel is bool or int, where int is interpreted as number of processes
- align docstrings
- add pickleable helper funcs
@dbrakenhoff

Copy link
Copy Markdown
Contributor Author

@mbakker7 this is ready for review now

@mbakker7

Copy link
Copy Markdown
Contributor

This looks nice. I tried the headgrid function in timflow.transient on a Macbook Air. It only has 10 cores (4 for performance, 6 for efficiency). With parallel=True I get a speedup of 10%. With parallel=4 I get a speedup of 30%. Maybe I don't have enough elements to worry about, as the run time is still short. Computing a 50 by 50 grid for 100 times only takes about 3 seconds. Is a bigger improvement expected when the model is so large that it would take, say 30 seconds?

@mbakker7 mbakker7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just ran a more substantial example (the parallel_example from #140). Generating a grid is 3 times faster with parallel=True, so great job! Good note that there is hardly any time lost by computing the grid at 10 different times rather than just 1 time.
So nice job!

@dbrakenhoff

Copy link
Copy Markdown
Contributor Author

Yea, i expect the speedup to be more significant for larger models (more elements) and finer grids, up to a certain point of course.

I think 3x speedup on 4 main cores seems reasonable. On my PC using the maximum number of threads (mp.cpu_count()) also didn't get me the fastest run time. The optimal setting probably depends a bit on the problem and the overhead of parallelization.

@dbrakenhoff dbrakenhoff merged commit d1b8d6b into dev Jun 24, 2026
11 checks passed
@dbrakenhoff dbrakenhoff deleted the headgrid_unstructured branch June 24, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compute heads and velocities on unstructured grids

2 participants