Better support for high-order meshes
See original GitHub issueThis is just random ideas and possible future directions regarding high-order meshes. We have ex31.py
for quadratic meshes but it’s a bit convoluted because you go back and forth between InteriorBasis
and Mesh
.
I was reading https://mfem.org/mesh-format-v1.x/ and experimented with similar ideas in scikit-fem. I created a new module with classes Topology
, Dofnum
(extracted from InteriorBasis._build_dofnum
) and Geometry
.
Then you describe the traditional triangular mesh as follows:
>>> from skfem import *
>>> from topology import *
>>> m = MeshTri()
>>> t = m.t
>>> p = m.p
>>> topo = Topology(t)
>>> dofnum = Dofnum(topo, ElementTriP1())
>>> geom = Geometry(p, dofnum)
>>> geom.p
array([[0., 1., 0., 1.],
[0., 0., 1., 1.]])
>>> geom.t
array([[0, 1],
[1, 2],
[2, 3]])
This Geometry
is approximately API compatible with traditional skfem.Mesh
so you can build a MappingIsoparametric
and, using that, an InteriorBasis
:
>>> mapping = MappingIsoparametric(geom, ElementTriP1())
>>> basis = InteriorBasis(m, ElementTriP2(), mapping)
Eventually I’d abstract out the mapping step so that geom
is directly compatible with InteriorBasis
constructor and returns the correct mapping via geom.mapping()
.
Anyhow, now a quadratic mesh would be described simply as follows:
>>> dofnum = Dofnum(topo, ElementTriP2())
>>> geom = Geometry(array([[0. , 1. , 0. , 1. , 0.5, 0. , 0.5, 1. , 0.5],
... [0. , 0. , 1. , 1. , 0. , 0.5, 0.5, 0.5, 1. ]]), dofnum)
>>> mapping = MappingIsoparametric(geom, ElementTriP2())
>>> basis = InteriorBasis(m, ElementTriP2(), mapping)
Pretty cool? Obviously all this should be invisible to the user but I wonder if this warrants a rewrite of skfem.mesh
so that we can easily define MeshTri2
or something to refer to the quadratic mesh.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
Just did some serious progress on this in #493
Loading a quadratic mesh from Gmsh using meshio and solving the Laplace equation.
Closing this shortly and opening new ones that are more detailed.