Issues when saving the output as numpy format, 'petsc4py.PETSc.Vec' object is not callable

I’m running the code in jorgensd/dolfinx_ipcs: Simple IPCS solver for dolfinx.

I ran the code as follows:

  • download the docker and git clone the repository;
  • run python3 create_and_convert_2D_mesh.py in command line;
  • run python3 DFG_benchmark.py in command line.

And I make sure it can run successfully.

Now I want to save the output as numpy format, I followed the code in

How to get the solution obtained by fenics as a vector? - #2 by dokken

But when I made change in the DFG_benchmark.py as follows:

dof_coordinates = V.tabulate_dof_coordinates() (line 47) ran with no error, but print(uh.vector().get_local()) (line 64) get the error:

TypeError: 'petsc4py.PETSc.Vec' object is not callable

I wonder if this problem comes from that I used the package dolfinx in dolfinx_icps rather dolfin.

THANKS A LOT For Any Help!!!

Please, for further posts, add the plain-text of your code with the following formatting:

```python
# add code here
```

rather than a screenshot.

Yes, this is because the API has changed. What you should use is uh.x.array
when running DOLFINx.

Thank you!!!
For futher posts, I’ll follow your instructions, rather than posting a screenshot.

uh.x.array successfully gets the value of velocity.