Discontinuous Galerkin method: an inflow term

Hello everyone,

I am working with a transport equation of the form

\frac{\partial u(t,\boldsymbol{x})}{\partial t} + \theta(\boldsymbol{x}) \cdot \nabla_{x} u(t,\boldsymbol{x}) = 0

where \theta is a given vector field, and u is the unknown function.

To solve this equation, I would like to apply the Discontinuous Galerkin (DG) approach. In my variational formulation, the following term appears:

\begin{cases} \sum_{K\in\mathcal{T}_{h}}\int_{\partial K^{in}}\theta\cdot n_{K}[u]v_{+}, & K\cap\partial\Omega^{in}=\emptyset,\\ \sum_{K\in\mathcal{T}_{h}}\int_{\partial K^{in}}\theta\cdot n_{K}u_{+}v_{+}, & K\cap\partial\Omega^{in}\neq\emptyset. \end{cases}

Here, \mathcal{T}_{h} is the set of finite elements, K is a finite element (triangle or tetrahedron), and n_{K} is the outward unit normal vector on \partial K. The set \partial K^{in} is defined as

\partial K^{in}=\left\{ \boldsymbol{x}\in\partial K\ \middle|\ \theta(\boldsymbol{x})\cdot n_{K}(\boldsymbol{x})<0\right\},

and the jump and trace operators are given by

v_{+}(\boldsymbol{x})=\lim_{s\rightarrow0^{+}} v(\boldsymbol{x}+s\theta), \quad u_{\pm}(\boldsymbol{x})=\lim_{s\rightarrow0^{\pm}} u(\boldsymbol{x}+s\theta),
[u]=u_{+}(\boldsymbol{x})-u_{-}(\boldsymbol{x}).

The inflow boundary subset \partial\Omega^{in} is defined as

\partial\Omega^{in}=\left\{ \boldsymbol{x}\in\partial\Omega\ \middle|\ \theta(\boldsymbol{x})\cdot n(\boldsymbol{x})<0\right\},

where n is the unit normal to \partial\Omega.

Of course, I am using a time discretization to solve this problem. However, implementing the above term in FEniCSx (0.9) has been quite challenging for me. Could you provide some guidance?

Wouldn’t a ufl.conditional help for this?

I.e. have a dS integral, and have

theta_n = ufl.dot(theta, n)
cond = ufl.lt(theta_n, 0)
branch = ufl.conditional(cond, u("+"), ufl.jump(u))
F = branch*v("+")*dS

There might be I am missing some subtlies, as your sum would loop over the same facet twice (one for each element that is facing it). Thus one might need a slightly more clever way of doing this with a custom integration measure, or combine the integrals for each viewpoint (as for one side it has to point in, then on the other side the functions has to point out).

However, as you have provided no code, I don’t have time to code this up myself.