Inquiring into a triangular mesh

All codes are written in Python and based on 3D plotting and mesh analysis library PyVista.

Cells connected to a node

To speed up finding the cells connected to a node, I initiate a dictionary with items {pointId : {cellIds}}. Using a set for cellIds leads to quick update and allows union properties of sets.

numOfPoints = mesh.n_points
meshPointIds = range(numOfPoints)
meshCells = mesh.faces.reshape(-1, 4)[:, 1:4]
pntIdCellIdDict = {pntId: set() for pntId in meshPointIds}
	for cellIndx, cell in enumerate(meshCells):
		for pntId in cell:
            pntIdCellIdDict[pntId].update({cellIndx})