-
Notifications
You must be signed in to change notification settings - Fork 1
RFC: Source terms via callback #172
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
base: main
Are you sure you want to change the base?
Conversation
add parameter index and only get averaged of the variable at position index
proof of concept for creating data vectors in libelixirs which can be filled later by external applications
required in this PR, subject to change
demonstrates source terms via database
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
+ Coverage 96.15% 96.19% +0.04%
==========================================
Files 25 26 +1
Lines 1273 1289 +16
Branches 74 74
==========================================
+ Hits 1224 1240 +16
Misses 45 45
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This has not been adopted by an external application but I still like the demo. Could we include it as well? |
LibTrixi.jl/examples/libelixir_structured2d_source_terms_callback.jl
Outdated
Show resolved
Hide resolved
LibTrixi.jl/examples/libelixir_structured2d_source_terms_callback.jl
Outdated
Show resolved
Hide resolved
| void source_term_wave(const double * u, const double * x, const double t, | ||
| const double gamma, double * sourceterm) { |
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.
Should we pass in the length of u, x, sourceterm?
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.
And then check on C side before accessing the fields?
| function (callback::SourceTermsCallback)(u, x, t, equations::CompressibleEulerEquations2D) | ||
| @unpack source_term_fptr, buffer = callback | ||
| @ccall $source_term_fptr(u::Ptr{Cdouble}, x::Ptr{Cdouble}, t::Cdouble, | ||
| equations.gamma::Cdouble, buffer::Ptr{Cdouble})::Cvoid | ||
| return SVector(buffer[]) |
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.
Would be nice to have some documentation. Are we calling this per point? It might be better for the user if they could call it over all points. The call-overhead is small, but present.
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.
Both true!
Trixi.jl's approach is to evaluate per point. If you would rather like to evaluate at all points and then access the values via indices you have to redefine Trixi.jl's calc_sources!. We did this here
| function Trixi.calc_sources!(du, u, t, source_terms::SourceTerm, |
but it's not very elegant.
This is to demonstrate how an external function could be called to evaluate source terms.
Issues:
source_term_callbackSome rough timing results:
Timing libtrixi
Timing Trixi.jl
Confer #173