# Saving mixed vector element as xdmf | FEniCSx 0.7.2

**URL:** <https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019>\
**Category:** Errors\
**Created:** [December 11, 2023, 2:55pm UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019 "2023-12-11T14:55:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dejanm](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dejanm/32/3633_2.png) [@dejanm](https://fenicsproject.discourse.group/u/dejanm)\
**Post date:** [December 11, 2023, 2:55pm UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019/1 "2023-12-11T14:55:00Z")

</div>

Hello everyone,

I recently upgraded from FEniCSx version 0.6.0 to 0.7.2. Now I get an error message when saving the results from a mixed functionspace as an xdmf file.

The mixed functionspace consists of vector elements and finite elements. I do not get an error message if I save only the scalar field, but the vector field. In paraview, the scalar field also looks as expected. I have tested the elements from the ufl, as well as from the basix library and both lead to this error.

Here is my code:

```auto
from dolfinx.mesh import create_unit_square
from dolfinx.fem import (Function, FunctionSpace)
from dolfinx.io import XDMFFile
from basix.ufl import (element, mixed_element)
from mpi4py import MPI

mesh = create_unit_square(MPI.COMM_WORLD, 50, 50)

u_el = element("Lagrange", mesh.basix_cell(), 1, shape=(mesh.topology.dim, )) #Vector element
p_el = element("Lagrange", mesh.basix_cell(), 1) #Finite element
V_up = FunctionSpace(mesh, mixed_element([u_el, p_el]))

U = Function(V_up)
with U.vector.localForm() as bc_local:
    bc_local.set(0.0)
u_parav, p_parav = U.split()

with XDMFFile(MPI.COMM_WORLD, "Results.xdmf", "w") as xdmf:
    xdmf.write_mesh(mesh)
    xdmf.write_function(u_parav, 0) #Results in error
    xdmf.write_function(p_parav, 0) #Works
    xdmf.close()

```

I get the following error message:

```auto
python3: /src/dolfinx/cpp/dolfinx/io/xdmf_function.cpp:140: void dolfinx::io::xdmf_function::add_function(MPI_Comm, const dolfinx::fem::Function<T, U>&, double, pugi::xml_node&, hid_t) [with T = double; U = double; MPI_Comm = int; hid_t = long int]: Assertion `dofs.size() == dofs_x.size()' failed.

Loguru caught a signal: SIGABRT
Stack trace:
27 0x56105bdf0ba5 _start + 37
26 0x7ff3e7516e40 __libc_start_main + 128
25 0x7ff3e7516d90 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7ff3e7516d90]
24 0x56105bdf0cad Py_BytesMain + 45
23 0x56105be1a41e Py_RunMain + 702
22 0x56105be27653 _PyRun_AnyFileObject + 67
21 0x56105be27a08 _PyRun_SimpleFileObject + 424
20 0x56105be28525 python3(+0x264525) [0x56105be28525]
19 0x56105be220bb python3(+0x25e0bb) [0x56105be220bb]
18 0x56105be287d8 python3(+0x2647d8) [0x56105be287d8]
17 0x56105bdfdcf6 PyEval_EvalCode + 134
16 0x56105bdfde56 python3(+0x239e56) [0x56105bdfde56]
15 0x56105bd0cf52 _PyEval_EvalFrameDefault + 2050
14 0x56105bd2470c _PyFunction_Vectorcall + 124
13 0x56105bd128a2 _PyEval_EvalFrameDefault + 24914
12 0x56105bd327bb python3(+0x16e7bb) [0x56105bd327bb]
11 0x56105bd1a5eb _PyObject_MakeTpCall + 603
10 0x56105bd23e0e python3(+0x15fe0e) [0x56105bd23e0e]
9 0x7ff3db990ae8 /usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/cpp.cpython-310-x86_64-linux-gnu.so(+0xb2ae8) [0x7ff3db990ae8]
8 0x7ff3dbad355f /usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/cpp.cpython-310-x86_64-linux-gnu.so(+0x1f555f) [0x7ff3dbad355f]
7 0x7ff3db7e8c43 void dolfinx::io::XDMFFile::write_function<double, double>(dolfinx::fem::Function<double, double> const&, double, std::string) + 995
6 0x7ff3db800b66 void dolfinx::io::xdmf_function::add_function<double, double>(int, dolfinx::fem::Function<double, double> const&, double, pugi::xml_node&, long) + 8038
5 0x7ff3e7526e96 /lib/x86_64-linux-gnu/libc.so.6(+0x39e96) [0x7ff3e7526e96]
4 0x7ff3e751571b /lib/x86_64-linux-gnu/libc.so.6(+0x2871b) [0x7ff3e751571b]
3 0x7ff3e75157f3 abort + 211
2 0x7ff3e752f476 raise + 22
1 0x7ff3e75839fc pthread_kill + 300
0 0x7ff3e752f520 /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7ff3e752f520]
2023-12-11 14:40:57.026 ( 0.090s) [main] :0 FATL| Signal: SIGABRT
Aborted

