Cannot open .xdmf files in legacy version of fenics + latest Paraview

Any help would be much appreciated as I cannot get this to work no matter what. I am running FEniCS 2019.1.0 (legacy latest version) in ubuntu 22.04.01 with anaconda. I installed using conda-forge in the ubuntu terminal.

Whenever I try to open a .xdmf file in any version of Paraview (tried numerous versions), Paraview crashes using the XDMFReaderS or T options, and doesn’t crash with just XDMFReader - but produces this error when I hit apply:

ERROR: In vtkXdmfReader.cxx, line 487
vtkXdmfReader (00000282C61832C0): Failed to read data.

ERROR: In vtkExecutive.cxx, line 741
vtkPVCompositeDataPipeline (00000282C580C470): Algorithm vtkFileSeriesReader (00000282D4036890) returned failure for request: vtkInformation (00000282FC6AE360)
Debug: Off
Modified Time: 420096
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
FORWARD_DIRECTION: 0
ALGORITHM_AFTER_FORWARD: 1
FROM_OUTPUT_PORT: 0

ERROR: In vtkXdmfReader.cxx, line 487
vtkXdmfReader (00000282FE17C690): Failed to read data.

ERROR: In vtkExecutive.cxx, line 741
vtkPVCompositeDataPipeline (00000282FD1E4E50): Algorithm vtkFileSeriesReader (00000282FC902380) returned failure for request: vtkInformation (00000282FDDD6AC0)
Debug: Off
Modified Time: 1145751
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
FORWARD_DIRECTION: 0
ALGORITHM_AFTER_FORWARD: 1
FROM_OUTPUT_PORT: 0

Here is my MWE:

from fenics import *

mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, “Lagrange”, 1)

def boundary(x):
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

u = TrialFunction(V)
v = TestFunction(V)
f = Expression(“10exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
g = Expression("sin(5
x[0])”, degree=2)
a = inner(grad(u), grad(v))dx
L = f
vdx + gv*ds

u = Function(V)
solve(a == L, u, bc)

file = File(“poisson.pvd”)
file << u

poissonfile = XDMFFile(“poissonFile.xdmf”)
poissonfile.write(u)

I have tried many different programs with xdmf files and all do the same issue. PVDs work fine. Please can anyone help?

Please post the contents of the XDMFFile?

Additionally, could you use ascii encoding and add the output of your xdmf file, i.e.

encoding = XDMFFile.Encoding.ASCII
file = XDMFFile("poissonFile.xdmf")
file.write(u,encoding=encoding)

Dokken, thank you very much. That made it work and I can now open and view it after hours of banging my head at this problem.

I wouldnt call it a solution. It was supposed to help debugging the code.

Using ascii will slow down the code in parallel.

