Trace() operator error and how to fix it

More
4 years 5 months ago - 4 years 5 months ago #2861 by dong
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) <ipython-input-12-02f4f3b3aa99> in <module> 108 109 #a += interface_term*ds(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)

When I added Trace() to ubar, there was another error related to Trace()
Code:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-14-a9a9b48be4c9> in <module> 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'

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.
Attachments:
Last edit: 4 years 5 months ago by dong.
More
4 years 5 months ago #2863 by mneunteufel
Hi dong,

you need to specify the Trace operator directly for the trial and test functions, before combining them with other CoefficientFunctions.
Code:
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

File Attachment:

File Name: HDGmethod.ipynb
File Size:7 KB
Attachments:
More
4 years 5 months ago #2864 by dong
Thank you so much, Michael. This helps me a lot.
Time to create page: 0.098 seconds