0

I wrote a finite element code in fortran 90.

This code is really fast, except the meshing process.

I used triangle and tetgen for meshing in 2D and 3D, respectively, so this process is fast, of course.

For example, for the unit square [0,1]x[0,1] in 2D I have a file with the coordinates of its nodes (for example, a mesh with 5 nodes):

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

called coordinate.dat, which have 4 elements (triangles) with nodes called 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 also have a file where each row i is the number of its initial an final node, called 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

With this files, I need to generate the following information:

(1) Given an element (triangle or tetrahedron), I need to know the number of its sides (edges and faces, respectively). For example, I need to generate the following structure or file, called 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) Furthermore, given a side (edge or face) I need to know the element numbers of the 2 elements (or only one if the side is on the boundary) shared by that side. For example, I need to generate the following structure (or file) called 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

For both of these structures, struct1.dat and struct2.dat, my code is very slow because I used a brute force approach with a lot of loops..

I am looking for an algorithm (a paper, or better: a subroutine in fortran available for download) optimized for this? I want to continue using triangle and tetgen, but I am willing to listen to other options.

user106306
  • 315
  • 2
  • 10
  • In my opinion, this question is too broad - I don't think we'll be able to help you. But perhaps other people disagree and can share their advice. – Ross Oct 30 '15 at 02:53
  • Thanks for your comment @Ross. I agree with you, the question is broad, but I think that is a usual question in a implementation of a finite element code (obviously, is only my opinion). I added an example in my question to clarify it. – user106306 Oct 30 '15 at 03:53
  • 1
    As a rule of thumb, if you don't have an issue with some actual piece of code you can post, you should probably find a different place to ask. Of course, there are exceptions. Maybe http://scicomp.stackexchange.com could be more suitable. – Vladimir F Героям слава Oct 30 '15 at 13:59
  • Thanks @VladimirF . I rewrote this question on scicomp: http://scicomp.stackexchange.com/questions/21163/meshing-options-to-generate-number-of-the-sides-of-and-element-tetgen-triangle Are there any problem rewriting the question there? Or I must to delete one of them? – user106306 Oct 30 '15 at 14:09
  • I don't know, but I doubt you will get a better answer here, the other one should suffice. – Vladimir F Героям слава Oct 30 '15 at 14:36
  • The general problem of automatic meshing in 2D and 3D has been worked on since the 1980s. I'd recommend that you fire up Google to learn what's available. Most vendors appear to have robust automatic meshing features build into their graphical modeling suites. – duffymo Nov 13 '15 at 15:53

0 Answers0