Setting up Neumann boundary conditions with dolfin_dg

I am using dolfin_dg to formulate my advection diffusion problem with Discontinuous Galerkin. I am trying to understand how one can set up the boundary conditions, specially the outflow conditions. For a HyperbolicOperator, it seems that if my outflow boundary is 3, I have to include DGNeumannBC(ds(3), Constant(0.0)), although the second argument seems to be ignored in here, therefore, it correctly includes the outflow boundary term. How does one formulate the outflow condition in the EllipticOperator? Using the same DGNeumannBC would result in actually applying the second argument in here. At the same time, if one does not use DGNeumannBC there is no residual at the outflow boundary being included in the DG formulation, as one would expect (I believe). Is there an example anywhere with an advection-diffusion problem with outflow conditions as well? Thanks.

Can you post a MWE for context? I’m having a little trouble understanding your problem.

EDIT: I think I understand your troubles now. It’ll take me a few moments to write out what’s going on in terms of the maths.

One must carefully consider the nature of the “hyperbolic” and “elliptic” operator desicretisations as offered by dolfin_dg.

As a prelude we consider the following simplified problem definitions.

Let \Omega be the standard, well behaved, finite domain.

The hyperbolic problem

Find u such that

\nabla \cdot (\vec{b} u) = 0 \text{ in } \Omega \\ u = u_\text{in} \text{ on } \partial\Omega_\text{in}

where \vec{b} is some well behaved vector field, u_\text{in} is the known incoming numerical flux component and \partial\Omega_\text{in} = \{ x \in \partial\Omega : \vec{b} \cdot \vec{n} < 0 \} is the boundary where we prescribe the numerical flux “incoming” to the domain.

Note: Here there is no notion of a Neumann boundary condition. We must carefully consider where numerical fluxes are known and unknown. The natural “outflow” BC is enforced in the weak formulation by preserving the unknown function u on the outflow boundary after integration by parts.

The elliptic problem

\partial\Omega is split into Dirichlet and Neumann components, \partial\Omega_D and \partial\Omega_N such that \partial\Omega = \partial\Omega_D \cup \partial\Omega_N and \partial\Omega_D \cap \partial\Omega_N = \emptyset.

The problem reads

-\nabla^2 u = 0 \text{ in } \Omega \\ u = u_D \text{ on } \partial\Omega_D \\ \nabla u \cdot \vec{n} = g_N \text{ on } \partial\Omega_N \\

The Dirichlet BCs are weakly enforced after integrating by parts by prescribing numerical fluxes on those boundaries. The Neumann condition is enforced naturally after performing the integration by parts.

dolfin_dg nomenclature

The DGNeumannBC is actually an abuse of terminology. In the context of a hyperbolic problem in dolfin_dg, a DGNeumannBC will weakly enforce the natural “outflow” boundary component of the weak formulation. And in terms of the elliptic problem it will enforce the natural Neumann BC in terms of the viscous flux prescription.

This matches with the code lines that you’ve linked to. The HyperbolicOperator simply prescribes the unknown flux on (what should be) the outflow component of the boundary as found in the NeumannBC data structure. The EllipticOperator notices the DGNeumannBC and simply formulates the standard integration by parts and assigns the viscous flux provided.

For a much more rigorous explanation, I refer to Houston & Sime 2018. Here you can see the general formulation of boundary conditions in terms of the hyperbolic operator’s flux Jacobian. Particularly Section 2 and the definition of \mathcal{N}(\mathbf{u}_h, \mathbf{v}_h) and \mathcal{N}_\Gamma(\mathbf{u}_h, \mathbf{v}_h).

Reasons for this choice of nomenclature

I wrote this back in 2014/15 or so when I was far less experience with FEMs. I tried to harmonise the formulation for all operator types so that one didn’t need to define a BC type for every BC component of every operator in a potentially diverse formulation (e.g. MHD). In my contemporary use of dolfin_dg, I elect to define the advective term discretisations more explicity, e.g. this spacetime Burgers example.

1 Like