Trace() operator error and how to fix it

I’m trying to implement an HDG method for Stokes-Darcy flows. I had the following error when I run the code. Please see the attached file.

[code]---------------------------------------------------------------------------
NgException Traceback (most recent call last)
in
108
109 #a += interface_termds(defined =mesh.Boundaries(“GammaI”))
→ 110 a += SymbolicBFI(interface_term, definedon=mesh.Boundaries(“GammaI”))
111
112 a += (p
lam2 + q*lam1)*dx

NgException: Trialfunction does not support BND-forms, maybe a Trace() operator is missing, type = class ngfem::DiffOp<class ngcomp::DiffOpIdFacet<2> > __cdecl(void)[/code]

When I added Trace() to ubar, there was another error related to Trace()

[code]---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
160 # interface Gamma_I
161 ah_I = alpha*sqrt(1/kappa)*InnerProduct(tan_ubar,tan_vbar)
→ 162 bh_IS = - pbarS.Trace()*vbar.Trace()*n - qbarS.Trace()*ubar.Trace()*n
163 bh_ID = - pbarD.Trace()*vbar.Trace()*n - qbarD.Trace()*ubar.Trace()*n
164 interface_term = ah_I + bh_IS# + bh_ID

AttributeError: ‘ngsolve.fem.CoefficientFunction’ object has no attribute ‘Trace’[/code]

I found a topic on Trace() operator here, but it didn’t give me a solution.
Could you please tell me why this is and how to fix this error?
Thank you so much.

Attachment: HDGmethod.ipynb

Hi dong,

you need to specify the Trace operator directly for the trial and test functions, before combining them with other CoefficientFunctions.

ubar = CoefficientFunction((ubar1, ubar2))
vbar = CoefficientFunction((vbar1, vbar2))

ubar_tr = CoefficientFunction((ubar1.Trace(), ubar2.Trace()))
vbar_tr = CoefficientFunction((vbar1.Trace(), vbar2.Trace()))

...

un=ubar_tr*n
vn=vbar_tr*n

...

bh_IS = - pbarS.Trace()*vbar_tr*n - qbarS.Trace()*ubar_tr*n
bh_ID = - pbarD.Trace()*vbar_tr*n - qbarD.Trace()*ubar_tr*n

Best,
Michael

https://ngsolve.org/media/kunena/attachments/889/HDGmethod.ipynb

Attachment: HDGmethod.ipynb

Thank you so much, Michael. This helps me a lot.