# Why is my code converging in 4 steps? Linear PDE

**URL:** <https://fenicsproject.discourse.group/t/why-is-my-code-converging-in-4-steps-linear-pde/14070>\
**Category:** General\
**Created:** [March 29, 2024, 10:32pm UTC](https://fenicsproject.discourse.group/t/why-is-my-code-converging-in-4-steps-linear-pde/14070 "2024-03-29T22:32:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [March 29, 2024, 10:41pm UTC](https://fenicsproject.discourse.group/t/why-is-my-code-converging-in-4-steps-linear-pde/14070/2 "2024-03-29T22:41:54Z")

</div>

> [@raboynics](#):
>
> `solver.convergence_criterion = "incremental"`

Start by changing the convergence criterion from «incremental» to residual.

> [@raboynics](#):
>
> When I simply remove the Dirichlet boundary condition, the problem is physically exactly the same (because voltage is defined up to a constant, and here I let the solver fix it instead of enforcing it myself)

The solver should then know about the null-space, Which you can enforce through options, see for instance

> [@Is the dofmap contains glocal index or local index?](https://fenicsproject.discourse.group/t/is-the-dofmap-contains-glocal-index-or-local-index/14044/5):
>
> ```auto
> problem = LinearProblem(a, L, bcs=[], petsc_options={
> "ksp_type": "preonly", "pc_type": "lu",
> "pc_factor_mat_solver_type": "mumps",
> "mat_mumps_icntl_24": 1, # Option to support solving a singular matrix
> "mat_mumps_icntl_25": 0 # Option to support solving a singular matrix
> })
> nullspace = PETSc.NullSpace().create(constant=True) # type: ignore
> PETSc.Mat.setNearNullSpace(problem.A, nullspace)
> 
> uh = problem.solve()
> 
> ```

in

> [@How to obtain coordinates of nodes? How to work with dofmap?](https://fenicsproject.discourse.group/t/how-to-obtain-coordinates-of-nodes-how-to-work-with-dofmap/8507/12):
>
> The rotation vector is -y, x, i.e. from mpi4py import MPI import ufl import dolfinx mesh = dolfinx.mesh.create\_unit\_square( MPI.COMM\_WORLD, 10, 10, cell\_type=dolfinx.mesh.CellType.quadrilateral) Ve = ufl.VectorElement("S", mesh.ufl\_cell(), 2) V = dolfinx.fem.functionspace(mesh, Ve) u = dolfinx.fem.Function(V) u.interpolate(lambda x: (-x[1], x[0])) V\_out = dolfinx.fem.FunctionSpace( mesh, ufl.VectorElement("Lagrange", mesh.ufl\_cell(), 2)) u\_out = dolfinx.fem.Function(V\_out) u\_out.in…

---

_[View the full topic](https://fenicsproject.discourse.group/t/why-is-my-code-converging-in-4-steps-linear-pde/14070)._
