# \[ANN\] Trixi.jl v0.4: New features and performance improvements for hyperbolic PDEs

**URL:** <https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995>\
**Category:** Package Announcements\
**Tags:** parallel, pde, numerics, physics, math\
**Created:** [October 18, 2021, 6:11pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995 "2021-10-18T18:11:02Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [October 18, 2021, 6:11pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/1 "2021-10-18T18:11:02Z")

</div>

We are pleased to announce the release of v0.4 of [Trixi.jl](https://github.com/trixi-framework/Trixi.jl), our Julia package providing adaptive high-order numerical simulations of hyperbolic PDEs. Compared to the initial [release of v0.3](https://discourse.julialang.org/t/ann-trixi-jl-v0-3-sciml-integration-and-a-new-modular-approach-for-easy-extension/50419), we have introduced a ton of new features. In particular, we added new mesh types enabling simulations on unstructured, curvilinear, non-conforming and adaptive meshes in multiple space dimensions. These new mesh types support all of our solver features, including shock capturing techniques for high-order methods. Additionally, we have introduced new physical models including multicomponent compressible Euler and magnetohydrodynamics equations. Moreover, Trixi.jl composes well with forward mode automatic differentiation and similar approaches. We presented most of these features already in our [presentation of Trixi.jl at JuliaCon](https://youtu.be/hoViWRAhCBE). Furthermore, we have some interactive visualizations with [Makie.jl](https://makie.juliaplots.org/) - kudos to @sdanisch, @jules, and all other developers of Makie!

As a teaser, here is the simulation of the shallow water equations with a bottom topography on a circular domain with slip-wall boundaries using a discontinuous Galerkin method on a high-order curved unstructured quadrilateral mesh.

[![](https://global.discourse-cdn.com/julialang/original/3X/a/c/ac3f1cbb4b2a7e9a39187707eecb085913e5b302.jpeg "Shallow water in a circular pond") ](https://www.youtube.com/watch?v=RAXU5BURyKQ)

The next video shows an MHD rotor, a rapidly spinning dense cylinder embedded in a magnetized, homogeneous medium at rest. This simulation uses a discontinuous Galerkin method on a high-order, curvilinear mesh with adaptive refinement and shock capturing.

[![](https://global.discourse-cdn.com/julialang/original/3X/8/d/8dc1284bdb4ba54758a99216467307d4aec80396.jpeg "Ideal MHD rotor on unstructured AMR mesh") ](https://www.youtube.com/watch?v=Iei7e9oQ0hs)

Many of these new features come with additional contributions to the Julia ecosystem. For example, we created [P4est.jl](https://github.com/trixi-framework/P4est.jl) as thin wrapper around the C library `p4est` for adaptive meshes and [HOHQMesh.jl](https://github.com/trixi-framework/HOHQMesh.jl) as Julia wrapper of a high-order mesh generation library. You can find more information about these and further activities related to Trixi.jl on [our summary website](https://trixi-framework.github.io/).

On top of these new features, we worked on the internals of Trixi.jl. In particular, we improved the performance quite a bit and were able to beat another open source code implementing the same numerical algorithms in Fortran by up to 2x. The details are available in our [preprint](http://arxiv.org/abs/2108.06476).

Since this is a breaking release, some user-facing changes are of course necessary. However, they should not affect most codes and are summarized in our [NEWS.md](https://github.com/trixi-framework/Trixi.jl/blob/main/NEWS.md).

Kudos to all contributors for exciting developments - and thanks to all users encouraging us!

Here is our current list of main features (changes vs. v0.3.0 highlighted):

- 1D, 2D, and 3D simulations on [line/quad/hex/ **simplex** meshes](https://trixi-framework.github.io/Trixi.jl/stable/overview/#Semidiscretizations)
  - Cartesian **and curvilinear** meshes
  - Conforming and non-conforming meshes
  - Structured **and unstructured** meshes
  - Hierarchical quadtree/octree grid with adaptive mesh refinement
  - **Forests of quadtrees/octrees with [p4est](https://github.com/cburstedde/p4est) via [P4est.jl](https://github.com/trixi-framework/P4est.jl)**

- High-order accuracy in space in time
- Discontinuous Galerkin methods
  - Kinetic energy-preserving and entropy-stable methods based on flux differencing
  - Entropy-stable shock capturing
  - Positivity-preserving limiting

- Compatible with the [SciML ecosystem for ordinary differential equations](https://diffeq.sciml.ai/latest/)
  - [Explicit low-storage Runge-Kutta time integration](https://diffeq.sciml.ai/latest/solvers/ode_solve/#Low-Storage-Methods)
  - [Strong stability preserving methods](https://diffeq.sciml.ai/latest/solvers/ode_solve/#Explicit-Strong-Stability-Preserving-Runge-Kutta-Methods-for-Hyperbolic-PDEs-(Conservation-Laws))
  - CFL-based and error-based time step control

- **Native support for differentiable programming**
  - **Forward mode automatic differentiation via [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl)**

- Periodic and weakly-enforced boundary conditions
- Multiple governing equations:
  - Compressible Euler equations
  - Magnetohydrodynamics (MHD) equations
  - **Multi-component compressible Euler and MHD equations**
  - **Acoustic perturbation equations**
  - Hyperbolic diffusion equations for elliptic problems
  - **Lattice-Boltzmann equations (D2Q9 and D3Q27 schemes)**
  - **Shallow water equations**
  - Several scalar conservation laws (e.g., linear advection, Burgers’ equation)

- Multi-physics simulations
  - [Self-gravitating gas dynamics](https://github.com/trixi-framework/paper-self-gravitating-gas-dynamics)

- Shared-memory parallelization via multithreading
- Visualization and postprocessing of the results
  - In-situ and a posteriori visualization with [Plots.jl](https://github.com/JuliaPlots/Plots.jl)
  - **Interactive visualization with [Makie.jl](https://makie.juliaplots.org/)**
  - Postprocessing with ParaView/VisIt via [Trixi2Vtk](https://github.com/trixi-framework/Trixi2Vtk.jl)

Xref: Previous announcements of [v0.3](https://discourse.julialang.org/t/ann-trixi-jl-v0-3-sciml-integration-and-a-new-modular-approach-for-easy-extension/50419) and [v0.2](https://discourse.julialang.org/t/ann-trixi-jl-a-tree-based-numerical-simulation-framework-for-hyperbolic-pdes/45886)

---

<div class="post-metadata">

**Author:** ![jcook](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcook/32/18211_2.png) [@jcook](https://discourse.julialang.org/u/jcook)\
**Post date:** [October 18, 2021, 6:29pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/2 "2021-10-18T18:29:47Z")

</div>

Trixi.jl is amazing, @ranocha! Out of interest, are there plans to implement distributed memory parallelism?

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [October 18, 2021, 7:12pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/3 "2021-10-18T19:12:03Z")

</div>

Thanks a lot! Yes, we plan to implement distributed memory parallelism via MPI. We have already some working prototypes on one mesh type with adaptive refinement in 2D. We just need more developer time to unify internal interfaces and resolve technical issues such as supporting MPI with binary dependencies created by BinaryBuilder. These are some non-trivial tasks, so it will take us some time. Nevertheless, I am sure that we will have MPI support in one of the following major new releases of Trixi.jl.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 19, 2021, 11:58am UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/4 "2021-10-19T11:58:02Z")

</div>

> [@ranocha](#):
>
> **Native support for differentiable programming**
> 
> - **Forward mode automatic differentiation via [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl)**

Do the adjoints not work? Since you’re using the DiffEq time stepping, I would think the adjoints would work? If you’re mutating internally, the EnzymeVJP might be the trick here.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 19, 2021, 11:58am UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/5 "2021-10-19T11:58:50Z")

</div>

> [@ranocha](#):
>
> Thanks a lot! Yes, we plan to implement distributed memory parallelism via MPI. We have already some working prototypes on one mesh type with adaptive refinement in 2D. We just need more developer time to unify internal interfaces and resolve technical issues such as supporting MPI with binary dependencies created by BinaryBuilder. These are some non-trivial tasks, so it will take us some time. Nevertheless, I am sure that we will have MPI support in one of the following major new releases of Trixi.jl.

It might be interesting to try reviving MPIArrays.jl @barche ?

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [October 19, 2021, 12:07pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/6 "2021-10-19T12:07:39Z")

</div>

We are using mutation quite a lot internally (for efficiency). Trying Enzyme.jl is on our (ever-growing) TODO list, see [https://github.com/trixi-framework/Trixi.jl/issues/462](https://github.com/trixi-framework/Trixi.jl/issues/462).

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [October 19, 2021, 12:17pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/7 "2021-10-19T12:17:31Z")

</div>

Yeah, that’s definitely something we [are interested in](https://github.com/trixi-framework/Trixi.jl/issues/329). Right now, we don’t know whether it’s (easily) possible to use some general MPI array type that satisfies the requirement of different packages. As far as I know, there are different MPI array types out there, e.g. from [CliMA](https://github.com/CliMA/ClimateMachine.jl/blob/master/src/Arrays/MPIStateArrays.jl), [PencilArrays.jl](https://github.com/jipolanco/PencilArrays.jl), [MPIArrays.jl](https://github.com/barche/MPIArrays.jl), and probably many more.  
For us, the requirements that come to my mind right now are

- broadcasting, mapreduce etc. to work with explicit time integrators and error-based step size control from OrdinaryDiffEq.jl
- accessing `parent` to implement parallel capabilities on top of serial code
- ability to control which data is available on which rank and load balancing
- no communication unless we explicitly ask for it, allowing the usual MPI-type communication patters (for efficiency)

---

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [October 19, 2021, 1:07pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/8 "2021-10-19T13:07:17Z")

</div>

> [@ChrisRackauckas](#):
>
> It might be interesting to try reviving MPIArrays.jl @barche ?

Possibly, though I admit I neglected this badly. It might be worth checking if something better exists in the mean time.

---

<div class="post-metadata">

**Author:** ![GregCoyle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregcoyle/32/29663_2.png) [@GregCoyle](https://discourse.julialang.org/u/GregCoyle)\
**Post date:** [November 5, 2021, 3:45pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/10 "2021-11-05T15:45:30Z")

</div>

I’ve been looking around the discussion boards for something similar for parabolic PDEs. Perhaps I’m missing something obvious, but is there any support for doing similar adaptive resizing of the grid/mesh for a parabolic PDE, e.g., the advection-dispersion-reaction (ADR) equation? Or is there another type of preferred method for such problems? I am interested in applying adaptive resizing (or similar) techniques to an ADR model in which (for example) a pollutant plume is traveling “downstream” along the grid and so the stability of each cell size may change with time as the plume moves, spreads out and decays. It seems to me that something like Trixi’s methods using callbacks on the ODE solver applied to the semi-discretization could considerably accelerate the solution by adapting the cell sizes based on where the plume currently resides. Thanks in advance for any thoughts offered!

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [November 5, 2021, 6:06pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/11 "2021-11-05T18:06:35Z")

</div>

I agree with you that this sort of adaptivity will also be useful for parabolic problems, advection-diffusion equations etc. However, these kinds of problems are not in the focus of research of our Trixi.jl developers, so we don’t have ready-to-use discretizations for them. Advection-dominated problems with diffusion (such as the compressible Navier-Stokes equations for computational fluid dynamics) are on our radar but not at the top of our priority list.

---

<div class="post-metadata">

**Author:** ![GregCoyle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregcoyle/32/29663_2.png) [@GregCoyle](https://discourse.julialang.org/u/GregCoyle)\
**Post date:** [November 5, 2021, 6:36pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/12 "2021-11-05T18:36:23Z")

</div>

Thanks for that feedback. If it’s simply a matter of interest and labor, as opposed to a better available solution, I’d be interested in contributing in this area. It would certainly benefit my work. If @ChrisRackauckas isn’t already planning/working on something similar in SciML (?), I’d think Trixi.jl would be the right place to include such features.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [November 5, 2021, 7:43pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/13 "2021-11-05T19:43:15Z")

</div>

[https://github.com/trixi-framework/Trixi.jl/issues/891](https://github.com/trixi-framework/Trixi.jl/issues/891)

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [November 6, 2021, 9:41am UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/14 "2021-11-06T09:41:26Z")

</div>

Yes, it’s definitely mostly a matter of labor and time - and an appropriate design if it should go into Trixi.jl. We have some prototype in a PR but we were not really satisfied with it back then…

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 7, 2021, 12:56pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/15 "2021-11-07T12:56:43Z")

</div>

> [@GregCoyle](#):
>
> @ChrisRackauckas isn’t already planning/working on something similar in SciML (?), I’d think Trixi.jl would be the right place to include such features.

To keep the scope as not infinitely large, I am trying to say that non-finite difference discretizations are not in the scope of SciML. Trixi, Gridap, etc. are great tools and so they should be used in conjunction with SciML bits. That said, ModelingToolkit is providing a generalized symbolic PDE interface, which then discretizers are being built on, and a few years from now we’ll probably look at that and start expanding the areas where discretizers are missing.

---

<div class="post-metadata">

**Author:** ![GregCoyle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregcoyle/32/29663_2.png) [@GregCoyle](https://discourse.julialang.org/u/GregCoyle)\
**Post date:** [November 8, 2021, 9:51pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/16 "2021-11-08T21:51:00Z")

</div>

Thanks, that’s a good rule of thumb to go by, and I appreciate the outlook on where you see things developing.

---

<div class="post-metadata">

**Author:** ![GregCoyle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregcoyle/32/29663_2.png) [@GregCoyle](https://discourse.julialang.org/u/GregCoyle)\
**Post date:** [November 8, 2021, 9:53pm UTC](https://discourse.julialang.org/t/ann-trixi-jl-v0-4-new-features-and-performance-improvements-for-hyperbolic-pdes/69995/17 "2021-11-08T21:53:01Z")

</div>

Thanks again - I’ll look through the PRs when I get the time myself and see if I can be of any help.
