Generate quad mesh or convert abaqus mesh to use in FEniCS

There is a workaround. You can follow my short tutorial:
Here is the mesh based on what you have provided as a geo file:

Save it as a MSH format. Then you can open it in excel. You need to modify it 2 times. First for the nodes and secondly for the elements and save them separately as text files. You need to keep only the nodes (or element) numbers and also the coordinates of the nodes in these two files. Please be aware that you need to delete everything else in these files. For example for the nodes you will have this (nodes.txt):

1 0 0
2 1 0
3 1 1
4 0 1
5 0.1111111111 0
6 0.2222222222 0
7 0.3333333333 0
8 0.4444444444 0
9 0.5555555556 0
10 0.6666666667 0
11 0.7777777778 0
12 0.8888888889 0
13 1 0.1111111111
14 1 0.2222222222
15 1 0.3333333333
16 1 0.4444444444
17 1 0.5555555556
18 1 0.6666666667
19 1 0.7777777778
20 1 0.8888888889
21 0.8888888889 1
22 0.7777777778 1
23 0.6666666667 1
24 0.5555555556 1
25 0.4444444444 1
26 0.3333333333 1
27 0.2222222222 1
28 0.1111111111 1
29 0 0.8888888889
30 0 0.7777777778
31 0 0.6666666667
32 0 0.5555555556
33 0 0.4444444444
34 0 0.3333333333
35 0 0.2222222222
36 0 0.1111111111
37 0.8888888889 0.8888888889
38 0.8888888889 0.7777777778
39 0.8888888889 0.6666666667
40 0.8888888889 0.5555555556
41 0.8888888889 0.4444444444
42 0.8888888889 0.3333333333
43 0.8888888889 0.2222222222
44 0.8888888889 0.1111111111
45 0.7777777778 0.8888888889
46 0.7777777778 0.7777777778
47 0.7777777778 0.6666666667
48 0.7777777778 0.5555555556
49 0.7777777778 0.4444444444
50 0.7777777778 0.3333333333
51 0.7777777778 0.2222222222
52 0.7777777778 0.1111111111
53 0.6666666667 0.8888888889
54 0.6666666667 0.7777777778
55 0.6666666667 0.6666666667
56 0.6666666667 0.5555555556
57 0.6666666667 0.4444444444
58 0.6666666667 0.3333333333
59 0.6666666667 0.2222222222
60 0.6666666667 0.1111111111
61 0.5555555556 0.8888888889
62 0.5555555556 0.7777777778
63 0.5555555556 0.6666666667
64 0.5555555556 0.5555555556
65 0.5555555556 0.4444444444
66 0.5555555556 0.3333333333
67 0.5555555556 0.2222222222
68 0.5555555556 0.1111111111
69 0.4444444444 0.8888888889
70 0.4444444444 0.7777777778
71 0.4444444444 0.6666666667
72 0.4444444444 0.5555555556
73 0.4444444444 0.4444444444
74 0.4444444444 0.3333333333
75 0.4444444444 0.2222222222
76 0.4444444444 0.1111111111
77 0.3333333333 0.8888888889
78 0.3333333333 0.7777777778
79 0.3333333333 0.6666666667
80 0.3333333333 0.5555555556
81 0.3333333333 0.4444444444
82 0.3333333333 0.3333333333
83 0.3333333333 0.2222222222
84 0.3333333333 0.1111111111
85 0.2222222222 0.8888888889
86 0.2222222222 0.7777777778
87 0.2222222222 0.6666666667
88 0.2222222222 0.5555555556
89 0.2222222222 0.4444444444
90 0.2222222222 0.3333333333
91 0.2222222222 0.2222222222
92 0.2222222222 0.1111111111
93 0.1111111111 0.8888888889
94 0.1111111111 0.7777777778
95 0.1111111111 0.6666666667
96 0.1111111111 0.5555555556
97 0.1111111111 0.4444444444
98 0.1111111111 0.3333333333
99 0.1111111111 0.2222222222
100 0.1111111111 0.1111111111

