Dolfinx fails to save complex vectors with Adios (VTX)

Hi,

From v0.7.0 dolfinx, I cannot save the complex functions as a .bp file. Here is simple MWE;

import dolfinx
from dolfinx.fem import petsc
from mpi4py import MPI
import numpy as np

mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 20, 20)

V = dolfinx.fem.FunctionSpace(mesh, ("Lagrange", 1))
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
boundary_facets = dolfinx.mesh.exterior_facet_indices(mesh.topology)
boundary_dofs = dolfinx.fem.locate_dofs_topological(V, mesh.topology.dim-1, boundary_facets)

dof_coordinates = V.tabulate_dof_coordinates()[boundary_dofs]
u_bc = dolfinx.fem.Function(V)

def f(x):
    return (x[0]+x[1])

u_bc.interpolate(f)
bc = dolfinx.fem.dirichletbc(u_bc, boundary_dofs)
u_boundary = dolfinx.fem.Function(V)
petsc.set_bc(u_boundary.vector, [bc])
u_boundary.x.scatter_forward()

with dolfinx.io.VTXWriter(mesh.comm, "u.bp", u_boundary) as vtx:
    vtx.write(0.0)

giving

Loguru caught a signal: SIGABRT
Stack trace:
72            0x40802a /home/ekrem/Applications/ParaView-5.10.1/bin/paraview-real() [0x40802a]
71      0x7fe054e29e40 __libc_start_main + 128
70      0x7fe054e29d90 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fe054e29d90]
69            0x407c8a /home/ekrem/Applications/ParaView-5.10.1/bin/paraview-real() [0x407c8a]
68      0x7fe051684120 QCoreApplication::exec() + 128
67      0x7fe05167b62a QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 298
66      0x7fe000a5ee13 /home/ekrem/Applications/ParaView-5.10.1/plugins/platforms/../../lib/libQt5XcbQpa.so.5(+0x5ee13) [0x7fe000a5ee13]
65      0x7fe051eee0db QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 187
64      0x7fe051f12b35 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 261
63      0x7fe051f118ad QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 1837
62      0x7fe05167cdd8 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 280
61      0x7fe053f63260 QApplication::notify(QObject*, QEvent*) + 704
60      0x7fe053f5c18c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 156
59      0x7fe053fb68fb /home/ekrem/Applications/ParaView-5.10.1/bin/../lib/libQt5Widgets.so.5(+0x1b68fb) [0x7fe053fb68fb]
58      0x7fe053fb3d86 /home/ekrem/Applications/ParaView-5.10.1/bin/../lib/libQt5Widgets.so.5(+0x1b3d86) [0x7fe053fb3d86]
57      0x7fe053f627cc QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) + 460
56      0x7fe05167cdd8 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 280
55      0x7fe053f63dc8 QApplication::notify(QObject*, QEvent*) + 3624
54      0x7fe053f5c18c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 156
53      0x7fe054122e04 QToolButton::event(QEvent*) + 36
52      0x7fe053f99c28 QWidget::event(QEvent*) + 424
51      0x7fe054122d7a QToolButton::mouseReleaseEvent(QMouseEvent*) + 10
50      0x7fe05403f945 QAbstractButton::mouseReleaseEvent(QMouseEvent*) + 213
49      0x7fe05403f70b /home/ekrem/Applications/ParaView-5.10.1/bin/../lib/libQt5Widgets.so.5(+0x23f70b) [0x7fe05403f70b]
48      0x7fe053f583bc QAction::activate(QAction::ActionEvent) + 204
47      0x7fe053f55fb2 QAction::triggered(bool) + 50
46      0x7fe0516ab1ea QMetaObject::activate(QObject*, int, int, void**) + 1850
45      0x7fe0548d717d /home/ekrem/Applications/ParaView-5.10.1/bin/../lib/libpqApplicationComponents-pv5.10.so.1(+0xd717d) [0x7fe0548d717d]
44      0x7fe05496b3cc pqLoadDataReaction::loadData() + 1180
43      0x7fe05496a8c8 pqLoadDataReaction::loadData(QList<QStringList> const&, QString const&, QString const&, pqServer*) + 1800
42      0x7fe054969c37 pqLoadDataReaction::DetermineFileReader(QString const&, pqServer*, vtkSMReaderFactory*, QPair<QString, QString>&) + 135
41      0x7fe04ffc7809 vtkSMReaderFactory::GetReaders(char const*, vtkSMSession*) + 889
40      0x7fe04ffc495d vtkSMReaderFactory::vtkInternals::vtkValue::CanReadFile(char const*, bool, std::vector<std::string> const&, vtkSMSession*, bool) + 461
39      0x7fe04ffc42fd vtkSMReaderFactory::CanReadFile(char const*, vtkSMProxy*) + 557
38      0x7fe04ff9e14b vtkSMProxy::UpdatePropertyInformation(vtkSMProperty*) + 75
37      0x7fe04ffa3fcc vtkSMProxy::UpdatePropertyInformationInternal(vtkSMProperty*) + 396
36      0x7fe04ffd0875 vtkSMRemoteObject::PullState(paraview_protobuf::Message*) + 117
35      0x7fe04fec3bd5 vtkPVSessionBase::PullState(paraview_protobuf::Message*) + 37
34      0x7fe04fec86ba vtkPVSessionCore::PullState(paraview_protobuf::Message*) + 506
33      0x7fe04fee6691 vtkSIProxy::Pull(paraview_protobuf::Message*) + 737
32      0x7fe04fee1dc3 vtkSIVectorPropertyTemplate<int, int>::Pull(paraview_protobuf::Message*) + 195
31      0x7fe04fee3ccc vtkSIProperty::ProcessMessage(vtkClientServerStream&) + 76
30      0x7fe04e21128d vtkClientServerInterpreter::ProcessStream(vtkClientServerStream const&) + 29
29      0x7fe04e210fee vtkClientServerInterpreter::ProcessOneMessage(vtkClientServerStream const&, int) + 1294
28      0x7fe04e2108bd vtkClientServerInterpreter::ProcessCommandInvoke(vtkClientServerStream const&, int) + 1229
27      0x7fe04e210259 vtkClientServerInterpreter::CallCommandFunction(char const*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&) + 345
26      0x7fe043491c58 vtkPVFilePathEncodingHelperCommand(vtkClientServerInterpreter*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&, void*) + 3704
25      0x7fe04fec23f4 vtkPVFilePathEncodingHelper::CallObjectMethod(char const*, bool) + 324
24      0x7fe04e21128d vtkClientServerInterpreter::ProcessStream(vtkClientServerStream const&) + 29
23      0x7fe04e210fee vtkClientServerInterpreter::ProcessOneMessage(vtkClientServerStream const&, int) + 1294
22      0x7fe04e2108bd vtkClientServerInterpreter::ProcessCommandInvoke(vtkClientServerStream const&, int) + 1229
21      0x7fe04e210259 vtkClientServerInterpreter::CallCommandFunction(char const*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&) + 345
20      0x7fe043706684 vtkFidesReaderCommand(vtkClientServerInterpreter*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&, void*) + 2548
19      0x7fe022609c17 vtkFidesReader::CanReadFile(std::string const&) + 87
18      0x7fe006465f12 fides::io::DataSetReader::CheckForDataModelAttribute(std::string const&, std::string const&) + 354
17      0x7fe00648e1bf /home/ekrem/Applications/ParaView-5.10.1/bin/../lib/../lib/libvtkfides-pv5.10.so.1(+0x8e1bf) [0x7fe00648e1bf]
16      0x7fe005493e6b adios2::IO::Open(std::string const&, adios2::Mode) + 187
15      0x7fe00398941c adios2::core::IO::Open(std::string const&, adios2::Mode) + 76
14      0x7fe003988b19 adios2::core::IO::Open(std::string const&, adios2::Mode, adios2::helper::Comm) + 1449
13      0x7fe004036fdf std::_Function_handler<std::shared_ptr<adios2::core::Engine> (adios2::core::IO&, std::string const&, adios2::Mode, adios2::helper::Comm), std::shared_ptr<adios2::core::Engine> (*)(adios2::core::IO&, std::string const&, adios2::Mode, adios2::helper::Comm)>::_M_invoke(std::_Any_data const&, adios2::core::IO&, std::string const&, adios2::Mode&&, adios2::helper::Comm&&) + 63
12      0x7fe00398ac82 std::shared_ptr<adios2::core::Engine> adios2::core::IO::MakeEngine<adios2::core::engine::BP4Reader>(adios2::core::IO&, std::string const&, adios2::Mode, adios2::helper::Comm) + 114
11      0x7fe003a4b0f9 adios2::core::engine::BP4Reader::BP4Reader(adios2::core::IO&, std::string const&, adios2::Mode, adios2::helper::Comm) + 297
10      0x7fe003a43fec adios2::core::engine::BP4Reader::Init() + 316
9       0x7fe003a437d0 adios2::core::engine::BP4Reader::InitBuffer(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<double, std::ratio<1l, 1000000000l> > > const&, std::chrono::duration<double, std::ratio<1l, 1l> > const&, std::chrono::duration<double, std::ratio<1l, 1l> > const&) + 368
8       0x7fe003a42a28 adios2::core::engine::MetadataExpectedMinFileSize(adios2::format::BP4Deserializer const&, std::string const&, bool) + 344
7       0x7fe045cae4d8 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae4d8) [0x7fe045cae4d8]
6       0x7fe045cae277 /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae277) [0x7fe045cae277]
5       0x7fe045cae20c /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae20c) [0x7fe045cae20c]
4       0x7fe045ca2b9e /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa2b9e) [0x7fe045ca2b9e]
3       0x7fe054e287f3 abort + 211
2       0x7fe054e42476 raise + 22
1       0x7fe054e969fc pthread_kill + 300
0       0x7fe054e42520 /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fe054e42520]
(   6.577s) [paraview        ]                       :0     FATL| Signal: SIGABRT
error: exception occurred: Subprocess aborted

