Skip to content

How to deal with source terms? #174

@benegee

Description

@benegee

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:

  1. 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_terms is 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 x to an index, needed to access the memory at the correct position
  2. 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_terms and make it available via a shared library
    • The function is then called each time source_terms is called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions