This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Getting "PETSc error code is: 73" with version 1.5

0 votes

I am using LUSolver from PETSc and it works fine with version 1.4. But version 1.5 (mac binary from fenicsproject) give this error at the solve stage

PETSc error code is: 73

Here is some portion of my code

a, L  = lhs(F2), rhs(F2)

A  = PETScMatrix()
solver = LUSolver(A)
solver.parameters['same_nonzero_pattern'] = True

while t < Tf:
    if it==1:
        assemble(a, tensor=A)
    else:
        assemble(a, tensor=A, reset_sparsity=False)
    assemble(L, tensor=b)
    [bc.apply(A,b) for bc in self.bcs]
    solver.solve(up2.vector(), b)

and here is the full error message

[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Object is in wrong state!
[0]PETSC ERROR: Matrix must be set first!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 3, Wed Aug 29 11:26:24 CDT 2012 
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Unknown Name on a darwin14. named newton.tifrbng.res.in by praveen Wed Mar 18 14:19:16 2015
[0]PETSC ERROR: Libraries linked from /Users/johannr/fenics-1.5.0/local/lib
[0]PETSC ERROR: Configure run at Mon Jan 12 22:17:07 2015
[0]PETSC ERROR: Configure options --prefix=/Users/johannr/fenics-1.5.0/local COPTFLAGS=-O2 --with-debugging=0 --with-clanguage=cxx --with-c-support=1 --with-blas-lapack-dir=/usr --with-umfpack=1 --with-umfpack-include=/Users/johannr/fenics-1.5.0/local/include/suitesparse --with-umfpack-lib="[/Users/johannr/fenics-1.5.0/local/lib/libumfpack.a,/Users/johannr/fenics-1.5.0/local/lib/libamd.a]" --with-spooles=1 --with-spooles-include=/Users/johannr/fenics-1.5.0/local/include --with-spooles-lib=/Users/johannr/fenics-1.5.0/local/lib/libspooles.a --with-ptscotch=1 --with-ptscotch-dir=/Users/johannr/fenics-1.5.0/local --with-ml=1 --with-ml-include=/Users/johannr/fenics-1.5.0/local/include/trilinos --with-ml-lib=/Users/johannr/fenics-1.5.0/local/lib/libml.dylib --with-hdf5=1 --with-hdf5-dir=/Users/johannr/fenics-1.5.0/local --with-x=0 -with-x11=0 --with-fortran=0 --with-shared-libraries=1 PETSC_DIR=/Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc PETSC_ARCH=darwin14.0.0-cxx-opt
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: PCSetUp() line 812 in /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc/src/ksp/pc/interface/precon.c
[0]PETSC ERROR: KSPSetUp() line 278 in /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc/src/ksp/ksp/interface/itfunc.c
[0]PETSC ERROR: KSPSolve() line 402 in /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc/src/ksp/ksp/interface/itfunc.c
Traceback (most recent call last):
  File "bdf_ext.py", line 5, in <module>
    problem.run_bdf_ext()
  File "/Users/praveen/Applications/fenics/2d/ns_cylinder/ns.py", line 363, in run_bdf_ext
    solver.solve(up2.vector(), b)
RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to successfully call PETSc function 'KSPSolve'.
*** Reason:  PETSc error code is: 73.
*** Where:   This error was encountered inside /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/DOLFIN/dolfin/la/PETScLUSolver.cpp.
*** Process: unknown
*** 
*** DOLFIN version: 1.5.0
*** Git changeset:  0468774816ee762b2409d09355d290940520716b
*** -------------------------------------------------------------------------
asked Mar 18, 2015 by praveen FEniCS User (2,760 points)

It looks like there is some change in v1.5. The following code does not work and gives error I posted before.

A  = PETScMatrix()
solver = LUSolver(A)
solver.parameters['same_nonzero_pattern'] = True

while t < Tf:
    assemble(a, tensor=A)
    assemble(L, tensor=b)
    [bc.apply(A,b) for bc in self.bcs]
    solver.solve(up2.vector(), b)

LUSolver is not getting the assembled matrix.

Please include a complete but minimal example that reproduces the error.

Example

from dolfin import *

def Boundary(x, on_boundary):
     return on_boundary

mesh = UnitSquareMesh(20,20)
V    = FunctionSpace(mesh, "CG", 1)

f = Expression("sin(pi*x[0])*cos(pi*x[1])")

u  = TrialFunction(V)
v  = TestFunction(V)

u0 = Constant(0.0)
bc = DirichletBC(V, u0, Boundary)

a = dot(grad(u), grad(v))*dx
L = f*v*dx

A = PETScMatrix()
solver = LUSolver(A)

assemble(a, tensor=A)
b = assemble(L)
bc.apply(A,b)

w = Function(V)
solver.solve(w.vector(), b)

File("u.pvd") << w

I get this error

[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Object is in wrong state!
[0]PETSC ERROR: Matrix must be set first!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 3, Wed Aug 29 11:26:24 CDT 2012 
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Unknown Name on a darwin14. named rmbp.Home by praveen Wed Mar 18 19:30:27 2015
[0]PETSC ERROR: Libraries linked from /Users/johannr/fenics-1.5.0/local/lib
[0]PETSC ERROR: Configure run at Mon Jan 12 22:17:07 2015
[0]PETSC ERROR: Configure options --prefix=/Users/johannr/fenics-1.5.0/local COPTFLAGS=-O2 --with-debugging=0 --with-clanguage=cxx --with-c-support=1 --with-blas-lapack-dir=/usr --with-umfpack=1 --with-umfpack-include=/Users/johannr/fenics-1.5.0/local/include/suitesparse --with-umfpack-lib="[/Users/johannr/fenics-1.5.0/local/lib/libumfpack.a,/Users/johannr/fenics-1.5.0/local/lib/libamd.a]" --with-spooles=1 --with-spooles-include=/Users/johannr/fenics-1.5.0/local/include --with-spooles-lib=/Users/johannr/fenics-1.5.0/local/lib/libspooles.a --with-ptscotch=1 --with-ptscotch-dir=/Users/johannr/fenics-1.5.0/local --with-ml=1 --with-ml-include=/Users/johannr/fenics-1.5.0/local/include/trilinos --with-ml-lib=/Users/johannr/fenics-1.5.0/local/lib/libml.dylib --with-hdf5=1 --with-hdf5-dir=/Users/johannr/fenics-1.5.0/local --with-x=0 -with-x11=0 --with-fortran=0 --with-shared-libraries=1 PETSC_DIR=/Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc PETSC_ARCH=darwin14.0.0-cxx-opt
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: PCSetUp() line 812 in /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc/src/ksp/pc/interface/precon.c
[0]PETSC ERROR: KSPSetUp() line 278 in /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc/src/ksp/ksp/interface/itfunc.c
[0]PETSC ERROR: KSPSolve() line 402 in /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/PETSc/src/ksp/ksp/interface/itfunc.c
Traceback (most recent call last):
  File "test.py", line 28, in <module>
    solver.solve(w.vector(), b)
RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to successfully call PETSc function 'KSPSolve'.
*** Reason:  PETSc error code is: 73.
*** Where:   This error was encountered inside /Users/johannr/fenics-1.5.0/fenics-superbuild/build-fenics/CMakeExternals/src/DOLFIN/dolfin/la/PETScLUSolver.cpp.
*** Process: unknown
*** 
*** DOLFIN version: 1.5.0
*** Git changeset:  0468774816ee762b2409d09355d290940520716b
*** -------------------------------------------------------------------------

I get the same error when using the latest development version of DOLFIN, but I'm not sure what the problem is. Maybe you should register an issue?

1 Answer

0 votes

I encountered similar problems with LUSolver, but you can work around them easily by creating the LUSolver only after assembly:

assemble(a, tensor=A)
solver = LUSolver(A)
answered Mar 25, 2015 by Gregor Mitscha-Baude FEniCS User (2,280 points)
...