-
Notifications
You must be signed in to change notification settings - Fork 2
Description
For simulations where source terms (aka right hand side, forcing, ...) change over time, we need a way for an external application to provide the respective values.
Trixi.jl expects a method source_terms(u, x, t, ...), which is called in every time step for every DG node, i.e.
- time
t - coordinates of the DG node
x - current values of conservative variables
u(x, t)
are given and the values of the source term S(u(x,t), x, t) need to be returned.
The method source_terms(u, x, t, ...) can simply be defined in a libelixir.
At his point there is a lot of flexibility. One could think about caching, interpolation onto DG nodes, ...
But in the end we need a mechanism therein that allows to retrieve whatever values there are from the calling external application.
We implemented two prototypes for demonstration:
-
Create a global data storage which can be written to via API functions: RFC: source terms via global vector storage #173
- The external application allocates memory and libtrixi stores pointers to it
- The external application computes source terms (whenever it wants) and stores the results in this memory
- libtrixi reads values from this memory every time
source_termsis called - To be able to compute the source term, the external application possibly needs to separately get
t,x,u - A mechanism is required to map coordinates
xto an index, needed to access the memory at the correct position
-
Let the user call her own external functions from a libelixir: RFC: Source terms via callback #172
- The user has to provide a function similar to
source_termsand make it available via a shared library - The function is then called each time
source_termsis called.
- The user has to provide a function similar to