dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22158
Re: [Question #149919]: PETScKrylovMatrix multiplication in Python
Question #149919 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/149919
Christian Clason posted a new comment:
Just a small update: The problem seems to be indeed with
PETScKrylovSolver, since PETScKrylovMatrix by itself works fine even
with standard vectors:
from dolfin import *
def boundary(x,on_boundary):
return on_boundary
mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, 'CG', 1)
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(grad(u), grad(v))*dx
class NewtonMatrix(PETScKrylovMatrix) :
def __init__(self) :
PETScKrylovMatrix.__init__(self, V.dim(), V.dim())
def mult(self, *args) :
du = Function(V,args[0])
f = du*v*dx
problem = VariationalProblem(a, f, bc)
dy = problem.solve()
args[1][:] = dy.vector()[:]
H = NewtonMatrix()
y = Function(V)
b = project(Constant(1.0),V)
H.mult(b.vector(),y.vector())
print(y.vector().norm('l2'))
However,
NewtonSolver = PETScKrylovSolver('cg', 'none')
NewtonSolver.solve(H, b.vector(), y.vector())
throws the error
TypeError: in method 'PETScKrylovSolver_solve', argument 3 of type
'dolfin::PETScVector &'
Christian
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.
Follow ups