meshpro / dmsh

:spider_web: Simple mesh generator inspired by distmesh.
GNU General Public License v3.0
210 stars 25 forks source link

Boundary Node Identification #60

Closed griff10000 closed 3 years ago

griff10000 commented 3 years ago

What is the best way to extract boundary node indices from a finished mesh?

nschloe commented 3 years ago

mesh.is_boundary_point should do it.

griff10000 commented 3 years ago

Many thanks for your prompt response. I used the following approach to generate the boundary nodes:

import meshplex
mesh = meshplex.MeshTri(X, cells)

idx = np.where(mesh.is_boundary_node == True)
x, y = X[idx,0].flatten(), X[idx,1].flatten()

I appreciate that this may not be optimal. However, I wonder if there is way of directly accessing an 'ordered list' of boundary nodes as I assume such a list is being generated for the show() function?

nschloe commented 3 years ago

Better use the boolean index directly:

Xb = X[mesh.is_boundary_node]

Or, if you need the coords separately,

x, y = X[mesh.is_boundary_node].T
griff10000 commented 3 years ago

Thanks again.

ml14je commented 3 years ago

I believe mesh.is_boundary_node is no longer valid? It comes up with AttributeError: 'MeshTri' object has no attribute 'is_boundary_node'

nschloe commented 3 years ago

@ml14je Try is_boundary_point. ipythons expansions can also help exploring a module if you're unsure about a method name.