Old HDG Program

Hi,

I tried to execute an older HDG solver for a nonlinear Fokker Planck equation. I discretize the diffusion operator implicitly, the convective term explicitly. I do get a strange error when I assemble the LinearForm related to the nonlinear outflow boundary conditions. I copied a snippet of the code below

Discretization of the Laplace operator - HDG formulation

stab = 10
a = BilinearForm(fes)
a += SymbolicBFI(D * grad(u) * grad(v))
a += SymbolicBFI((D * grad(u)) * n * (vhat-v)+ (D * grad(v))n(uhat-u)+ stab * orderorder/h(u-uhat)*(v-vhat), element_boundary=True)
a.Assemble()

Transportation vector in x-direction

b = CoefficientFunction( (1,0) )
bn = b*specialcf.normal(2)
ubnd = CoefficientFunction(0)

Discretization of the convection operator - DG formulation with upwind

conv = BilinearForm(fes)
conv += SymbolicBFI (-u * (1-u) * b* grad(v))
conv += SymbolicBFI ((bn*IfPos(bn, u * (1-u), u.Other(bnd=ubnd) * (1-u.Other(bnd=ubnd))) * v).Compile(), element_boundary=True)

Mass matrix

m = BilinearForm(fes)
m += SymbolicBFI (u * v)
m.Assemble()

hmat = a.mat.CreateMatrix()
hmat.AsVector().data = 0.5 * tau * a.mat.AsVector() + m.mat.AsVector()
inv = hmat.Inverse(fes.FreeDofs())

Linearform - inflow

fbc_in = LinearForm(fes)
fbc_in += SymbolicLFI(fin * vhat, BND, definedon=mesh.Boundaries(“inflow”))
fbc_in.Assemble()

The following error occurs when assembling the linear form fbc_in:
File “”, line 79, in
RuntimeError: cannot evaluate facet-fe inside element, add trans simdin Assemble LinearForm

Could you please advise what to do ?

Thanks a lot
Marie-Therese

Hi,

you need the Trace operator if you want to evaluate vhat directly on the boundary:

fbc_in += SymbolicLFI(fin * vhat.Trace(), BND, definedon=mesh.Boundaries(“inflow”))

Best,
Michael