Computation on custom mesh: PETSc error code is: 73 (Object is in wrong state).

Issue #838 invalid
Nico Schlömer created an issue

MWE:

from dolfin import *

mesh = Mesh('test.xml')

V = FunctionSpace(mesh, 'Lagrange', 1)
u = TrialFunction(V)
v = TestFunction(V)
sol = Function(V)
solver = KrylovSolver('gmres')
solver.set_operator(assemble(u*v*dx))
solver.solve(sol.vector(), assemble(Constant(1)*v*dx))

gives

*** Error:   Unable to successfully call PETSc function 'KSPSolve'.
*** Reason:  PETSc error code is: 73 (Object is in wrong state).
*** Where:   This error was encountered inside /build/dolfin-1R8MPk/dolfin-2016.2.0/dolfin/la/PETScKrylovSolver.cpp.

This uses test.xml.

When using mesh = UnitSquareMesh(20, 20), it all works as expected.

Comments (6)

  1. Nathan Sime

    Your mesh looks bad. There's nothing connected to vertex 0. The matrix is singular.

    from dolfin import *
    
    mesh = Mesh('test.xml')
    
    V = FunctionSpace(mesh, 'Lagrange', 1)
    u = TrialFunction(V)
    v = TestFunction(V)
    A = assemble(u*v*dx).array()
    
    bad_dof = 0
    d2v = dof_to_vertex_map(V)
    
    # Zero diagonal
    print A[bad_dof, bad_dof]
    
    # The bad vertex
    bad_vertex = Vertex(mesh, d2v[bad_dof])
    print "Bad vertex: " + str(bad_vertex.index())
    
    # Connectivity has no cells
    mesh.init()
    print [c for c in cells(bad_vertex)]
    print [f for f in facets(bad_vertex)]
    

    In the xml

    <vertex index="0" x="1.0" y="0.0" z="0.0"/>
    

    is never used.

  2. Jan Blechta

    Good spotting @nate-sime. In fact, one gets for d2v = dof_to_vertex_map(V) when assertions are on

    *** Error:   Unable to complete call to function vertex_to_dof_map().
    *** Reason:  Assertion vertex_found failed.
    
  3. Log in to comment