# Errors imposing boundary conditions weakly with DG

I am using interior penalty discontinuous Galerkin to solve a simple Laplace problem: \begin{align*} \nabla u=0 \end{align*} with prescribed 0 and 1 Dirichlet boundary conditions on opposite edges of a unit square. The other edges have 0 Neumann. You'll see above that I have an image of the solution and it's gradient on the right.

The exact solution should be linear and it's gradient should be a constant value which is what I would get with continuous Galerkin. But with DG this isn't the case. I am getting some pollution of my solution and it's gradient at the corner. This won't happen if I defined continuous boundary conditions.

I need to integrate on the edge to queue for forces but the corner elements are causing me problems. I am using an edited version of step 74 of dealii for this and I can't impose BCs strongly in DG.

Any hints or tips on how to circumvent this issue? Other formulations and ways to impose BCs?

• How did you get the plot on the right? Maybe it's just a post processing problem Commented Jan 5, 2023 at 15:20
• A more important question would be the scaling of the axis first. Commented Jan 5, 2023 at 15:51
• Moreover, what is the polynomial degree in your calculation and how did you choose the penalties for the Inner- and the BC-sides? For accurate results, the penalties should be as high as possible, but less enough to prevent a bad condition number. Also be aware that DG does not even directly impose $C^0$ solutions, which makes the result in this particular case extremely sensitive on the penalties, especially with a high polynomial degree. Commented Jan 5, 2023 at 16:08
• #bobinthebox The plot on the right is directly using the Paraview Gradient filter of the solution. I get the same looking solution if I were to use the in-built dealii functions @ConvexHull the gradients aren't too high. The gradient in the domain is at 1, and at the corners goes form 0.2 to 1.5. Polynomial degree=1, the penalties are the same ones used in dealii step 74. Commented Jan 5, 2023 at 16:34
• Importantly, if you use polynomial degree 1, the exact solution is in the discrete solution space and the discrete solution needs to be exact. If it isn't, something is wrong. Commented Jan 6, 2023 at 6:04

I'm not familiar with deal.II. However, to show that DG is able to reproduce the constant gradient solution I will post some results with a different tool using IP. The penalty is about $$\sigma\approx1\times10^8$$, the polynomial degree is $$P=1$$.

Edit:

The solver is based on a "grad/div" or "strong-weak/weak" formulation. The system is assembled using the flux form and solved in primal form (applying the Schur complement). Using this approach all contributions in the system matrix from element-outside are set to zero using Neumann BC's. The matrix system is solved using direct LU.

Coarse mesh: 2x2 elements

Medium mesh: 8x8 elements

Fine mesh: 32x32 elements

• Is there a term in the weak from associated with the zero Neumann BC? Commented Jan 11, 2023 at 8:58
• @CuteCompute The solver is based on a "grad/div" or "strong-weak/weak" formulation. The system is assembled using the flux form and solved in primal form (applying the Schur complement). Using this approach all contributions in the system matrix from element-outside are set to zero using Neumann BC's. The matrix system is solved using direct LU. Commented Jan 11, 2023 at 17:05
• Can you share a paper that best illustrates this formulation? Commented Jan 12, 2023 at 5:52
• I think the methodology is quite standard. Commented Jan 13, 2023 at 21:39

I fixed it after help from the dealii user group. It was a coding error on my part. Thank you all for your inputs