-
Notifications
You must be signed in to change notification settings - Fork 80
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
Mesh.facets_around() not working after refinement #1154
Comments
Thanks for the report. Based on this, all named boundaries should be removed from the mesh during adaptive refine: scikit-fem/skfem/mesh/mesh_tri_1.py Line 389 in c6b3675
What is check_mesh doing? |
Anyhow, don’t expect this to be fixed any time soon. It is a somewhat challenging indexing problem to solve in general. |
Sorry, the
The thing is, the named boundaries are not preserved already. What is preserved is the sub domains, but the ordering may be messed up. I don't know
Yes, I can only imagine. It would be a great feature though |
I don't quite follow what happens in this issue. Can you provide the code of |
def check_boundary(mesh):
plt.figure()
plt.scatter(*mesh.p, marker = 'o', facecolor = 'None', edgecolor = 'black', s = 15)
# boundary = mesh.boundaries['square___clad']
boundary = mesh.facets_around(mesh.subdomains['square'])
facet_basis = basis0.boundary(boundary)
facets = mesh.facets[:,boundary]
colors = plt.cm.jet(np.linspace(0,1,facets.shape[1]))
for i in range(facets.shape[1]):
# plt.text(*data[:,i], f'{i}')
x = [mesh.p[0,facets[0,i]], mesh.p[0,facets[1,i]]]
y = [mesh.p[1,facets[0,i]], mesh.p[1,facets[1,i]]]
norm = np.asarray([facet_basis.normals[0,i,0],
facet_basis.normals[1,i,0]])
norm = norm/np.sqrt(np.sum(np.abs(norm)**2)) * 0.1
plt.arrow(np.mean(x), np.mean(y), dx = norm[0], dy = norm[1], color = colors[i],
head_width = 0.03,
head_length = 0.01,
length_includes_head = True)
plt.plot(x, y, color = colors[i])
# plt.text(np.mean(x), np.mean(y), f"{i}")
plt.scatter(mesh.p[0,facets[0]], mesh.p[1,facets[0]], c = colors, s = 20)
plt.scatter(mesh.p[0,facets[1]], mesh.p[1,facets[1]], c = colors, s = 20) |
I'm unable to reproduce this with my own minimal example, perhaps it was fixed by another issue, or then I misunderstood the issue: from skfem import *
import numpy as np
m = MeshTri().refined(4).with_subdomains({'test': lambda x: (x[0] < 0.5) * (x[0] > 0.3) * (x[1] < 0.5) * (x[1] > 0.3)})
m = m.with_boundaries({'test': m.facets_around('test')})
m.draw(boundaries=True).show()
m = m.refined(np.arange(200))
m = m.with_boundaries({'test': m.facets_around('test')})
m.draw(boundaries=True).show() The normal vector should be pointing opposite to the red triangle. |
I was working on the mesh refinement, trying to understand how can boundaries be kept, and came across the issue of the
mesh.facets_around()
not working properly after a refinement.Before refinement:
After refinement:
The text was updated successfully, but these errors were encountered: