precice / aste

Artificial Solver Testing Environment
GNU General Public License v3.0
10 stars 11 forks source link

ASTE with time dependent functions #176

Open fsimonis opened 1 year ago

fsimonis commented 1 year ago

ASTE is a great tool to analyze the error of a single map operation. To simulate multiple time windows, we need to generate a complete mesh for every time step. This is not only very space inefficient, but also results in a lot of unnecessary IO.

It would be a great simple tool for testing transient mappings for functions that depend on t, as well as testing mappings with a time independent function to study their runtime stability over time.

Currently we have the following data flow:

flowchart TB
    IM[Mesh] -->|"eval f(x,y,z)"| IMD
    IMD[Mesh+Data] --> |partition| IMDP
    OM[Mesh] --> |partition| OMP
    OMP[Partitioned Mesh] --> |B Mesh| ASTE
    IMDP[Partitioned Mesh+Data] --> |A Mesh| ASTE
    ASTE(ASTE)--> |map Data form A to B| MMP
    MMP[Paritioned Mesh+Data] --> MM
    MM[Mesh+Data]

We could pass the function directly to ASTE (preciceMap) and evaluate it on the input mesh using VTK. Adding the time t as further input allows us to evaluate this for each time step/window without the need to read a completely new mesh. Time window size and max time windows are configurable in the configuration file.

flowchart TB
    IM[Mesh] --> |partition| IMDP
    OM[Mesh] --> |partition| OMP
    OMP[Partitioned Mesh] --> BIM
    IMDP[Partitioned Mesh] -->  AIM
    F("f(x,y,z,t)") --> AF

    subgraph ASTEA [Participant A]
        direction TB
        AF(Function) --> |"apply"| AIMD
        AIM[A Mesh] -->  AIMD
        AIMD[A Mesh + Data] --> |"writeData()"| AP
        AP(preCICE)
    end

    subgraph ASTEB [Participant B]
        direction TB
        BP(preCICE) --> |"readData()"| BIMD
        BIM[B Mesh] --> BIMD[B Mesh + Data]
    end
    AP -.-> BP

    BIMD --> MMP

    MMP[Paritioned Mesh+Data] --> MM
    MM[Mesh+Data] --> MME[Mesh+Error]
    F --> |calc error| MME

Taking this one step further, using the function as input for both participants allows us to calculate the error directly in ASTE.

flowchart TB
    IM[Mesh] --> |partition| IMDP
    OM[Mesh] --> |partition| OMP
    OMP[Partitioned Mesh] --> BIM
    IMDP[Partitioned Mesh] -->  AIM
    F("f(x,y,z,t)") --> AF
    F --> BF

    MMP[Paritioned Mesh+Error] --> MM
    MM[Mesh+Error]

    subgraph ASTEA [Participant A]
        direction TB
        AF(Function) --> |"apply"| AIMD
        AIM[A Mesh] -->  AIMD
        AIMD[A Mesh + Data] --> |"writeData()"| AP
        AP(preCICE)
    end

    subgraph ASTEB [Participant B]
        direction TB
        BF(Function) --> |"|f(x,y,z,u) - d(x,y,z)|"| BE
        BP(preCICE) --> |"readData()"| BIMD
        BIM[B Mesh] --> BIMD["B Mesh + Data d"]
        BIMD --> BE
        BE[B Mesh + Error]
    end
    BE --> MMP
    AP -.-> BP
BenjaminRodenberg commented 3 months ago

I discussed this topic with @davidscn to some degree because this overlaps with the fake.py script I contributed via https://github.com/precice/tutorials/pull/472. I need a tool that allows me to define a general (time dependent) function; potentially with subcycling. I think having these fake solvers as parts of the tutorials is a quite nice feature. ASTE currently does not fulfill this requirement as far as I know.

With the fake.py script I don't have to provide complicated or precomputed data to define the function (replay mode?) or csv files to define the mesh. Instead, I have a purely symbolic representation in Python for

The main drawback of fake.py is that there literally exists no clear interface. It's a plain python script. I could imagine something along the following lines:

python3 fake.py ../precice-config.xml --participant=Fluid --write={"Force":"(y * sin(t),0)"} --mesh={"Fluid-Mesh": ...tricky...}

If I could do the same with ASTE (assuming installation is as simple as running a plain python script), I would be glad to replace the fake.py script with some ASTE-based workflow.

uekerman commented 3 months ago

I think there is no need to replace the one with the other. We should simply be aware that both exist and how they differ. And carefully think before investing more time in the one or the other.