I am writing a training routine for a graph neural network (GNN) which uses a finite element mesh as the basis of the graph. This data is stored as a .vtu file with some DataArray features that should be captured in the feature vector for each vertex (in my case, this happens to be features like velocity and pressure). I wanted to represent it as a torch_geometric Data object for easy training. The cells represent vertices in the graph. Two vertices are connected by an edge iff. they share a face. The corresponding edge attribute is naturally the displacement vector between the two cells. I have tried using PyVista to loop through each cell, find its adjacency list, and then add this information to the edge_index representation of the graph e.g. for idx in range(mesh.n_cells): neighbors = mesh.cell_neighbors(idx, 'faces') for n in neighbors: edge_index[0, idx] = idx edge_index[1, idx] = n However, this has proven to be very slow - I suspect due to the cell_neighbors() function converting between C++ and Python repeatedly. Is there a way to easily and quickly convert between a .vtu file and a torch_geometric Data object? Ideally the method would run in parallel for use on extremely large meshes. Continue reading...