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

Add functionality for `TimeSeries` callback on `UnstructuredMesh2D` #1855

Closed andrewwinters5000 closed 3 months ago

andrewwinters5000 commented 4 months ago

~For now this callback is only reliable on straight-sided unstructured elements. If a curved element contains a time series point then a warning is thrown to inform the user. The callback itself still works and creates data, but it may have errors.~

I updated my element identification strategy such that this callback now works as expected on curvilinear elements as well. It uses the same Newton approach and reuses the existing mapping and metric functions used in the mesh creation. It took me a bit to realize that we already had all the tools necessary to invert the transfinite interpolation as well. My new strategy to identify if a point lies in a curved element is a bit brute force (it involves computing all the barycenters), so I am open to suggestions to optimize it if it allocates too much or so.

github-actions[bot] commented 4 months 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 4 months ago

Codecov Report

Attention: Patch coverage is 98.60140% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 87.23%. Comparing base (1ca37cf) to head (d81b79e). Report is 1 commits behind head on main.

Files Patch % Lines
src/callbacks_step/time_series_dg2d.jl 98.20% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1855 +/- ## ========================================== - Coverage 89.44% 87.23% -2.22% ========================================== Files 438 439 +1 Lines 35593 35734 +141 ========================================== - Hits 31836 31170 -666 - Misses 3757 4564 +807 ``` | [Flag](https://app.codecov.io/gh/trixi-framework/Trixi.jl/pull/1855/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/1855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | `87.23% <98.60%> (-2.22%)` | :arrow_down: | 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 4 months ago

I forgot to mention in my review: It would be great to update the docs as well, indicating which mesh types are supported (both in the docstring of the callback and the docs in docs/)

andrewwinters5000 commented 4 months ago

There are still normal use cases that fail, I need to work more and make this more robust.

andrewwinters5000 commented 4 months ago

After several conversations with @patrickersing we managed to create a quite robust way to identify whether or not a point is inside a curvilinear element. It is a bit brute force and could maybe do with some optimization, but the strategy can handle all the standard and edge cases that I could think of in 2D. For the new test I added I use the mesh below where the black diamonds are the barycenters and the red dots are the points that need identified. My old strategy failed for several of these, in particular the point near the center of the domain would have been identified to be closest to the incorrect barycenter.

Screenshot 2024-03-08 at 23 11 48
andrewwinters5000 commented 4 months ago

forgot to mention in my review: It would be great to update the docs as well, indicating which mesh types are supported (both in the docstring of the callback and the docs in docs/)

I updated the docstring but could not find this callback mentioned anywhere else in the docs.

sloede commented 4 months ago

forgot to mention in my review: It would be great to update the docs as well, indicating which mesh types are supported (both in the docstring of the callback and the docs in docs/)

I updated the docstring but could not find this callback mentioned anywhere else in the docs.

You're right, sorry. I thought we had mentioned it there, but apparently we didn't.

JoshuaLampert commented 4 months ago

I updated the docstring but could not find this callback mentioned anywhere else in the docs.

We have this: https://github.com/trixi-framework/Trixi.jl/blob/main/docs/src/callbacks.md#time-series.

andrewwinters5000 commented 3 months ago

I updated the docstring but could not find this callback mentioned anywhere else in the docs.

We have this: https://github.com/trixi-framework/Trixi.jl/blob/main/docs/src/callbacks.md#time-series.

Since this general discussion links to the TimeSeriesCallback docstring where we indicate the mesh support I do not think we need to update the general callback overview.

andrewwinters5000 commented 3 months ago

@sloede @ranocha Should this feature extension get mentioned in the NEWS.md?

sloede commented 3 months ago

@sloede @ranocha Should this feature extension get mentioned in the NEWS.md?

I think this is so cool that, yes, I'd mention it!