Probably, as it is related to xdmf with h5 encoding, it was adressed at https://bitbucket.org/fenics-project/dolfin/commits/6fbc9fb8e1272c4cdd73d7e2e432dc29ebfe03ac
and
backport xdmf+boost patch (#169) · conda-forge/fenics-feedstock@3ea2183 · GitHub

I see, thanks. I am not sure how to upload the contents of the xdmf file with the ascii encoding here. Is this patch able to be applied to legacy fenics 2019.1.0?

This patch is for 2019.1.0 (the one on fenics-feedstock).

Ascii encoding is plaintext, simply open the xdmf file in a text editor, and copy the content of the file here, encapsulated with 3x`, i.e.

```
add contents here
```

Thats great thanks for the patch. Here is the file contents - I reduced the mesh to 14x14 to make the file shorter to be able to post here.

<?xml version="1.0"?>
<Xdmf Version="3.0">
  <Domain>
    <Grid Name="mesh" GridType="Uniform">
      <Topology NumberOfElements="392" TopologyType="Triangle" NodesPerElement="3">
        <DataItem Dimensions="392 3" NumberType="UInt" Format="XML">0 1 16
0 15 16
1 2 17
1 16 17
2 3 18
2 17 18
3 4 19
3 18 19
4 5 20
4 19 20
5 6 21
5 20 21
6 7 22
6 21 22
7 8 23
7 22 23
8 9 24
8 23 24
9 10 25
9 24 25
10 11 26
10 25 26
11 12 27
11 26 27
12 13 28
12 27 28
13 14 29
13 28 29
15 16 31
15 30 31
16 17 32
16 31 32
17 18 33
17 32 33
18 19 34
18 33 34
19 20 35
19 34 35
20 21 36
20 35 36
21 22 37
21 36 37
22 23 38
22 37 38
23 24 39
23 38 39
24 25 40
24 39 40
25 26 41
25 40 41
26 27 42
26 41 42
27 28 43
27 42 43
28 29 44
28 43 44
30 31 46
30 45 46
31 32 47
31 46 47
32 33 48
32 47 48
33 34 49
33 48 49
34 35 50
34 49 50
35 36 51
35 50 51
36 37 52
36 51 52
37 38 53
37 52 53
38 39 54
38 53 54
39 40 55
39 54 55
40 41 56
40 55 56
41 42 57
41 56 57
42 43 58
42 57 58
43 44 59
43 58 59
45 46 61
45 60 61
46 47 62
46 61 62
47 48 63
47 62 63
48 49 64
48 63 64
49 50 65
49 64 65
50 51 66
50 65 66
51 52 67
51 66 67
52 53 68
52 67 68
53 54 69
53 68 69
54 55 70
54 69 70
55 56 71
55 70 71
56 57 72
56 71 72
57 58 73
57 72 73
58 59 74
58 73 74
60 61 76
60 75 76
61 62 77
61 76 77
62 63 78
62 77 78
63 64 79
63 78 79
64 65 80
64 79 80
65 66 81
65 80 81
66 67 82
66 81 82
67 68 83
67 82 83
68 69 84
68 83 84
69 70 85
69 84 85
70 71 86
70 85 86
71 72 87
71 86 87
72 73 88
72 87 88
73 74 89
73 88 89
75 76 91
75 90 91
76 77 92
76 91 92
77 78 93
77 92 93
78 79 94
78 93 94
79 80 95
79 94 95
80 81 96
80 95 96
81 82 97
81 96 97
82 83 98
82 97 98
83 84 99
83 98 99
84 85 100
84 99 100
85 86 101
85 100 101
86 87 102
86 101 102
87 88 103
87 102 103
88 89 104
88 103 104
90 91 106
90 105 106
91 92 107
91 106 107
92 93 108
92 107 108
93 94 109
93 108 109
94 95 110
94 109 110
95 96 111
95 110 111
96 97 112
96 111 112
97 98 113
97 112 113
98 99 114
98 113 114
99 100 115
99 114 115
100 101 116
100 115 116
101 102 117
101 116 117
102 103 118
102 117 118
103 104 119
103 118 119
105 106 121
105 120 121
106 107 122
106 121 122
107 108 123
107 122 123
108 109 124
108 123 124
109 110 125
109 124 125
110 111 126
110 125 126
111 112 127
111 126 127
112 113 128
112 127 128
113 114 129
113 128 129
114 115 130
114 129 130
115 116 131
115 130 131
116 117 132
116 131 132
117 118 133
117 132 133
118 119 134
118 133 134
120 121 136
120 135 136
121 122 137
121 136 137
122 123 138
122 137 138
123 124 139
123 138 139
124 125 140
124 139 140
125 126 141
125 140 141
126 127 142
126 141 142
127 128 143
127 142 143
128 129 144
128 143 144
129 130 145
129 144 145
130 131 146
130 145 146
131 132 147
131 146 147
132 133 148
132 147 148
133 134 149
133 148 149
135 136 151
135 150 151
136 137 152
136 151 152
137 138 153
137 152 153
138 139 154
138 153 154
139 140 155
139 154 155
140 141 156
140 155 156
141 142 157
141 156 157
142 143 158
142 157 158
143 144 159
143 158 159
144 145 160
144 159 160
145 146 161
145 160 161
146 147 162
146 161 162
147 148 163
147 162 163
148 149 164
148 163 164
150 151 166
150 165 166
151 152 167
151 166 167
152 153 168
152 167 168
153 154 169
153 168 169
154 155 170
154 169 170
155 156 171
155 170 171
156 157 172
156 171 172
157 158 173
157 172 173
158 159 174
158 173 174
159 160 175
159 174 175
160 161 176
160 175 176
161 162 177
161 176 177
162 163 178
162 177 178
163 164 179
163 178 179
165 166 181
165 180 181
166 167 182
166 181 182
167 168 183
167 182 183
168 169 184
168 183 184
169 170 185
169 184 185
170 171 186
170 185 186
171 172 187
171 186 187
172 173 188
172 187 188
173 174 189
173 188 189
174 175 190
174 189 190
175 176 191
175 190 191
176 177 192
176 191 192
177 178 193
177 192 193
178 179 194
178 193 194
180 181 196
180 195 196
181 182 197
181 196 197
182 183 198
182 197 198
183 184 199
183 198 199
184 185 200
184 199 200
185 186 201
185 200 201
186 187 202
186 201 202
187 188 203
187 202 203
188 189 204
188 203 204
189 190 205
189 204 205
190 191 206
190 205 206
191 192 207
191 206 207
192 193 208
192 207 208
193 194 209
193 208 209
195 196 211
195 210 211
196 197 212
196 211 212
197 198 213
197 212 213
198 199 214
198 213 214
199 200 215
199 214 215
200 201 216
200 215 216
201 202 217
201 216 217
202 203 218
202 217 218
203 204 219
203 218 219
204 205 220
204 219 220
205 206 221
205 220 221
206 207 222
206 221 222
207 208 223
207 222 223
208 209 224
208 223 224
</DataItem>
      </Topology>
      <Geometry GeometryType="XY">
        <DataItem Dimensions="225 2" Format="XML">0 0
0.07142857142857142 0
0.1428571428571428 0
0.2142857142857143 0
0.2857142857142857 0
0.3571428571428572 0
0.4285714285714285 0
0.5 0
0.5714285714285714 0
0.6428571428571429 0
0.7142857142857143 0
0.7857142857142857 0
0.8571428571428571 0
0.9285714285714286 0
1 0
0 0.07142857142857142
0.07142857142857142 0.07142857142857142
0.1428571428571428 0.07142857142857142
0.2142857142857143 0.07142857142857142
0.2857142857142857 0.07142857142857142
0.3571428571428572 0.07142857142857142
0.4285714285714285 0.07142857142857142
0.5 0.07142857142857142
0.5714285714285714 0.07142857142857142
0.6428571428571429 0.07142857142857142
0.7142857142857143 0.07142857142857142
0.7857142857142857 0.07142857142857142
0.8571428571428571 0.07142857142857142
0.9285714285714286 0.07142857142857142
1 0.07142857142857142
0 0.1428571428571428
0.07142857142857142 0.1428571428571428
0.1428571428571428 0.1428571428571428
0.2142857142857143 0.1428571428571428
0.2857142857142857 0.1428571428571428
0.3571428571428572 0.1428571428571428
0.4285714285714285 0.1428571428571428
0.5 0.1428571428571428
0.5714285714285714 0.1428571428571428
0.6428571428571429 0.1428571428571428
0.7142857142857143 0.1428571428571428
0.7857142857142857 0.1428571428571428
0.8571428571428571 0.1428571428571428
0.9285714285714286 0.1428571428571428
1 0.1428571428571428
0 0.2142857142857143
0.07142857142857142 0.2142857142857143
0.1428571428571428 0.2142857142857143
0.2142857142857143 0.2142857142857143
0.2857142857142857 0.2142857142857143
0.3571428571428572 0.2142857142857143
0.4285714285714285 0.2142857142857143
0.5 0.2142857142857143
0.5714285714285714 0.2142857142857143
0.6428571428571429 0.2142857142857143
0.7142857142857143 0.2142857142857143
0.7857142857142857 0.2142857142857143
0.8571428571428571 0.2142857142857143
0.9285714285714286 0.2142857142857143
1 0.2142857142857143
0 0.2857142857142857
0.07142857142857142 0.2857142857142857
0.1428571428571428 0.2857142857142857
0.2142857142857143 0.2857142857142857
0.2857142857142857 0.2857142857142857
0.3571428571428572 0.2857142857142857
0.4285714285714285 0.2857142857142857
0.5 0.2857142857142857
0.5714285714285714 0.2857142857142857
0.6428571428571429 0.2857142857142857
0.7142857142857143 0.2857142857142857
0.7857142857142857 0.2857142857142857
0.8571428571428571 0.2857142857142857
0.9285714285714286 0.2857142857142857
1 0.2857142857142857
0 0.3571428571428572
0.07142857142857142 0.3571428571428572
0.1428571428571428 0.3571428571428572
0.2142857142857143 0.3571428571428572
0.2857142857142857 0.3571428571428572
0.3571428571428572 0.3571428571428572
0.4285714285714285 0.3571428571428572
0.5 0.3571428571428572
0.5714285714285714 0.3571428571428572
0.6428571428571429 0.3571428571428572
0.7142857142857143 0.3571428571428572
0.7857142857142857 0.3571428571428572
0.8571428571428571 0.3571428571428572
0.9285714285714286 0.3571428571428572
1 0.3571428571428572
0 0.4285714285714285
0.07142857142857142 0.4285714285714285
0.1428571428571428 0.4285714285714285
0.2142857142857143 0.4285714285714285
0.2857142857142857 0.4285714285714285
0.3571428571428572 0.4285714285714285
0.4285714285714285 0.4285714285714285
0.5 0.4285714285714285
0.5714285714285714 0.4285714285714285
0.6428571428571429 0.4285714285714285
0.7142857142857143 0.4285714285714285
0.7857142857142857 0.4285714285714285
0.8571428571428571 0.4285714285714285
0.9285714285714286 0.4285714285714285
1 0.4285714285714285
0 0.5
0.07142857142857142 0.5
0.1428571428571428 0.5
0.2142857142857143 0.5
0.2857142857142857 0.5
0.3571428571428572 0.5
0.4285714285714285 0.5
0.5 0.5
0.5714285714285714 0.5
0.6428571428571429 0.5
0.7142857142857143 0.5
0.7857142857142857 0.5
0.8571428571428571 0.5
0.9285714285714286 0.5
1 0.5
0 0.5714285714285714
0.07142857142857142 0.5714285714285714
0.1428571428571428 0.5714285714285714
0.2142857142857143 0.5714285714285714
0.2857142857142857 0.5714285714285714
0.3571428571428572 0.5714285714285714
0.4285714285714285 0.5714285714285714
0.5 0.5714285714285714
0.5714285714285714 0.5714285714285714
0.6428571428571429 0.5714285714285714
0.7142857142857143 0.5714285714285714
0.7857142857142857 0.5714285714285714
0.8571428571428571 0.5714285714285714
0.9285714285714286 0.5714285714285714
1 0.5714285714285714
0 0.6428571428571429
0.07142857142857142 0.6428571428571429
0.1428571428571428 0.6428571428571429
0.2142857142857143 0.6428571428571429
0.2857142857142857 0.6428571428571429
0.3571428571428572 0.6428571428571429
0.4285714285714285 0.6428571428571429
0.5 0.6428571428571429
0.5714285714285714 0.6428571428571429
0.6428571428571429 0.6428571428571429
0.7142857142857143 0.6428571428571429
0.7857142857142857 0.6428571428571429
0.8571428571428571 0.6428571428571429
0.9285714285714286 0.6428571428571429
1 0.6428571428571429
0 0.7142857142857143
0.07142857142857142 0.7142857142857143
0.1428571428571428 0.7142857142857143
0.2142857142857143 0.7142857142857143
0.2857142857142857 0.7142857142857143
0.3571428571428572 0.7142857142857143
0.4285714285714285 0.7142857142857143
0.5 0.7142857142857143
0.5714285714285714 0.7142857142857143
0.6428571428571429 0.7142857142857143
0.7142857142857143 0.7142857142857143
0.7857142857142857 0.7142857142857143
0.8571428571428571 0.7142857142857143
0.9285714285714286 0.7142857142857143
1 0.7142857142857143
0 0.7857142857142857
0.07142857142857142 0.7857142857142857
0.1428571428571428 0.7857142857142857
0.2142857142857143 0.7857142857142857
0.2857142857142857 0.7857142857142857
0.3571428571428572 0.7857142857142857
0.4285714285714285 0.7857142857142857
0.5 0.7857142857142857
0.5714285714285714 0.7857142857142857
0.6428571428571429 0.7857142857142857
0.7142857142857143 0.7857142857142857
0.7857142857142857 0.7857142857142857
0.8571428571428571 0.7857142857142857
0.9285714285714286 0.7857142857142857
1 0.7857142857142857
0 0.8571428571428571
0.07142857142857142 0.8571428571428571
0.1428571428571428 0.8571428571428571
0.2142857142857143 0.8571428571428571
0.2857142857142857 0.8571428571428571
0.3571428571428572 0.8571428571428571
0.4285714285714285 0.8571428571428571
0.5 0.8571428571428571
0.5714285714285714 0.8571428571428571
0.6428571428571429 0.8571428571428571
0.7142857142857143 0.8571428571428571
0.7857142857142857 0.8571428571428571
0.8571428571428571 0.8571428571428571
0.9285714285714286 0.8571428571428571
1 0.8571428571428571
0 0.9285714285714286
0.07142857142857142 0.9285714285714286
0.1428571428571428 0.9285714285714286
0.2142857142857143 0.9285714285714286
0.2857142857142857 0.9285714285714286
0.3571428571428572 0.9285714285714286
0.4285714285714285 0.9285714285714286
0.5 0.9285714285714286
0.5714285714285714 0.9285714285714286
0.6428571428571429 0.9285714285714286
0.7142857142857143 0.9285714285714286
0.7857142857142857 0.9285714285714286
0.8571428571428571 0.9285714285714286
0.9285714285714286 0.9285714285714286
1 0.9285714285714286
0 1
0.07142857142857142 1
0.1428571428571428 1
0.2142857142857143 1
0.2857142857142857 1
0.3571428571428572 1
0.4285714285714285 1
0.5 1
0.5714285714285714 1
0.6428571428571429 1
0.7142857142857143 1
0.7857142857142857 1
0.8571428571428571 1
0.9285714285714286 1
1 1
</DataItem>
      </Geometry>
      <Attribute Name="f_9" AttributeType="Scalar" Center="Node">
        <DataItem Dimensions="225 1" Format="XML">0
0.09370228609759618
0.1780013147464425
0.2445401281439827
0.2869377850603337
0.3015140433289596
0.2877618206583519
0.248536039743258
0.1898876432832188
0.1204544916443629
0.05046948820368251
-0.009281447478906758
-0.04791180692856932
-0.05277307820995598
0
0
0.07369729344261501
0.1405861789432085
0.194569338485314
0.2308906370123113
0.2466326252217233
0.2410787045849454
0.2159521350437466
0.1754473017384074
0.1258631008804773
0.0748027087105025
0.03020937778229468
-0.0004608998560315762
-0.01108966619774169
0
0
0.06050070682028275
0.1160767396762034
0.1622601485605296
0.1954214321243086
0.2130428389754783
0.2139601458634453
0.1987371435365681
0.1700796687582574
0.1327449579163033
0.09266805671929293
0.05577701022892671
0.02694848099145147
0.008875312287706227
0
0
0.0522287647400534
0.1009594991867803
0.1429694408259687
0.175473390345903
0.1960989907855366
0.2028715945400295
0.1948279709804447
0.1732963365216154
0.1423272123036193
0.1073358217962907
0.07328007352952129
0.04360227843423039
0.01964241942867661
0
0
0.0474545916719266
0.09255940837457183
0.1331541441289751
0.167248099266254
0.192525005441148
0.2056775696776024
0.20331940324663
0.185152786572111
0.155566592215599
0.1209635781653732
0.0863865986585073
0.05453608789412575
0.02609194746808203
0
0
0.04502882641551554
0.0886506849075932
0.1296840296675619
0.1670498703744435
0.1986123399363471
0.219250685188927
0.2219448650723272
0.2041948392837152
0.1718481310352802
0.1339899994279286
0.09666228857765291
0.06205179879053474
0.03018847129326326
0
0
0.04400575209734364
0.08727231326582405
0.1293982854196483
0.1701919905287591
0.2078768698647308
0.2356538291499414
0.2426373288802595
0.2238636419263901
0.1869958903852202
0.1445113391473958
0.1038556166689722
0.06677855439353063
0.03260719540210306
0
0
0.04371377715552038
0.08692422882195132
0.1295231073633594
0.1716993461625384
0.2119351829243851
0.2428862692791035
0.2519747576456155
0.2328473809021134
0.1937905169030622
0.1489698750865777
0.10667257708528
0.06850667139237744
0.03345509693368886
0
0
0.04391577713097913
0.0870590640027229
0.1289831629723636
0.1694726831496157
0.2069010427013904
0.2348690856697084
0.2426373288802592
0.2246483854066229
0.1879717175485602
0.1452306465265387
0.1042707391162567
0.06699180365663164
0.03269717036846751
0
0
0.04488360837774366
0.08832015176546247
0.1290800899017271
0.1660732057412865
0.1973572865331
0.2182725735638284
0.2219448650723269
0.2051729509088133
0.1731031844385268
0.1349666640610853
0.09726622834348739
0.06238233193266526
0.03033368933103503
0
0
0.04729556110219982
0.09221605177608988
0.1325786983631272
0.1664081025946904
0.191537121297237
0.2049491244514261
0.2033194032466295
0.1858812317982866
0.1565544763595095
0.1218035748369362
0.08696204442435478
0.05487944449260744
0.02625097803780868
0
0
0.05208177299870319
0.1006580676484215
0.1425061827126453
0.1748680844139441
0.1954593108237186
0.2024334246771252
0.1948279709804442
0.1737345063845189
0.1429668922654365
0.1079411277282489
0.07374333164284423
0.04390370997258891
0.01978941117002669
0
0
0.06037332371950363
0.1158262112131011
0.1619012954249584
0.194994375057366
0.2126334721418998
0.2136995849808824
0.1987371435365676
0.1703402296408192
0.133154324749881
0.09309511378623489
0.05613586336449745
0.02719900945455341
0.009002695388485216
0
0
0.07358529573777167
0.1403719351885468
0.1942763608235749
0.2305629200235131
0.246338824702066
0.2409013642478021
0.2159521350437462
0.1756246420755499
0.1261569014001339
0.07513042569930009
0.03050235544403333
-0.0002466561013701914
-0.0109776684928985
0
0
0.09359592305572163
0.1777998580513011
0.2442691531325935
0.286641308254783
0.3012545988827158
0.2876082532765843
0.2485360397432576
0.1900412106649856
0.120713936090606
0.05076596500923267
-0.009010472467517967
-0.04771035023342823
-0.05266671516808159
0
</DataItem>
      </Attribute>
    </Grid>
  </Domain>
</Xdmf>

As the ascii format works, i am more interested in the content of the xdmf file if you use the hdf5 encoding. Then the file should be significantly shorter, as it should contain pointers to the h5 file.

Ah sorry. Here is what the hdf5 encoded xdmf looks like (14x14 mesh)


<?xml version="1.0"?>
<Xdmf Version="3.0">
  <Domain>
    <Grid Name="mesh" GridType="Uniform">
      <Topology NumberOfElements="392" TopologyType="Triangle" NodesPerElement="3">
        <DataItem Dimensions="392 3" NumberType="UInt" Format="HDF">poissonFile.h5</DataItem>
      </Topology>
      <Geometry GeometryType="XY">
        <DataItem Dimensions="225 2" Format="HDF">poissonFile.h5</DataItem>
      </Geometry>
      <Attribute Name="f_9" AttributeType="Scalar" Center="Node">
        <DataItem Dimensions="225 1" Format="HDF">poissonFile.h5</DataItem>
      </Attribute>
    </Grid>
  </Domain>
</Xdmf>



The issue is here, there should be something appended after .h5, which is what

is resolving.

Thank you very much for your help, appreciate it.