in paraview.

It works perfectly with the real mode, but gives the error above with the complex mode.

Is it a bug?

Delete the u.bp file, and then add engine="BP4" to

as Paraview doesn’t support BP5, which is the default engine of VTX/Adios2

For what it’s worth, the code as written runs fine with the debian build of the complex package (using adios2 2.9.2).

adios2 support in dolfinx has just been added to the Ubuntu PPA, though paraview has not yet been rebuilt there to support it.

edit: paraview with adios2 support (and gmsh) is now available for ubuntu on the FEniCS PPA.

Paraview opens now, and shows the geometry and mesh, but not the function;

The issue is: Paraview opens ADIOS2-VTX BP5 files as BP4 (#22108) · Issues · ParaView / ParaView · GitLab
which is not yet resolved.

Please run bpls -a -l u.bp from your terminal so one can inspect the data in the bp file.
I added a patch for complex functions in v0.7.1: Release v0.7.1 · FEniCS/dolfinx · GitHub ref: Complex variables stored correctly in VTXWriter by jorgensd · Pull Request #2831 · FEniCS/dolfinx · GitHub

gives;

  uint32_t  NumberOfEntities     {1} = 800 / 800
  uint32_t  NumberOfNodes        {1} = 441 / 441
  int64_t   connectivity         [1]*{800, 4} = 0 / 440
  double    f_imag               [1]*{441, 1} = 0 / 0
  double    f_real               [1]*{441, 1} = 0 / 2
  double    geometry             [1]*{441, 3} = -1.07711e-18 / 1
  double    step                 scalar = 0
  uint32_t  types                scalar = 69
  string    vtk.xml              attr   = 
<VTKFile type="UnstructuredGrid" version="0.1">
  <UnstructuredGrid>
    <Piece NumberOfPoints="NumberOfNodes" NumberOfCells="NumberOfCells">
      <Points>
        <DataArray Name="geometry" />
      </Points>
      <Cells>
        <DataArray Name="connectivity" />
        <DataArray Name="types" />
      </Cells>
      <PointData>
        <DataArray Name="TIME">step</DataArray>
        <DataArray Name="vtkOriginalPointIds" />
        <DataArray Name="vtkGhostType" />
        <DataArray Name="f" />
      </PointData>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

  uint8_t   vtkGhostType         [1]*{441} = 0 / 0
  int64_t   vtkOriginalPointIds  [1]*{441} = 0 / 440

I will check the patch now.

Interestingly, the code runs fine with v0.6.0 without specifying engine;

import dolfinx
from dolfinx.fem import petsc
from mpi4py import MPI
import numpy as np

mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 20, 20)

V = dolfinx.fem.FunctionSpace(mesh, ("Lagrange", 1))
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
boundary_facets = dolfinx.mesh.exterior_facet_indices(mesh.topology)
boundary_dofs = dolfinx.fem.locate_dofs_topological(V, mesh.topology.dim-1, boundary_facets)

dof_coordinates = V.tabulate_dof_coordinates()[boundary_dofs]
u_bc = dolfinx.fem.Function(V)

def f(x):
    return (x[0]+x[1])

u_bc.interpolate(f)
bc = dolfinx.fem.dirichletbc(u_bc, boundary_dofs)
u_boundary = dolfinx.fem.Function(V)
petsc.set_bc(u_boundary.vector, [bc])
u_boundary.x.scatter_forward()

with dolfinx.io.VTXWriter(mesh.comm, "u.bp", u_boundary) as vtx:
    vtx.write(0.0)

gives

The debian build has applied a bundle of patches from paraview head to enable support for adios2 2.9, which might explain why it’s working. It’s now available from the FEniCS PPA for ubuntu.

The patch should fix the issue,
As

Should have a data-array called f_real and f_imag

1 Like

I upgraded to v0.7.2 and it works.