<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Yes it works,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
but does not provide a correct solution and is stationary in time, I was just pointing this out. </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I'll try to get as much as I can from the PetscFE object, PETSc provides already a lot of stuff, it cannot do everything.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Thanks for the support and time dedicated,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Matteo</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Da:</b> Mark Adams <mfadams@lbl.gov><br>
<b>Inviato:</b> giovedì 19 febbraio 2026 18:15<br>
<b>A:</b> Matteo Leone <matteo4.leone@mail.polimi.it><br>
<b>Cc:</b> PETSc users list <petsc-users@mcs.anl.gov><br>
<b>Oggetto:</b> Re: [petsc-users] Fw: DG methods in PETSc</font>
<div> </div>
</div>
<div>
<div dir="ltr">Just to avoid confusion with a convoluted thread, here is my response reposed:
<div><br>
</div>
<div>
<div>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</div>
<div><br>
</div>
<div>I see that the Riemann solver is set:</div>
<div><br>
</div>
<div>  PetscCall(PetscDSSetRiemannSolver(ds, 0, RiemannSolver_Advection));</div>
<div><br>
</div>
<div>I would not recommend using DG because there are no tests for it. </div>
<div>There are tests for PetscDSSetRiemannSolver that you could clone and replace the FE/FV construction in those with DG:</div>
<div><br>
</div>
<div>src/ts/tutorials/ex11.c:  PetscCall(PetscDSSetRiemannSolver(prob, 0, user->model->physics->riemann));<br>
src/ts/tutorials/ex18.c:  if (user->velocityDist == VEL_ZERO) PetscCall(PetscDSSetRiemannSolver(prob, 1, riemann_advection));<br>
src/ts/tutorials/ex18.c:  else PetscCall(PetscDSSetRiemannSolver(prob, 1, riemann_coupled_advection));</div>
<div><br>
</div>
<div>If you get this far, you might want to look at internal examples (not tests) and clone these DG constructors:</div>
<div><br>
</div>
<div>src/dm/dt/fe/interface/fe.c:  PetscFECreateBrokenElement - Create a discontinuous version of the input `PetscFE`<br>
src/dm/dt/fe/interface/fe.c:PetscErrorCode PetscFECreateBrokenElement(PetscFE cgfe, PetscFE *dgfe)<br>
src/dm/impls/plex/plexcreate.c:        PetscCall(PetscFECreateBrokenElement(fe, &dgfe));<br>
src/dm/interface/dmcoordinates.c:      PetscCall(PetscFECreateBrokenElement(feLinear, &dgfe));</div>
<div><br>
</div>
<div>Sorry we do not have DG fully deployed yet.</div>
<div><br>
</div>
<div>Good luck,</div>
<div>Mark</div>
</div>
</div>
<br>
<div class="x_gmail_quote x_gmail_quote_container">
<div dir="ltr" class="x_gmail_attr">On Thu, Feb 19, 2026 at 12:14 PM Matteo Leone via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<br>
</div>
<div id="x_m_-7346522953463486077ms-outlook-mobile-body-separator-line" dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt">
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
</div>
<div id="x_m_-7346522953463486077ms-outlook-mobile-signature" dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt">
<span style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt">Inviato da
<a href="https://urldefense.us/v3/__https://aka.ms/AAb9ysg__;!!G_uCfscf7eWS!esCSra9pt1Q2VQtIwFRk5ds5BQ6-sbeQ66hUETSln-bCt8DbHI1HPvjOPOT6hyKlCgM8Xa4rlvZ6s9Gz4-MYSg9RvFGxWhhnjWc$" target="_blank">
Outlook per Android</a></span></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-7346522953463486077divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matteo Leone <<a href="mailto:matteo4.leone@mail.polimi.it" target="_blank">matteo4.leone@mail.polimi.it</a>><br>
<b>Sent:</b> Thursday, February 19, 2026 3:36:44 PM<br>
<b>To:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>><br>
<b>Subject:</b> R: [petsc-users] DG methods in PETSc</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hello, I now have tested quite a bit the code, and I have some doubts.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Note I am quite new to PETSc.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
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.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
The Riemann solver is never called and also the solution is just static in time. </div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
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). </div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
(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).</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
There is also a small .py to handle the visualization (It was made by Claude code, but it just plots the results)</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hopefully we can go deep into this PETSc DG stuff.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Thanks in advace.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Matteo</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="x_m_-7346522953463486077x_appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-7346522953463486077x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Da:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>><br>
<b>Inviato:</b> mercoledì 11 febbraio 2026 17:25<br>
<b>A:</b> Matteo Leone <<a href="mailto:matteo4.leone@mail.polimi.it" target="_blank">matteo4.leone@mail.polimi.it</a>>; PETSc users list <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Oggetto:</b> Re: [petsc-users] DG methods in PETSc</font>
<div> </div>
</div>
<div>
<div dir="ltr">Great, and keep it on the list. Lots of people here to help!</div>
<br>
<div>
<div dir="ltr">On Wed, Feb 11, 2026 at 9:46 AM Matteo Leone <<a href="mailto:matteo4.leone@mail.polimi.it" target="_blank">matteo4.leone@mail.polimi.it</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
Wow thank you so much! I was almost hopeless, I'll deep dive into it and I'll give you a feedback.</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<br>
</div>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
Matteo</div>
<div id="x_m_-7346522953463486077x_x_m_2712524141435510669ms-outlook-mobile-body-separator-line" dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt">
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<br>
</div>
</div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-7346522953463486077x_x_m_2712524141435510669divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>><br>
<b>Sent:</b> Wednesday, February 11, 2026 3:38:30 PM<br>
<b>To:</b> Matteo Leone <<a href="mailto:matteo4.leone@mail.polimi.it" target="_blank">matteo4.leone@mail.polimi.it</a>><br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a> <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] DG methods in PETSc</font>
<div> </div>
</div>
<div>
<div dir="ltr">DG (discontinuous Galerkin) is done with a "Broken" FE. Yikes I do not see a test.
<div>Here is a test but it is not well verified.</div>
<div>Mark</div>
</div>
<br>
<div>
<div dir="ltr">On Tue, Feb 10, 2026 at 10:25 AM Matteo Leone via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hello, I already posted on Reddit but just to be sure I write even here.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
First thanks for the job you do for PETSc, I have used it for several projects and is  always nice.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
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. </div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I was  wondering if I am maybe missing  something out or what.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
For reference I use PETSc 3.24.3 by means of nix. </div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Thanks in advance, cheers.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Matteo</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>