-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add support for plotting 1D function #2250
Conversation
Review checklistThis 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 ❤️ by the Trixi.jl community. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2250 +/- ##
==========================================
- Coverage 96.87% 96.87% -0.00%
==========================================
Files 490 490
Lines 39427 39454 +27
==========================================
+ Hits 38194 38220 +26
- Misses 1233 1234 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This is ready for a review from my point of view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Once the codecov is fine this can be merged.
I think it will be hard to make codecov happy on this one because lines like this, i.e., the function definition lines of the plot recipes are just not caught by codecov. So we can't do much against it. The only two lines that are not covered are the error messages, but I think it's fine to not cover them. |
Yeah that is always with the case - ironically, code coverage punishes you for adding safety :D Would be nice to add comments for codecov s.t. some lines are tolerated to be skipped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Nice feature to have 👍
Co-authored-by: Hendrik Ranocha <[email protected]>
5f29ace
Co-authored-by: Hendrik Ranocha <[email protected]>
Could you please post the result of one or two examples? If that looks good, this PR should be ready to go 👍 |
Sure: julia> include("examples/tree_1d_dgsem/elixir_euler_density_wave.jl")
[...]
julia> plot((x, equations) -> initial_condition(x, last(tspan), equations), semi)
julia> plot((x, equations) -> cons2prim(initial_condition(x, last(tspan), equations), equations), semi)
julia> plot!(sol)
julia> plot((x, equations) -> sinpi.(x), semi, nvisnodes = 5) The calls look the same for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Sometimes it might be of interest to not only plot the numerical solution, but also other functions on top of it, especially in a 1D plot. Often this is done with the initial condition/analytical solution as reference. Currently, as far as I know, there was no straightforward way to accomplish this in 1D (except for using the internal
semi.cache.elements.node_coordinates
).This PR enables the possibility to call
plot(func, semi)
, wherefunc
is a function accepting spatial coordinatesx
and theequations
, i.e. it is called byfunc(x, equations)
. A common example would be(x, equations) -> initial_condition(x, last(tspan), equations)
.If you agree that it would be nice to support this, I can clean up the PR a bit.