HDG for time dependent advection equation with periodic BC

Hello,

I am writing a DG code for a time-dependent nonlinear PDE and would like to use NGSolve’s built-in Newton solver. Since I understand that the Newton solver does not work directly with a DG formulation, I am introducing a facet variable that is constrained to coincide with the average trace, effectively converting the method into an HDG formulation.

To avoid unnecessary complications, let us consider the standard advection equation with periodic boundary conditions as a test case. The DG method with central fluxes works as expected, but the HDG formulation does not. In 2D, the solution is almost correct, except for some unexpected behavior near the periodic boundaries. In 1D, however, the computed solution is completely wrong.

I have attached the corresponding codes.

Best,
Enrico

TransportHDG2d.ipynb (6.5 KB)

TransportHDG.ipynb (72.1 KB)

Hi Enrico,

there is one problem with life-time management of vectors of component gridfunctions:
If I change this

def evolveIE_HDG(gfrho_old_vec):
    ...
    return gfA.components[0].vec.Copy()

I get something reasonable for your 2D probelm,

Joachim

Thanks, Joachim. Is there a way to make it work also for the 1d problem?

Best,

Enrico

Ok, I think I found a solution: it seems that in 1d FacetFESpace does not work properly with periodic BC. I replaced it with Periodic( H1(mesh, order = 1)) and it works.

Enrico

Periodic(FacetFESpace) works now also in 1D, thank you for the bug report!

1 Like

Hi Joachim, I am new to NGSolve. Can you suggest how to perform element-wise post-processing for the HDG method? It would be helpful if you could share any useful examples on that. Thank you.