trixi-framework / Trixi.jl

Trixi.jl: Adaptive high-order numerical simulations of conservation laws in Julia
https://trixi-framework.github.io/Trixi.jl
MIT License
505 stars 98 forks source link

Towards partitioned RHS's (1D) #1967

Open DanielDoehring opened 3 weeks ago

DanielDoehring commented 3 weeks ago

This draft is one way how we could realize partitioned RHS's with relatively little changes to the existing code. Opinions on this @sloede ?

Related to https://github.com/trixi-framework/Trixi.jl/issues/21

github-actions[bot] commented 3 weeks ago

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

Code quality

Documentation

Testing

Performance

Verification

Created with :heart: by the Trixi.jl community.

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.16%. Comparing base (def208b) to head (78a7786).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1967 +/- ## ======================================= Coverage 96.16% 96.16% ======================================= Files 460 460 Lines 36980 36980 ======================================= Hits 35560 35560 Misses 1420 1420 ``` | [Flag](https://app.codecov.io/gh/trixi-framework/Trixi.jl/pull/1967/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/trixi-framework/Trixi.jl/pull/1967/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | `96.16% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sloede commented 1 week ago

This draft is one way how we could realize partitioned RHS's with relatively little changes to the existing code. Opinions on this @sloede ?

From a first look, I like the idea!

An small variation could be to have a modified function without default argument and create new functions with the old API that call it with eachelement(...) etc. But I don't know if that's really more readable. Have you checked if your change impacts the performance (since now maybe the compiler is not able to infer as much as before)?

Another thought is that to me, range strongly implies an ordered subset of an array, e.g., something like 5:10 or 10:2:20. However, in this case there is no such a restriction - it is just a bunch of indices. So maybe {element,interface,whatever}_indices would be more apt?

sloede commented 1 week ago

In general, I think this would be a good topic to bring up at a Trixi.jl meeting for discussion (possibly with a heads up in Slack such that people can think about it beforehand)

DanielDoehring commented 1 week ago

An small variation could be to have a modified function without default argument and create new functions with the old API that call it with eachelement(...) etc. But I don't know if that's really more readable.

True, but this adds in principle the overhead of calling another function, right? But should be explored in a benchmarking run.

Have you checked if your change impacts the performance (since now maybe the compiler is not able to infer as much as before)?

No, not yet.

Another thought is that to me, range strongly implies an ordered subset of an array, e.g., something like 5:10 or 10:2:20. However, in this case there is no such a restriction - it is just a bunch of indices. So maybe {element,interface,whatever}_indices would be more apt?

Yeah that sounds reasonable :+1:

sloede commented 1 week ago

An small variation could be to have a modified function without default argument and create new functions with the old API that call it with eachelement(...) etc. But I don't know if that's really more readable.

True, but this adds in principle the overhead of calling another function, right? But should be explored in a benchmarking run.

Yes and yes. In the end, it is likely that it doesn't make a difference performance-wise.

ranocha commented 1 week ago

Sounds reasonable. Could you please run some benchmarks?

DanielDoehring commented 5 days ago

Currently, we do not benchmark any 1D simulation:

https://github.com/trixi-framework/Trixi.jl/blob/961f2e7423bd14c6d64170c296ea8238a26a2995/benchmark/benchmarks.jl#L13-L39

I could add some 1D elixirs locally or we extend the benchmarks by some representative elixirs for 1D.

Otherwise, I could extend these changes to 2D to get benchmark results for this.

ranocha commented 4 days ago

I think it would be nice if you could add some representative 1D elixirs to the benchmarks in a new PR