Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving more than one point_data using TimeSeries #1458

Open
mwenceslaucosta opened this issue Feb 23, 2024 · 1 comment
Open

Saving more than one point_data using TimeSeries #1458

mwenceslaucosta opened this issue Feb 23, 2024 · 1 comment

Comments

@mwenceslaucosta
Copy link

Hello, is it possible to use xdmf.TimeSeries to save more than one result field in the same file? I tried to use it as shown below, but when I read the file, all the data are not present.

       with meshio.xdmf.TimeSeriesWriter('out_file.XDMF') as writer:
              points = nodes
              cells = [("hexahedron", connectivity)]
              writer.write_points_cells(points,cells)
              for i in range(len(time_vector)):
                  t=time_vector[i]                 
                  writer.write_data(t, point_data={"Temperature": temperature_1[:,0]})
                  writer.write_data(t, point_data={"Qx_flux": q_all_nodes[:,0]})
                  writer.write_data(t, point_data={"Qy_flux": q_all_nodes[:,1]})
                  writer.write_data(t, point_data={"Qz_flux": q_all_nodes[:,2]})`

Note: Saving just one field in a file, "Temperature" for example, works fine.

Thank you.

@keurfonluu
Copy link
Contributor

Hi @mwenceslaucosta,

You should gather all your data in a single dict:

with meshio.xdmf.TimeSeriesWriter('out_file.XDMF') as writer:
    points = nodes
    cells = [("hexahedron", connectivity)]
    writer.write_points_cells(points,cells)
    for i in range(len(time_vector)):
        t=time_vector[i]                 
        writer.write_data(t, point_data={
            "Temperature": temperature_1[:,0],
            "Qx_flux": q_all_nodes[:,0],
            "Qy_flux": q_all_nodes[:,1],
            "Qz_flux": q_all_nodes[:,2],
            },
        )

Another issue with your code is that you are saving the same arrays at each time step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants