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.

Div of a Curl

More
5 years 8 months ago #606 by ddrake
Div of a Curl was created by ddrake
Hi,

I've been enjoying the updated iTutorials very much!

I noticed a small issue with the new HCurlDiv iTutorial, though...

It tries to compute the div of the curl of a grid function l in block 12, and fails like this:

Exception Traceback (most recent call last)
<ipython-input-14-3853ecb1c0ea> in <module>()
----> 1 div(uc)

~/ngsuite/ngsolve-install/lib/python3/dist-packages/ngsolve/utils.py in div(func)
84 if add:
85 return add
---> 86 raise Exception("cannot form div")
87
88

Exception: cannot form div

Just to see what would happen, I changed a line in utils.py (as below) and restarted the Jupyter kernel.
Code:
def div(func): # if func.derivname == "div": if func.derivname in ["div", "curl"]: return func.Deriv() add = func.Operator("div") if add: return add raise Exception("cannot form div")

It seemed to work:

div(uc)
<ngsolve.comp.CoefficientFunction at 0x7fd22cce68e0>

Best,
Dow
More
5 years 8 months ago - 5 years 8 months ago #608 by christopher
Replied by christopher on topic Div of a Curl
Hi, that line was there to show that you cannot form the div of a function in HCurl (because its not implemented either as the default operator or as an additional operator). So it raises an exception.
The function .Deriv() returns the default derivative for the finite element space the Testfunction/Trialfunction/Gridfunction is defined on. We give a function from HCurl, so
Code:
if func.derivname in ["div", "curl"]:
returns true and with
Code:
return func.Deriv()
you return the curl of the function not the div...

Best
Christopher
Last edit: 5 years 8 months ago by christopher.
The following user(s) said Thank You: ddrake
More
5 years 8 months ago #611 by ddrake
Replied by ddrake on topic Div of a Curl
Hi Christopher,

Thanks for clearing up my misunderstanding on this!

Best,
Dow
More
5 years 8 months ago #615 by plederer
Replied by plederer on topic Div of a Curl
Hi dow!

Note however that the piecewise grad operator is exported for H(curl) function. By this you could for example implement (just for fun :D...) an H(curl) conforming dg vector laplce problem.

Thus you can easily implement the pice-wise div operator on your own.

Best, Philip

PS: I think grad(u) is actually the transpose...
The following user(s) said Thank You: ddrake
Time to create page: 0.149 seconds