# Tensor Product Space and HCurl/HDiv

5 years 10 months ago #1204 by jhauser
I recently started to work with NGSolve.
I would like to work with the tensor product space. However it always crashes when it comes to HCurl and HDiv. Or at least if I try to evaluate a function of a tensor product space with HDiv/HCurl. One small example would be:
Code:
from ngsolve.TensorProductTools import * from ngsolve import * from netgen.geom2d import unit_square import netgen.gui %gui tk meshx = Mesh(unit_square.GenerateMesh(maxh=0.15)) mesht = Mesh(SegMesh(20,0,1,periodic=True) ) tpmesh = Mesh(MakeTensorProductMesh(mesht,meshx)) Draw(tpmesh) n=1 m=1 fesx = HDiv(meshx,order=n) fest = H1(mesht,order=m) tpfes = TensorProductFESpace([fest,fesx]) u = GridFunction(tpfes) gtest = x g = ProlongateCoefficientFunction(gtest,0,tpfes) u.Set(g)

It crashes with the "u.Set()". When I looked into the code it seemed to me, that the ".Set" uses the ".GetFE"-routine which isn't implemented for the two spaces HDiv and HCurl.
My problem is that I haven't found the right Set/evaluation routines for those two spaces. Could you give me some advise about the parts of the code I should look into to fix this problem?
5 years 10 months ago #1205 by joachim
Hi,

I did a quick debug of your problem:

The tensor-product Set assumes scalar finite elements (in tpintrule.hpp, line 155). It should be rewritten using the Evaluators of the component spaces.

Gerhard may help here.

Don't worry, also the HCurl and HDiv - spaces have GetFE - functions.

Btw, your tensor-product space is vector valued, so it does not make sense to set a function to the scalar function x.

Joachim
5 years 10 months ago #1206 by jhauser
Thank you very much for the quick reply!

So it would be best to distinguish between the finite element spaces and use for HCurl the BaseHCurlFiniteElement in line 155 and 156 of tpintrule.hpp? Would you use HDivFiniteElement in the HDiv Case? (However I didn't find the implementation of "CalcShape" for HDivFiniteElement in hdivfe.cpp. Only for FE_RTTrig0, FE_BDMTrigl and so on.)

Thank you for the remark. I assumed falsely that it would be projected to a vector valued function. (I got a bit confused with the gradx/grady naming of the gradiant of the tensor product space.)
5 years 10 months ago #1208 by gerhard
Hi jhauser,

It should be possible now, to construct an H1 times HDiv ( and H1 times HCurl) and to set gridfunctions in that space to a given coefficient function. I changed tthe code from your post to give you a first example.

Since one of your spaces is called fest, I expect that you have space-time applications in mind? Because currently we only support operator application for BilinearForms defined in TensorProductFESpace, no system matrix can yet be assembled. ( Since it was intended for DG operator application initially, so mainly a historical reason).

Additionally I'm not sure, if vectorial spaces are treated correctly when applying your BilinearForm.

However, I think most of the above mentioned things an be solved.

Gerhard
5 years 10 months ago #1209 by gerhard
Sorry, I forgot to give you an example code also. Here it is...

#### File Attachment:

File Name: SetExample.py
File Size:1 KB
##### Attachments:
5 years 10 months ago #1212 by jhauser
I updated my ngsolve version yesterday and today. However your example still crashes with the ".Set". The two lines in tpintrule.hpp (155&156) haven't changed as well.

Yes, space-time is the goal. But i knew that there will be work before things run smoothly. There isn't a software yet which is open source for space-time with HCurl/HDiv. (At least as far as I know) Which is why I am trying to get things running with NGSolve.
Is there anything I should keep in mind before I tackle the problem of the BilinearForm?
Time to create page: 0.118 seconds