How to define and update function on internal DG interfaces?

I want to define a logistic function N on an interior boundary of a mesh using a DG elements and am hoping to make this function piecewise constant on each facet of a 2D mesh labelled with the marker 3. I’m defining the function N as

\dfrac{dN}{dt} = N(1-N)

and using the initial condition N(t=0) = 0.1.
To define the initial state of N, I have the code below:

DG0_elem = FiniteElement("DG", mesh.ufl_cell(), 0)
V0 = FunctionSpace(mesh, DG0_elem)
v0 = TestFunction(V0)
val = assemble(Constant(0.1)*v0('+')*dS(3))
N = Function(V0,val)

I’d like to update N in a time loop without re-assembling the expression for N in each loop, as I am currently doing:

dt = 0.01
T = 10.0*dt
while dt < T:
 N_new = Function(V0, assemble((N('+')*(1-N('+')*dt + N('+'))*v0('+')*dS(3))
  N.assign(N_new)

The above expression seems like it would be slow because it is redefining a new function and assembling a new form with every iteration. Is there a better way to do this?

If N is defined only on the trace of the elements, you should correspondingly use DG trace elements.

I somewhat lazily tried to convert your code into a working example with efficiency updates

from dolfin import *

mesh = UnitSquareMesh(1, 1)

DG0_elem = FiniteElement("Discontinuous Lagrange Trace", mesh.ufl_cell(), 0)
V0 = FunctionSpace(mesh, DG0_elem)
v0 = TestFunction(V0)
val = assemble(Constant(0.1)*v0('+')*dS(3))
N = Function(V0,val)

dt = 0.01
t = 0.0
T = 10.0*dt
N_new = Function(V0)
while t < T:
	assemble((N('+')*(1-N('+')*dt + N('+'))*v0('+')*dS(3)), tensor=N_new.vector())
	N.assign(N_new)
	t += dt

Hi nate–thanks for your quick response! The Discontinuous Lagrange Trace elements seem like what I’m looking for. Is there a way to plot these elements?

Maybe I should have said this in my original post, but in my larger application code, the value of N depends on a function of order 1 “DG” elements and I want to use the updated value of N in each time step to compute a penalty parameter on the order 1 “DG” elements. Is an approach like the one you outlined still valid? Or is there a better way?