问题描述
我是Python的新用户,对于从Python导出数据有疑问。我编写了使用Delaunay三角剖分创建网格的代码。对于三角剖分,我使用了matplotlib.tri库。我得到了一个网格图,现在我想保存节点和元素的坐标。所以我保存了节点列表:
import React,{ useState } from 'react';
const useForceUpdate = () => useState()[1];
const App = () => {
const forceUpdate = useForceUpdate();
console.log('rendering');
return <button onClick={forceUpdate}>Click To Render</button>;
};
现在我要保存元素,每个元素都包含两个节点,因为我考虑使用桁架元素。您有什么建议,如何将元素导出到.txt文件?
解决方法
我对您问题的最佳理解使我找到了这个答案
In [7]: import numpy as np
...: from matplotlib.tri import Triangulation
...: np.random.seed(sum(ord(c) for c in 'gboffi'))
...: x,y = [np.random.random(10) for _ in (0,0)]
...: tri = Triangulation(x,y)
...: print(tri.edges)
[[1 0]
[2 1]
[4 0]
[4 1]
[5 0]
[5 1]
[5 2]
[6 0]
[6 3]
[6 4]
[7 3]
[7 4]
[7 6]
[8 1]
[8 2]
[8 4]
[8 7]
[9 0]
[9 3]
[9 6]]
In [8]:
这是您想要的吗?
PS,我已经读到您的隐藏评论:Abaqus / CAE具有更好的网格划分支持。