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 global vector storage #173

Draft
wants to merge 20 commits into
base: more-data-access
Choose a base branch
from

Conversation

benegee
Copy link
Collaborator

@benegee benegee commented Feb 29, 2024

This demonstrates how source terms can be evaluated via a global shared storage.

Issues:

  • Data vectors need to be access via an index. Trixi.jl's source_terms function works with the local coordinate x. Therefore a mapping x -> index is required or a change in Trixi.jl to allow for a source_terms function operating on indices.
  • In this demonstration also a vector of node coordinates is fetched. This would become obsolete if a (t8code) mesh existed both in the calling program and within libtrixi.

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.45s /  16.8%            137MiB /  13.5%

 Section                   ncalls     time    %tot     avg     alloc    %tot      avg
 ────────────────────────────────────────────────────────────────────────────────────
 I/O                            5    199ms   48.4%  39.7ms   10.6MiB   57.4%  2.11MiB
   save solution                4    123ms   29.9%  30.7ms   10.3MiB   56.1%  2.59MiB
   ~I/O~                        5   76.0ms   18.5%  15.2ms    230KiB    1.2%  46.1KiB
   save mesh                    4    664ns    0.0%   166ns     0.00B    0.0%    0.00B
   get element variables        4    415ns    0.0%   104ns     0.00B    0.0%    0.00B
   get node variables           4   87.0ns    0.0%  21.8ns     0.00B    0.0%    0.00B
 rhs!                       1.15k    119ms   29.0%   104μs   5.14KiB    0.0%    4.59B
   volume integral          1.15k   48.2ms   11.7%  42.1μs     0.00B    0.0%    0.00B
   interface flux           1.15k   30.9ms    7.5%  27.0μs     0.00B    0.0%    0.00B
   source terms             1.15k   21.2ms    5.2%  18.5μs     0.00B    0.0%    0.00B
   surface integral         1.15k   11.5ms    2.8%  10.1μs     0.00B    0.0%    0.00B
   Jacobian                 1.15k   4.40ms    1.1%  3.84μs     0.00B    0.0%    0.00B
   reset ∂u/∂t              1.15k   2.29ms    0.6%  2.00μs     0.00B    0.0%    0.00B
   ~rhs!~                   1.15k    563μs    0.1%   491ns   5.14KiB    0.0%    4.59B
   boundary flux            1.15k   22.1μs    0.0%  19.3ns     0.00B    0.0%    0.00B
 analyze solution               4   88.4ms   21.5%  22.1ms   7.85MiB   42.6%  1.96MiB
 calculate dt                 230   4.59ms    1.1%  19.9μ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 #172

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
@benegee benegee changed the base branch from main to more-data-access March 7, 2024 16:23
@benegee
Copy link
Collaborator Author

benegee commented Mar 7, 2024

Fortran interface is still missing.

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.

1 participant