Skip to content
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

RFC: Source terms via callback #172

Draft
wants to merge 96 commits into
base: main
Choose a base branch
from
Draft

Conversation

benegee
Copy link
Collaborator

@benegee benegee commented Feb 29, 2024

This is to demonstrate how an external function could be called to evaluate source terms.

Issues:

  • Path to shared object is currently hard-coded.
  • Global buffer variable in libelixir to prevent subsequent allocations in source_term_callback

Some rough timing results:

Timing libtrixi
────────────────────────────────────────────────────────────────────────────────────────────────────
Trixi.jl simulation finished.  Final time: 2.0  Time steps: 229 (accepted), 229 (total)
────────────────────────────────────────────────────────────────────────────────────────────────────


*** Trixi controller ***   Finalize Trixi simulation
 ────────────────────────────────────────────────────────────────────────────────────
              Trixi.jl                      Time                    Allocations
                                   ───────────────────────   ────────────────────────
         Tot / % measured:              2.39s /  19.5%            129MiB /  14.2%

 Section                   ncalls     time    %tot     avg     alloc    %tot      avg
 ────────────────────────────────────────────────────────────────────────────────────
 I/O                            5    200ms   43.0%  40.1ms   10.6MiB   57.4%  2.11MiB
   save solution                4    124ms   26.6%  31.0ms   10.3MiB   56.1%  2.59MiB
   ~I/O~                        5   76.3ms   16.4%  15.3ms    230KiB    1.2%  46.1KiB
   get element variables        4   1.52μs    0.0%   380ns     0.00B    0.0%    0.00B
   save mesh                    4    501ns    0.0%   125ns     0.00B    0.0%    0.00B
   get node variables           4   88.0ns    0.0%  22.0ns     0.00B    0.0%    0.00B
 rhs!                       1.15k    174ms   37.3%   152μs   5.14KiB    0.0%    4.59B
   source terms             1.15k   80.7ms   17.3%  70.4μs     0.00B    0.0%    0.00B
   volume integral          1.15k   45.9ms    9.8%  40.0μs     0.00B    0.0%    0.00B
   interface flux           1.15k   29.7ms    6.4%  25.9μs     0.00B    0.0%    0.00B
   surface integral         1.15k   10.8ms    2.3%  9.44μs     0.00B    0.0%    0.00B
   Jacobian                 1.15k   4.16ms    0.9%  3.63μs     0.00B    0.0%    0.00B
   reset ∂u/∂t              1.15k   2.20ms    0.5%  1.92μs     0.00B    0.0%    0.00B
   ~rhs!~                   1.15k    523μs    0.1%   457ns   5.14KiB    0.0%    4.59B
   boundary flux            1.15k   21.4μs    0.0%  18.7ns     0.00B    0.0%    0.00B
 analyze solution               4   87.2ms   18.7%  21.8ms   7.85MiB   42.6%  1.96MiB
 calculate dt                 230   4.44ms    1.0%  19.3μs     0.00B    0.0%    0.00B
 ────────────────────────────────────────────────────────────────────────────────────
Timing Trixi.jl
────────────────────────────────────────────────────────────────────────────────────
              Trixi.jl                      Time                    Allocations
                                   ───────────────────────   ────────────────────────
         Tot / % measured:              164ms /  94.0%           2.00MiB /  90.6%

 Section                   ncalls     time    %tot     avg     alloc    %tot      avg
 ────────────────────────────────────────────────────────────────────────────────────
 rhs!                       1.15k    144ms   93.2%   126μs   5.14KiB    0.3%    4.59B
   source terms             1.15k   59.7ms   38.7%  52.1μs     0.00B    0.0%    0.00B
   volume integral          1.15k   41.5ms   26.9%  36.2μs     0.00B    0.0%    0.00B
   interface flux           1.15k   26.6ms   17.3%  23.2μs     0.00B    0.0%    0.00B
   surface integral         1.15k   9.68ms    6.3%  8.44μs     0.00B    0.0%    0.00B
   Jacobian                 1.15k   3.82ms    2.5%  3.34μs     0.00B    0.0%    0.00B
   reset ∂u/∂t              1.15k   1.99ms    1.3%  1.73μs     0.00B    0.0%    0.00B
   ~rhs!~                   1.15k    498μs    0.3%   434ns   5.14KiB    0.3%    4.59B
   boundary flux            1.15k   28.8μs    0.0%  25.2ns     0.00B    0.0%    0.00B
 I/O                            5   4.82ms    3.1%   964μs   1.56MiB   85.9%   319KiB
   save solution                4   4.31ms    2.8%  1.08ms   1.55MiB   85.4%   397KiB
   ~I/O~                        5    507μs    0.3%   101μs   8.83KiB    0.5%  1.77KiB
   get element variables        4    765ns    0.0%   191ns     0.00B    0.0%    0.00B
   save mesh                    4    488ns    0.0%   122ns     0.00B    0.0%    0.00B
   get node variables           4    342ns    0.0%  85.5ns     0.00B    0.0%    0.00B
 calculate dt                 230   4.04ms    2.6%  17.6μs     0.00B    0.0%    0.00B
 analyze solution               4   1.59ms    1.0%   396μs    258KiB   13.9%  64.5KiB
 ────────────────────────────────────────────────────────────────────────────────────

Confer #173

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Project coverage is 94.33%. Comparing base (0e0ea3d) to head (4274883).

Files with missing lines Patch % Lines
examples/source_terms.c 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #172      +/-   ##
==========================================
- Coverage   95.62%   94.33%   -1.29%     
==========================================
  Files          23       24       +1     
  Lines        1097     1112      +15     
  Branches       63       63              
==========================================
  Hits         1049     1049              
- Misses         44       59      +15     
  Partials        4        4              
Flag Coverage Δ
unittests 94.33% <0.00%> (-1.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benegee benegee changed the base branch from main to bg/baroclinic-instability November 28, 2024 13:37
Base automatically changed from bg/baroclinic-instability to main January 16, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants