PETScLUSolver returns the same results for solving Ax=b and A^Tx=b

Issue #1060 new
BO JIN created an issue

It seems the bool parameter doesn't work in PETScLUSolver.solve(GenericVector& x, const GenericVector& b, bool transpose). The minimal code is shown below.

from fenics import *
import numpy as np
from petsc4py import PETSc
from scipy.sparse import csr_matrix

# matrix A=[1 2]
#          [3 4]
A_csr=csr_matrix([[1.0,2.0],[3.0,4.0]])
p1=A_csr.indptr
p2=A_csr.indices
p3=A_csr.data
petsc_mat = PETSc.Mat().createAIJ(size=A_csr.shape,csr=(p1,p2,p3))# creating petsc matrix from csr
A_petsc = PETScMatrix(petsc_mat)

# rhs b=[1 2]
b=np.asarray([1.0,2.0])
b=PETScVector(PETSc.Vec().createWithArray(b))

# solve Ax=b and A^Tx=b
x=PETScVector(PETSc.Vec().createWithArray(np.asarray([0.0,0.0])))
solver = PETScLUSolver(A_petsc, 'mumps')
solver.solve(x,b,False)
print(x.get_local())
solver.solve(x,b,True)
print(x.get_local())

#[-4.59940115e-17  5.00000000e-01]
#[-4.59940115e-17  5.00000000e-01]

Comments (2)

  1. Log in to comment