从列表和顺序i中提取数据

2021-10-17 14:57:28 发布

您现在位置:Python中文网/ 问答频道 /正文

问题陈述:

I have a finite element mesh made of two noded finite elements (so each finite element (line) is made of two nodes located in its extremeties). I have several types of components (groups of finite elements) in the mesh. So for example a vertical component is made up of several finite elements aligned vertically from bottom to top, and adjacent finite elements share a common node.

I need to get a list of lists where each list has the node IDs (node numbers) of each vertical component, ordered from bottom to top.

我所拥有的: 我有两个列表:nodeselementsnodeselements具有以下结构:

nodes = [[node_ID1, X1, Y1, Z1],[node_ID2, X2, Y2, Z2], ...]]
elements = [[element_ID1, nodeID_a, nodeID_b],[element_ID2, nodeID_b, nodeID_c], ...]]

我还有另外两个名为nodesVelementsV的列表列表,分别表示节点和元素的子集示例:

nodesV = [[node_IDa, node_IDb, node_IDc],[ ....]]
elementsV = [[element_IDa, element_IDb, element_IDc],[ ....]]

这两个列表分别表示所有垂直组件的节点和元素。你知道吗

我需要的是: 基于上述数据,我需要构建一个列表列表,其中每个列表包含每个垂直组件的有序节点ID:

desired_list = [[first nodeID of vertical component 1, ...., last nodeID],[first nodeID of vertical component 2, ...., last nodeID], ...]]

示例: 假设网格中只有两个组件,每个组件仅由单个元素组成,其中一个是垂直的:

nodes = [[1, 0, 0, 0], [2, 1, 0, 0], [3, 1, 0, 1]]
elements = [[1, 1, 2], [2, 1, 3]]

nodesV = [[1,3]] #each list can only contain 16 elements
elementsV = [[2]]

所以desired_list = [[1,3]]

有没有办法在几千个节点的网格上实现这一点?你知道吗