Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Trace() operator error and how to fix it

More
3 years 10 months ago - 3 years 10 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: 3 years 10 months ago by dong.
More
3 years 10 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
3 years 10 months ago #2864 by dong
Thank you so much, Michael. This helps me a lot.
Time to create page: 0.120 seconds