How to set bound in SNES solver?

Hi, I would like to use SNES solver to solute the problem, and I have learned Set bounds in a NonLinearProblemSet limits to the solution functiondolfinx/python/test/unit/fem/test_nonlinear_assembler.py at 160ed13eb476df99944072aec70bd46a6fcb9bcf · FEniCS/dolfinx · GitHub and dolfinx/python/test/unit/fem/test_nonlinear_assembler.py at 8140591d980ba4e0705588999294e37704c96186 · FEniCS/dolfinx · GitHub.

However, when I want to set bounds for SNES solver, the dolfinx.fem.Function.vector has lost.

d_min, d_max = d.copy(), d.copy()
d_min.x.array[:] = 0
d_max.x.array[:] = 1
solver_d = PETSc.SNES().create(MPI.COMM_WORLD)
solver_d.setVariableBounds(d_min.vector, d_max.vector)

Thank you!

What do you mean by has lost?
Could you

  1. specify what version of DOLFINx you are running?
  2. Add the error message and trace you are getting when running the code?

@dokken Thank you, and I’m sorry to do not describe it clearly. What I mean is that in FEniCSx v0.9 version, there is no Vector item in the dolfinx.fem.Function object #dolfinx.fem.Function. I would like to knew how to set the snes.setVariableBounds for SNES solver in FEniCSx of 0.9 version. Thank you very much.

See: FEniCS release notes | FEniCS Project

Thank you, this is exactly what I want.