0

我用 fortran 90 写了一个有限元代码。

这段代码真的很快,除了网格划分过程。

我分别使用三角形tetgen进行 2D 和 3D 网格划分,所以这个过程当然很快。

例如,对于 2D 中的单位正方形 [0,1]x[0,1],我有一个文件,其中包含其节点的坐标(例如,具有 5 个节点的网格):

1   0.0 0.0  # coordinates of node 1
2   1.0 0.0  # coordinates of node 2
3   1.0 1.0  # coordinates of node 3
4   0.0 1.0  # coordinates of node 4
5   0.5 0.5  # coordinates of node 5

称为coordinate.dat,它有 4 个元素(三角形),节点称为element.dat

1   1 5 4  # vertices of triangle 1
2   1 2 5  # vertices of triangle 2
3   2 3 5  # vertices of triangle 3
4   5 2 4  # vertices of triangle 4

我还有一个文件,其中每一行i是其初始的最终节点的编号,称为edge.dat

1   1 2  # initial and final node of edge 1
2   2 3  # initial and final node of edge 2
3   3 4  # initial and final node of edge 3
4   4 1  # initial and final node of edge 4
5   1 5  # initial and final node of edge 5
6   5 2  # initial and final node of edge 6
7   2 5  # initial and final node of edge 7
8   5 4  # initial and final node of edge 8

使用这些文件,我需要生成以下信息:

(1) 给定一个元素(三角形或四面体),我需要知道它的边数(分别为边和面)。例如,我需要生成以下结构或文件,称为struct1.dat

1   5 8 4  # triangle 1 has the edges number 5, 8 and 4
2   1 6 5  # triangle 2 has the edges number 1, 6 and 5
3   6 2 7  # triangle 2 has the edges number 6, 2 and 7
4   7 3 8  # triangle 4 has the edges number 7, 3 and 8

(2) 此外,给定一条边(边或面),我需要知道该边共享的 2 个元素(如果边在边界上,则只有一个)的元素编号。例如,我需要生成以下结构(或文件),称为struct2.dat

1   2 0  # edge number 1 is only on element 2
2   3 0  # edge number 2 is only on element 3
3   4 0  # edge number 3 is only on element 4
4   1 0  # edge number 4 is only on element 1
5   1 2  # edge number 5 is sharing by elements 1 and 2
6   3 2  # edge number 6 is sharing by elements 3 and 2
7   4 3  # edge number 7 is sharing by elements 4 and 3
8   1 4  # edge number 8 is sharing by elements 1 and 4

对于这两种结构struct1.datstruct2.dat,我的代码非常慢,因为我使用了带有很多循环的蛮力方法。

我正在寻找一种为此优化的算法(一篇论文,或者更好的:fortran 中的一个子程序可供下载)?我想继续使用三角形和 tetgen,但我愿意听取其他选择。

4

0 回答 0