kinnala / scikit-fem

Simple finite element assemblers
https://scikit-fem.readthedocs.io
BSD 3-Clause "New" or "Revised" License
512 stars 81 forks source link

Error constructing basis of ElementGlobal in 3D #1036

Closed pbignardi closed 1 year ago

pbignardi commented 1 year ago

When constructing an instance of ElementGlobal in 3D the function _pbasis_init throws the following exception (line 87)

TypeError: '>' not supported between instances of 'NoneType' and 'int'

This is due to the fact that dy is set to None, and the culprit for that is (line 120)

dy = sum([1 for d in diff if d == 1]) if dim == 2 else None

This seems wrong, as one should have dy even in the 3D case, i.e. when dim == 3

kinnala commented 1 year ago

Thanks for the report. I think we don't have any 3D elements in scikit-fem using ElementGlobal right now and this has probably been untested because of that.

Out of curiosity, what kind of finite element you are trying to implement?

pbignardi commented 1 year ago

I'm trying to implement a C1 element on a hexahedral mesh.

Maybe I should open a discussion about that in the appropriate section, but do you have any suggestion on how that could be achieved using tools already available in scikit-fem?

For now, the simplest idea that came to mind was to implement the tensor product of Hermite Line Element in each direction x, y, z.

kinnala commented 1 year ago

https://onlinelibrary.wiley.com/doi/10.1002/nme.2449

They use cubic full tensor basis with 64 DOFs. The DOFs per node are value (1), first derivatives (3), mixed second derivatives (3), mixed third derivative (1). So 8 DOFs per node.

kinnala commented 1 year ago

The above element is implemented now in #1037.

Do not try to use too many elements (and remember to keep intorder quite low) because 64 DOFs is quite huge and the approach used in ElementGlobal is not really suitable for such complex elements.