0
$\begingroup$

If $u_t+a \cdot u_x=0$ under a periodic boundary condition (to mimic an infinite domain) is solved by Discontinuous Galerkin (DG), how to implement periodic boundary condition and the other details in DG?

$\endgroup$
1
  • 1
    $\begingroup$ One can impose periodic boundary conditions by imposing them on the trial function basis. Their span will consist only of periodic functions. $\endgroup$
    – hardmath
    Commented Dec 31, 2022 at 16:34

1 Answer 1

2
$\begingroup$

You can implement the boundary condition topologically. In pseudo-code this might look something like:

# I'm assuming 0-based indexing in 1D, adjust accordingly for 1-based indexing
for every element i:
    if i == 0:
        left_element = nelems - 1
    else:
        left_element = i - 1
    if i == nelems - 1:
        right_element = 0
    else:
        right_element = i + 1
    compute_dg_update(left_element, i, right_element)

If you want to uniquely pre-compute the numerical flux instead of recomputing it in an element-based update, you would compute the numerical flux only for left faces (or only right faces, but not both). Then the numerical flux for the right face of element $\mathrm{nelems}-1$ would be the flux computed for the left face of element $0$ (vise-versa if you instead computed the flux at the right faces).

A third way to implement periodic boundary conditions is by using "ghost values". You can initialize your storage array to hold elements $[-1, \mathrm{nelems}]$, then copy the values in element $\mathrm{nelems}-1$ to element $-1$, and copy element $0$ to element $\mathrm{nelems}$. You then only update the solution for elements $[0, \mathrm{nelems}-1]$ using DG. This method generalizes well when you want to partition your domain for MPI parallelism since the periodic BC is handled almost seamlessly by the same code which handles regular sub-partition coupling.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.