Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplementation of skfem.mesh #556

Merged
merged 117 commits into from
Mar 13, 2021
Merged

Reimplementation of skfem.mesh #556

merged 117 commits into from
Mar 13, 2021

Conversation

kinnala
Copy link
Owner

@kinnala kinnala commented Feb 5, 2021

@kinnala kinnala marked this pull request as draft February 5, 2021 10:14
@kinnala
Copy link
Owner Author

kinnala commented Feb 5, 2021

Let me add that in theory it supports arbitrarily high order meshes.

@kinnala
Copy link
Owner Author

kinnala commented Feb 5, 2021

One thing that must be verified is that the performance cost is not too large because it's using MappingIsoparametric always in place of MappingAffine.

skfem/mesh/graph.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gdmcbain gdmcbain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert (a-A).sum() < 1e-10

Possibly not the best test since

a.sum() == A.sum() == 0

and almost numerically also for a2, A2, …, by definition the laplacian of a constant vanishing.

Maybe

assert (a - A).nnz == (a3 - A3).nnz == (a4 - A4).nnz == 0

but (a2 - A2).nnz == 452 and has data ranging from -504.5 to 251.6.

[1, 2],
[0, 2],
]
elif self.t.shape[0] == 4:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not immediately obvious to me how this distinguishes quadrilaterals from tetrahedra, but I'll step through the (obviously working) example to see.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, is it just that quadrilaterals aren't included yet and will be handled by something like

elif self.dim == 2 and self.mesh.t2f.shape[0] == 4:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[np.array_equal(m.facets, M.facets) for m, M in [(m, M), (m2, M2), (m3, M3), (m4, M4)]]

[True, True, False, False]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing these out. It seems that the quadratic Grid still has some issues. It's a bit complicated to wrap my head around it, however, at least we have the working reference MeshTri2 to compare against.

@kinnala
Copy link
Owner Author

kinnala commented Feb 9, 2021

...

@kinnala
Copy link
Owner Author

kinnala commented Feb 9, 2021

Although it's very nice approach, currently the performance difference is so large that I won't replace Mesh unless I'm able to optimize it significantly:

In [1]: %timeit basis3 = InteriorBasis(m3, ElementTetP1())                      
142 ms ± 773 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [2]: %timeit Basis3 = InteriorBasis(M3, ElementTetP1())                      
775 ms ± 5.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

There are some bottlenecks that I immediately recognize. I'll start looking into it tomorrow.

@kinnala
Copy link
Owner Author

kinnala commented Mar 12, 2021

TODO hexahedron save reordering

@kinnala kinnala changed the title Next gen mesh A reimplementation of skfem.mesh Mar 13, 2021
@kinnala kinnala changed the title A reimplementation of skfem.mesh Reimplementation of skfem.mesh Mar 13, 2021
@kinnala kinnala merged commit 3420810 into master Mar 13, 2021
@kinnala kinnala deleted the next-gen-mesh branch March 13, 2021 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants