[petsc-users] Fw: DG methods in PETSc
Mark Adams
mfadams at lbl.gov
Thu Feb 19 11:15:58 CST 2026
Just to avoid confusion with a convoluted thread, here is my response
reposed:
This was a work in progress, but it does run: ./ex9 -dm_plex_box_faces 8,8
-dm_plex_dim 2 -dm_plex_simplex 0 -order 1 -ts_max_steps 10 -ts_monitor
-velocity 1.0,0.5
I see that the Riemann solver is set:
PetscCall(PetscDSSetRiemannSolver(ds, 0, RiemannSolver_Advection));
I would not recommend using DG because there are no tests for it.
There are tests for PetscDSSetRiemannSolver that you could clone and
replace the FE/FV construction in those with DG:
src/ts/tutorials/ex11.c: PetscCall(PetscDSSetRiemannSolver(prob, 0,
user->model->physics->riemann));
src/ts/tutorials/ex18.c: if (user->velocityDist == VEL_ZERO)
PetscCall(PetscDSSetRiemannSolver(prob, 1, riemann_advection));
src/ts/tutorials/ex18.c: else PetscCall(PetscDSSetRiemannSolver(prob, 1,
riemann_coupled_advection));
If you get this far, you might want to look at internal examples (not
tests) and clone these DG constructors:
src/dm/dt/fe/interface/fe.c: PetscFECreateBrokenElement - Create a
discontinuous version of the input `PetscFE`
src/dm/dt/fe/interface/fe.c:PetscErrorCode
PetscFECreateBrokenElement(PetscFE cgfe, PetscFE *dgfe)
src/dm/impls/plex/plexcreate.c:
PetscCall(PetscFECreateBrokenElement(fe, &dgfe));
src/dm/interface/dmcoordinates.c:
PetscCall(PetscFECreateBrokenElement(feLinear, &dgfe));
Sorry we do not have DG fully deployed yet.
Good luck,
Mark
On Thu, Feb 19, 2026 at 12:14 PM Matteo Leone via petsc-users <
petsc-users at mcs.anl.gov> wrote:
>
>
> Inviato da Outlook per Android
> <https://urldefense.us/v3/__https://aka.ms/AAb9ysg__;!!G_uCfscf7eWS!esCSra9pt1Q2VQtIwFRk5ds5BQ6-sbeQ66hUETSln-bCt8DbHI1HPvjOPOT6hyKlCgM8Xa4rlvZ6s9Gz4-MYSg9RvFGxWhhnjWc$>
> ------------------------------
> *From:* Matteo Leone <matteo4.leone at mail.polimi.it>
> *Sent:* Thursday, February 19, 2026 3:36:44 PM
> *To:* Mark Adams <mfadams at lbl.gov>
> *Subject:* R: [petsc-users] DG methods in PETSc
>
> Hello, I now have tested quite a bit the code, and I have some doubts.
> Note I am quite new to PETSc.
>
> I have modified a bit your code to test it and I tried to print from the
> functions to check if they were actually called with negative results.
> The Riemann solver is never called and also the solution is just static in
> time.
> I share the code. It's a bit modified and no more c but c++ (I do not know
> to write the csv file fom c, in case is a dealbreaker I'll try to give a
> look on how to do it).
> (For reference I use PETSc 3.24.4 by means of nix, the nix flake is in the
> shared docs if you are used to it lmk).
>
> There is also a small .py to handle the visualization (It was made by
> Claude code, but it just plots the results)
> Hopefully we can go deep into this PETSc DG stuff.
>
>
> Thanks in advace.
> Matteo
>
>
> ------------------------------
> *Da:* Mark Adams <mfadams at lbl.gov>
> *Inviato:* mercoledì 11 febbraio 2026 17:25
> *A:* Matteo Leone <matteo4.leone at mail.polimi.it>; PETSc users list <
> petsc-users at mcs.anl.gov>
> *Oggetto:* Re: [petsc-users] DG methods in PETSc
>
> Great, and keep it on the list. Lots of people here to help!
>
> On Wed, Feb 11, 2026 at 9:46 AM Matteo Leone <matteo4.leone at mail.polimi.it>
> wrote:
>
> Wow thank you so much! I was almost hopeless, I'll deep dive into it and
> I'll give you a feedback.
>
> Matteo
>
> ------------------------------
> *From:* Mark Adams <mfadams at lbl.gov>
> *Sent:* Wednesday, February 11, 2026 3:38:30 PM
> *To:* Matteo Leone <matteo4.leone at mail.polimi.it>
> *Cc:* petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject:* Re: [petsc-users] DG methods in PETSc
>
> DG (discontinuous Galerkin) is done with a "Broken" FE. Yikes I do not see
> a test.
> Here is a test but it is not well verified.
> Mark
>
> On Tue, Feb 10, 2026 at 10:25 AM Matteo Leone via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
> Hello, I already posted on Reddit but just to be sure I write even here.
>
> First thanks for the job you do for PETSc, I have used it for several
> projects and is always nice.
>
> I am writing cause I am getting mad trying to implement DG solver in
> PETSc, the target is the Euler equations, however I am failing even with
> just the simplest transport equation (u/t + u/x = 0). I was wondering if I
> am missing somenthing. I tried with the DSSetReimannSolver and DualSpaces,
> and more, but I keep failing, I tried also with LLMs, but seems like there
> is no DG code with PETSc on the web, however I see many papers that do it.
>
> I was wondering if I am maybe missing something out or what.
>
> For reference I use PETSc 3.24.3 by means of nix.
>
> Thanks in advance, cheers.
>
> Matteo
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260219/22324910/attachment.html>
More information about the petsc-users
mailing list