Solving advection equation with Inequality constraint with DG

Hello,

I currently have implemented in NgSolve a program that solve for the advection equation a_t + Div( aU ) = 0 with DG, but I want to modify the code so that the value of “a” is bounded between 0 < a < 1.

A    = L2(mesh, order = k, dgjumps = True, dirichlet="wall|inlet")
a, z = A.TnT()

bfa  = BilinearForm(A)

bfa +=   a * z * dx
bfa += - dt * a * U * grad(z) * dx
bfa +=   dt *(z-z.Other())* IfPos( U*n, a, a.Other()) * U * n * dx(skeleton=True)
bfa +=   dt * z * a * U * n * ds(skeleton=True, definedon=mesh.Boundaries("outlet"))

lfa = LinearForm(A)

lfa +=   a_old * z * dx
lfa += - dt * z * U * n * ad_bnd * ds(skeleton=True, definedon=mesh.Boundaries("inlet|wall"))

To satisfy the inequality constraint, I’m unfamiliar with how to convert my bilinear and linear forms into a SNES object to solve with PETsc, or if I have other options.