Using an implicit-explicit (IMEX) Runge-Kutta solver based on Ariadne with Trixi.jl

using Trixi
using Theseus
using CairoMakie

Notes: You must disable both Polyester and LoopVectorization for Enzyme to be able to differentiate Trixi.jl.

LocalPreferences.jl

[Trixi]
loop_vectorization = false
backend = "static"
@assert Trixi._PREFERENCE_THREADING !== :polyester
@assert !Trixi._PREFERENCE_LOOPVECTORIZATION

First call to load callbacks

trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), sol = nothing);

stepsize_callback = StepsizeCallback(cfl = 0.5)

callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback)

trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), sol = nothing, callbacks = callbacks);
###############################################################################
[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.
[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.

run the simulation

sol = solve(
    ode,
    Theseus.ARS222(); # ARS111, ARS222, ARS443
    dt = 0.01, # solve needs some value here but it will be overwritten by the stepsize_callback
    ode_default_options()..., callback = callbacks,
    krylov_algo = :gmres,
);

████████╗██████╗ ██╗██╗  ██╗██╗
╚══██╔══╝██╔══██╗██║╚██╗██╔╝██║
   ██║   ██████╔╝██║ ╚███╔╝ ██║
   ██║   ██╔══██╗██║ ██╔██╗ ██║
   ██║   ██║  ██║██║██╔╝ ██╗██║
   ╚═╝   ╚═╝  ╚═╝╚═╝╚═╝  ╚═╝╚═╝

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ SemidiscretizationHyperbolicParabolic                                                            │
│ ═════════════════════════════════════                                                            │
│ #spatial dimensions: ………………………… 2                                                                │
│ mesh: ………………………………………………………………… TreeMesh{2, Trixi.SerialTree{2, Float64}} with length 341        │
│ hyperbolic equations: ……………………… LinearScalarAdvectionEquation2D                                  │
│ parabolic equations: ………………………… LaplaceDiffusion2D                                               │
│ initial condition: ……………………………… initial_condition_diffusive_convergence_test                     │
│ source terms: …………………………………………… nothing                                                          │
│ source terms parabolic: ………………… nothing                                                          │
│ solver: …………………………………………………………… DG                                                               │
│ parabolic solver: ………………………………… ViscousFormulationBassiRebay1                                    │
│ total #DOFs per field: …………………… 4096                                                             │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ TreeMesh{2, Trixi.SerialTree{2, Float64}}                                                        │
│ ═════════════════════════════════════════                                                        │
│ center: …………………………………………………………… [0.0, 0.0]                                                       │
│ length: …………………………………………………………… 2.0                                                              │
│ periodicity: ……………………………………………… (true, true)                                                     │
│ current #cells: ……………………………………… 341                                                              │
│ #leaf-cells: ……………………………………………… 256                                                              │
│ maximum #cells: ……………………………………… 30000                                                            │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ LinearScalarAdvectionEquation2D                                                                  │
│ ═══════════════════════════════                                                                  │
│ #variables: ………………………………………………… 1                                                                │
│ │ variable 1: …………………………………………… scalar                                                           │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ DG{Float64}                                                                                      │
│ ═══════════                                                                                      │
│ basis: ……………………………………………………………… LobattoLegendreBasis{Float64}(polydeg=3)                         │
│ mortar: …………………………………………………………… LobattoLegendreMortarL2{Float64}(polydeg=3)                      │
│ surface integral: ………………………………… SurfaceIntegralWeakForm                                          │
│ │ surface flux: ……………………………………… FluxLaxFriedrichs(max_abs_speed)                                 │
│ volume integral: …………………………………… VolumeIntegralWeakForm                                           │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ AnalysisCallback                                                                                 │
│ ════════════════                                                                                 │
│ interval: ……………………………………………………… 100                                                              │
│ analyzer: ……………………………………………………… LobattoLegendreAnalyzer{Float64}(polydeg=6)                      │
│ │ error 1: …………………………………………………… l2_error                                                         │
│ │ error 2: …………………………………………………… linf_error                                                       │
│ │ integral 1: …………………………………………… entropy_timederivative                                           │
│ save analysis to file: …………………… no                                                               │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ AliveCallback                                                                                    │
│ ═════════════                                                                                    │
│ interval: ……………………………………………………… 10                                                               │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ StepsizeCallback                                                                                 │
│ ════════════════                                                                                 │
│ CFL Advective: ………………………………………… Returns{Float64}(0.5)                                            │
│ CFL Diffusive: ………………………………………… Returns{Float64}(0.0)                                            │
│ Interval: ……………………………………………………… 1                                                                │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Time integration                                                                                 │
│ ════════════════                                                                                 │
│ Start time: ………………………………………………… 0.0                                                              │
│ Final time: ………………………………………………… 1.5                                                              │
│ time integrator: …………………………………… ARS222                                                           │
│ adaptive: ……………………………………………………… false                                                            │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Environment information                                                                          │
│ ═══════════════════════                                                                          │
│ #threads: ……………………………………………………… 1                                                                │
│ threading backend: ……………………………… static                                                           │
│ LoopVectorization: ……………………………… disabled                                                         │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'LinearScalarAdvectionEquation2D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                  0                run time:       3.49508457e-01 s
 Δt:             1.00000000e-02                └── GC time:    0.00000000e+00 s (0.000%)
 sim. time:      0.00000000e+00 (0.000%)       time/DOF/rhs!:         NaN s
                                               PID:                   Inf s
 #DOFs per field:          4096                alloc'd memory:       1163.905 MiB
 #elements:                 256

 Variable:       scalar
 L2 error:       3.94120825e-06
 Linf error:     1.23670425e-05
 ∑∂S/∂U ⋅ Uₜ :  -1.23370054e-01
────────────────────────────────────────────────────────────────────────────────────────────────────

┌ Warning: TODO forward zero-set of memorycopy used memset rather than runtime type
│ Caused by:
│ Stacktrace:
│   [1] copy
│     @ ./array.jl:350
│   [2] unaliascopy
│     @ ./abstractarray.jl:1516
│   [3] unalias
│     @ ./abstractarray.jl:1500
│   [4] broadcast_unalias
│     @ ./broadcast.jl:946
│   [5] preprocess
│     @ ./broadcast.jl:953
│   [6] preprocess_args
│     @ ./broadcast.jl:956
│   [7] preprocess_args
│     @ ./broadcast.jl:955
│   [8] preprocess
│     @ ./broadcast.jl:952
│   [9] preprocess_args
│     @ ./broadcast.jl:956
│  [10] preprocess_args
│     @ ./broadcast.jl:955
│  [11] preprocess
│     @ ./broadcast.jl:952
│  [12] preprocess_args
│     @ ./broadcast.jl:955
│  [13] preprocess
│     @ ./broadcast.jl:952
│  [14] override_bc_copyto!
│     @ ~/.julia/packages/Enzyme/C5rSn/src/compiler/interpreter.jl:818
│  [15] copyto!
│     @ ./broadcast.jl:925
│  [16] materialize!
│     @ ./broadcast.jl:883
│  [17] materialize!
│     @ ./broadcast.jl:880
│  [18] RKIMEX
│     @ ~/work/Ariadne.jl/Ariadne.jl/libs/Theseus/src/imex/imex.jl:33
└ @ Enzyme.Compiler ~/.julia/packages/Enzyme/C5rSn/src/rules/llvmrules.jl:812
┌ Warning: TODO forward zero-set of memorycopy used memset rather than runtime type
│ Caused by:
│ Stacktrace:
│   [1] copy
│     @ ./array.jl:350
│   [2] unaliascopy
│     @ ./abstractarray.jl:1516
│   [3] unalias
│     @ ./abstractarray.jl:1500
│   [4] broadcast_unalias
│     @ ./broadcast.jl:946
│   [5] preprocess
│     @ ./broadcast.jl:953
│   [6] preprocess_args
│     @ ./broadcast.jl:956
│   [7] preprocess_args
│     @ ./broadcast.jl:955
│   [8] preprocess
│     @ ./broadcast.jl:952
│   [9] preprocess_args
│     @ ./broadcast.jl:956
│  [10] preprocess_args
│     @ ./broadcast.jl:955
│  [11] preprocess
│     @ ./broadcast.jl:952
│  [12] override_bc_copyto!
│     @ ~/.julia/packages/Enzyme/C5rSn/src/compiler/interpreter.jl:818
│  [13] copyto!
│     @ ./broadcast.jl:925
│  [14] materialize!
│     @ ./broadcast.jl:883
│  [15] materialize!
│     @ ./broadcast.jl:880
│  [16] RKIMEX
│     @ ~/work/Ariadne.jl/Ariadne.jl/libs/Theseus/src/imex/imex.jl:33
└ @ Enzyme.Compiler ~/.julia/packages/Enzyme/C5rSn/src/rules/llvmrules.jl:812
#timesteps:     10 │ Δt: 6.2500e-03 │ sim. time: 6.2500e-02 (4.167%)   │ run time: 5.7836e+01 s
#timesteps:     20 │ Δt: 6.2500e-03 │ sim. time: 1.2500e-01 (8.333%)   │ run time: 5.8007e+01 s
#timesteps:     30 │ Δt: 6.2500e-03 │ sim. time: 1.8750e-01 (12.500%)  │ run time: 5.8069e+01 s
#timesteps:     40 │ Δt: 6.2500e-03 │ sim. time: 2.5000e-01 (16.667%)  │ run time: 5.8103e+01 s
#timesteps:     50 │ Δt: 6.2500e-03 │ sim. time: 3.1250e-01 (20.833%)  │ run time: 5.8141e+01 s
#timesteps:     60 │ Δt: 6.2500e-03 │ sim. time: 3.7500e-01 (25.000%)  │ run time: 5.8174e+01 s
#timesteps:     70 │ Δt: 6.2500e-03 │ sim. time: 4.3750e-01 (29.167%)  │ run time: 5.8214e+01 s
#timesteps:     80 │ Δt: 6.2500e-03 │ sim. time: 5.0000e-01 (33.333%)  │ run time: 5.8247e+01 s
#timesteps:     90 │ Δt: 6.2500e-03 │ sim. time: 5.6250e-01 (37.500%)  │ run time: 5.8285e+01 s

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'LinearScalarAdvectionEquation2D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                100                run time:       5.86689206e+01 s
 Δt:             6.25000000e-03                └── GC time:    8.72812911e-01 s (1.488%)
 sim. time:      6.25000000e-01 (41.667%)      time/DOF/rhs!:  7.37983541e-08 s
                                               PID:            4.74595289e-05 s
 #DOFs per field:          4096                alloc'd memory:       1172.882 MiB
 #elements:                 256

 Variable:       scalar
 L2 error:       3.81726799e-04
 Linf error:     5.50778812e-04
 ∑∂S/∂U ⋅ Uₜ :  -3.59099416e-02
────────────────────────────────────────────────────────────────────────────────────────────────────

#timesteps:    110 │ Δt: 6.2500e-03 │ sim. time: 6.8750e-01 (45.833%)  │ run time: 5.8357e+01 s
#timesteps:    120 │ Δt: 6.2500e-03 │ sim. time: 7.5000e-01 (50.000%)  │ run time: 5.8391e+01 s
#timesteps:    130 │ Δt: 6.2500e-03 │ sim. time: 8.1250e-01 (54.167%)  │ run time: 5.8424e+01 s
#timesteps:    140 │ Δt: 6.2500e-03 │ sim. time: 8.7500e-01 (58.333%)  │ run time: 5.8462e+01 s
#timesteps:    150 │ Δt: 6.2500e-03 │ sim. time: 9.3750e-01 (62.500%)  │ run time: 5.8496e+01 s
#timesteps:    160 │ Δt: 6.2500e-03 │ sim. time: 1.0000e+00 (66.667%)  │ run time: 5.8534e+01 s
#timesteps:    170 │ Δt: 6.2500e-03 │ sim. time: 1.0625e+00 (70.833%)  │ run time: 5.8567e+01 s
#timesteps:    180 │ Δt: 6.2500e-03 │ sim. time: 1.1250e+00 (75.000%)  │ run time: 5.8606e+01 s
#timesteps:    190 │ Δt: 6.2500e-03 │ sim. time: 1.1875e+00 (79.167%)  │ run time: 5.8639e+01 s

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'LinearScalarAdvectionEquation2D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                200                run time:       5.90278198e+01 s
 Δt:             6.25000000e-03                └── GC time:    8.97627060e-01 s (1.521%)
 sim. time:      1.25000000e+00 (83.333%)      time/DOF/rhs!:  7.38230588e-08 s
                                               PID:            2.91221899e-07 s
 #DOFs per field:          4096                alloc'd memory:       1142.403 MiB
 #elements:                 256

 Variable:       scalar
 L2 error:       4.11963020e-04
 Linf error:     5.84938377e-04
 ∑∂S/∂U ⋅ Uₜ :  -1.04524859e-02
────────────────────────────────────────────────────────────────────────────────────────────────────

#timesteps:    210 │ Δt: 6.2500e-03 │ sim. time: 1.3125e+00 (87.500%)  │ run time: 5.8711e+01 s
#timesteps:    220 │ Δt: 6.2500e-03 │ sim. time: 1.3750e+00 (91.667%)  │ run time: 5.8750e+01 s
#timesteps:    230 │ Δt: 6.2500e-03 │ sim. time: 1.4375e+00 (95.833%)  │ run time: 5.8783e+01 s

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'LinearScalarAdvectionEquation2D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                240                run time:       5.91718631e+01 s
 Δt:             6.25000000e-03                └── GC time:    9.07402166e-01 s (1.534%)
 sim. time:      1.50000000e+00 (100.000%)     time/DOF/rhs!:  7.37148779e-08 s
                                               PID:            2.90892360e-07 s
 #DOFs per field:          4096                alloc'd memory:       1131.554 MiB
 #elements:                 256

 Variable:       scalar
 L2 error:       3.86247716e-04
 Linf error:     5.47814220e-04
 ∑∂S/∂U ⋅ Uₜ :  -6.38001271e-03
────────────────────────────────────────────────────────────────────────────────────────────────────

────────────────────────────────────────────────────────────────────────────────────────────────────
Trixi.jl simulation finished.  Final time: 1.5  Time steps: 240 (accepted), 240 (total)
────────────────────────────────────────────────────────────────────────────────────────────────────

───────────────────────────────────────────────────────────────────────────────────────
              Trixi.jl                        Time                    Allocations
                                     ───────────────────────   ────────────────────────
          Tot / % measured:               59.2s /   1.1%           4.86GiB /   0.2%

Section                      ncalls     time    %tot     avg     alloc    %tot      avg
───────────────────────────────────────────────────────────────────────────────────────
parabolic rhs!                2.65k    556ms   88.7%   210μs   9.00KiB    0.1%    3.48B
  calculate gradient          2.65k    247ms   39.5%  93.4μs   3.33KiB    0.0%    1.29B
    volume integral           2.65k    154ms   24.6%  58.2μs     0.00B    0.0%    0.00B
    Jacobian                  2.65k   28.6ms    4.6%  10.8μs     0.00B    0.0%    0.00B
    surface integral          2.65k   19.6ms    3.1%  7.42μs     0.00B    0.0%    0.00B
    prolong2interfaces        2.65k   18.4ms    2.9%  6.95μs     0.00B    0.0%    0.00B
    interface flux            2.65k   17.9ms    2.8%  6.74μs     0.00B    0.0%    0.00B
    reset gradients           2.65k   5.11ms    0.8%  1.93μs     0.00B    0.0%    0.00B
    ~calculate gradient~      2.65k   2.95ms    0.5%  1.11μs   3.33KiB    0.0%    1.29B
    prolong2mortars           2.65k    328μs    0.1%   124ns     0.00B    0.0%    0.00B
    prolong2boundaries        2.65k    272μs    0.0%   103ns     0.00B    0.0%    0.00B
    mortar flux               2.65k    228μs    0.0%  86.3ns     0.00B    0.0%    0.00B
    boundary flux             2.65k   83.2μs    0.0%  31.4ns     0.00B    0.0%    0.00B
  volume integral             2.65k    164ms   26.2%  61.9μs     0.00B    0.0%    0.00B
  calculate viscous fluxes    2.65k   50.8ms    8.1%  19.2μs     0.00B    0.0%    0.00B
  surface integral            2.65k   19.9ms    3.2%  7.51μs     0.00B    0.0%    0.00B
  interface flux              2.65k   17.5ms    2.8%  6.60μs     0.00B    0.0%    0.00B
  transform variables         2.65k   17.2ms    2.7%  6.49μs     0.00B    0.0%    0.00B
  prolong2interfaces          2.65k   16.6ms    2.6%  6.27μs     0.00B    0.0%    0.00B
  Jacobian                    2.65k   14.6ms    2.3%  5.50μs     0.00B    0.0%    0.00B
  ~parabolic rhs!~            2.65k   4.38ms    0.7%  1.65μs   5.67KiB    0.1%    2.19B
  reset ∂u/∂t                 2.65k   2.62ms    0.4%   988ns     0.00B    0.0%    0.00B
  prolong2mortars             2.65k    274μs    0.0%   103ns     0.00B    0.0%    0.00B
  mortar flux                 2.65k    259μs    0.0%  97.9ns     0.00B    0.0%    0.00B
  prolong2boundaries          2.65k    245μs    0.0%  92.4ns     0.00B    0.0%    0.00B
  source terms parabolic      2.65k   96.9μs    0.0%  36.6ns     0.00B    0.0%    0.00B
  boundary flux               2.65k   82.8μs    0.0%  31.3ns     0.00B    0.0%    0.00B
rhs!                            720   66.2ms   10.6%  92.0μs   4.78KiB    0.0%    6.80B
  volume integral               720   42.5ms    6.8%  59.0μs     0.00B    0.0%    0.00B
  surface integral              720   6.21ms    1.0%  8.62μs     0.00B    0.0%    0.00B
  interface flux                720   5.99ms    1.0%  8.32μs     0.00B    0.0%    0.00B
  prolong2interfaces            720   5.24ms    0.8%  7.27μs     0.00B    0.0%    0.00B
  Jacobian                      720   4.62ms    0.7%  6.41μs     0.00B    0.0%    0.00B
  ~rhs!~                        720    882μs    0.1%  1.23μs   4.78KiB    0.0%    6.80B
  reset ∂u/∂t                   720    553μs    0.1%   769ns     0.00B    0.0%    0.00B
  prolong2boundaries            720   81.5μs    0.0%   113ns     0.00B    0.0%    0.00B
  prolong2mortars               720   68.5μs    0.0%  95.2ns     0.00B    0.0%    0.00B
  mortar flux                   720   51.9μs    0.0%  72.1ns     0.00B    0.0%    0.00B
  boundary flux                 720   22.9μs    0.0%  31.7ns     0.00B    0.0%    0.00B
  source terms                  720   22.3μs    0.0%  30.9ns     0.00B    0.0%    0.00B
analyze solution                  4   4.29ms    0.7%  1.07ms   9.65MiB   99.5%  2.41MiB
calculate dt                    241    173μs    0.0%   718ns   33.9KiB    0.3%     144B
───────────────────────────────────────────────────────────────────────────────────────

This page was generated using Literate.jl.