PETScKrylovSolver does not iterate
Now that PETScKrylovSolver can be called from Python for KrylovMatrix, I've hit another snag: In some cases, PETScKrylovSolver returns the right hand side vector after one iteration. Curiously, "monitor_
Christian
###
from dolfin import *
def boundary(
return on_boundary
mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, 'CG', 1)
bc = DirichletBC(V, Constant(0.0), boundary)
u = TrialFunction(V); v = TestFunction(V)
A, b = assemble_system( inner(grad(u), grad(v))*dx, Constant(1.0)*v*dx, bc)
class NewtonMatrix(
def __init__(self) :
def mult(self, *args) :
x = args[0]; bc.apply(x)
class NewtonMatrix2(
def __init__(self) :
def mult(self, *args) :
x = args[0];
y = A*x
args[1][:] = y[:]
NewtonSolver = PETScKrylovSolv
NewtonSolver.
y = Function(V)
solve(A,
x_petsc = PETScVector(
print NewtonSolver.
print (b - x_petsc).norm('l2') # works: this is zero
x_petsc.zero()
print NewtonSolver.
print (y.vector() - x_petsc).norm('l2') # doesn't work: this is not zero
print (b - x_petsc).norm('l2') # but this is
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Christian Clason for more information if necessary.