```

FEniCSx: 0.7.2 (installed via docker-container)  
Ubuntu: 22.04

Thank you in advance!

With kind regards  
Dejan

---

<div class="post-metadata">

**Author:** ![Katie](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@Katie](https://fenicsproject.discourse.group/u/Katie)\
**Post date:** [December 11, 2023, 4:31pm UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019/2 "2023-12-11T16:31:44Z")

</div>

I am also having a similar problem!

Many thanks,  
Katie

---

<div class="post-metadata">

**Author:** ![dparsons](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dparsons](https://fenicsproject.discourse.group/u/dparsons)\
**Post date:** [December 11, 2023, 6:25pm UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019/3 "2023-12-11T18:25:54Z")

</div>

I can’t reproduce that error with the debian or ubunta (PPA) packages.

```auto
$ python3 test.py 
$ ls -l 
total 260
-rw-r--r-- 1 root root 252408 Dec 11 19:23 Results.h5
-rw-r--r-- 1 root root 1504 Dec 11 19:23 Results.xdmf
-rw-r--r-- 1 root root 775 Dec 11 19:23 test.py

```

Looks like the binaries for the docker context need rebuilding.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [December 11, 2023, 7:10pm UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019/4 "2023-12-11T19:10:49Z")

</div>

> [@dejanm](#):
>
> FEniCSX: 0.7.2 (installed via docker-container)  
> Ubuntu: 22.04

What docker image are you using?

---

<div class="post-metadata">

**Author:** ![dejanm](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dejanm/32/3633_2.png) [@dejanm](https://fenicsproject.discourse.group/u/dejanm)\
**Post date:** [December 11, 2023, 8:01pm UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019/5 "2023-12-11T20:01:58Z")

</div>

The image that I used is dolfinx/dolfinx:stable.

After running the container for the first time, I also executed the following commands:

export HDF5\_MPI=“ON”  
export CC=mpicc  
export HDF5\_DIR=“/usr/lib/x86\_64-linux-gnu/hdf5/mpich/”  
pip3 install --no-cache-dir --no-binary=h5py h5py meshio  
pip3 install lxml  
pip3 install tqdm  
pip3 install pygmsh  
pip3 install matplotlib  
pip3 install pyvista  
pip3 install pyvistaqt  
pip3 install PyQt5  
pip3 install ipygany

---

<div class="post-metadata">

**Author:** ![dejanm](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dejanm/32/3633_2.png) [@dejanm](https://fenicsproject.discourse.group/u/dejanm)\
**Post date:** [December 12, 2023, 10:03am UTC](https://fenicsproject.discourse.group/t/saving-mixed-vector-element-as-xdmf-fenicsx-0-7-2/13019/6 "2023-12-12T10:03:36Z")

</div>

I just tested and the additional commands I mentioned have no influence on the error. So the error occurs even if the container is not changed.