For the elements, you should consider only the element start with number.3 in the second column in the msh file. (Number 3 correspond to the quad elements) and delete everything else. Here is the text file for the elements (element.txt):

41 3 21 37 20
42 20 37 38 19
43 19 38 39 18
44 18 39 40 17
45 17 40 41 16
46 16 41 42 15
47 15 42 43 14
48 14 43 44 13
49 13 44 12 2
50 21 22 45 37
51 37 45 46 38
52 38 46 47 39
53 39 47 48 40
54 40 48 49 41
55 41 49 50 42
56 42 50 51 43
57 43 51 52 44
58 44 52 11 12
59 22 23 53 45
60 45 53 54 46
61 46 54 55 47
62 47 55 56 48
63 48 56 57 49
64 49 57 58 50
65 50 58 59 51
66 51 59 60 52
67 52 60 10 11
68 23 24 61 53
69 53 61 62 54
70 54 62 63 55
71 55 63 64 56
72 56 64 65 57
73 57 65 66 58
74 58 66 67 59
75 59 67 68 60
76 60 68 9 10
77 24 25 69 61
78 61 69 70 62
79 62 70 71 63
80 63 71 72 64
81 64 72 73 65
82 65 73 74 66
83 66 74 75 67
84 67 75 76 68
85 68 76 8 9
86 25 26 77 69
87 69 77 78 70
88 70 78 79 71
89 71 79 80 72
90 72 80 81 73
91 73 81 82 74
92 74 82 83 75
93 75 83 84 76
94 76 84 7 8
95 26 27 85 77
96 77 85 86 78
97 78 86 87 79
98 79 87 88 80
99 80 88 89 81
100 81 89 90 82
101 82 90 91 83
102 83 91 92 84
103 84 92 6 7
104 27 28 93 85
105 85 93 94 86
106 86 94 95 87
107 87 95 96 88
108 88 96 97 89
109 89 97 98 90
110 90 98 99 91
111 91 99 100 92
112 92 100 5 6
113 28 4 29 93
114 93 29 30 94
115 94 30 31 95
116 95 31 32 96
117 96 32 33 97
118 97 33 34 98
119 98 34 35 99
120 99 35 36 100
121 100 36 1 5

Then you can run this code to generate a meshfile:

file = open('meshfile.py', 'w')

file.write('from dolfin import *;\n')
file.write('mesh = Mesh();\n')
file.write('editor = MeshEditor();\n')
file.write("editor.open(mesh,'quadrilateral', 2, 2);\n")
file.write('editor.init_vertices(100);\n')   #100 is number of nodes
file.write('editor.init_cells(121);\n')        # 121 is number of elements

file.close()

lines = [line.rstrip('\n') for line in open('nodes.txt')]
output = open('meshfile.py', 'a')

for line in lines:
    line = line.split()
    line[0] = int(line[0]) - 1

    output.write('editor.add_vertex({},{},{});\n'.format(line[0], line[1], line[2]))

output.close()

lines = [line.rstrip('\n') for line in open('element.txt')]
output = open('meshfile.py', 'a')

for line in lines:
    line = line.split()
    line[0] = int(line[0]) - 41  # 41 is the number of the first element in the element.txt file

    for i in range (1,5):

        line[i] =int(line[i]) - 1

    output.write('editor.add_cell({},{},{},{},{});\n'.format(line[0], line[1], line[2], line[4], line[3]))

output.close()

file = open('meshfile.py', 'a')

file.write('editor.close()\n')
file.write("File('mesh.pvd') << mesh\n")
file.close()

So you can open the meshfile and simply run it. It creates a mesh which is readable for FEniCS. If you open the mesh.pvd, here is what you can see:

fenics

Which is the same mesh in GMSH!

1 Like