← Back to team overview

dolfin team mailing list archive

Re: [Question #149919]: PETScKrylovMatrix multiplication in Python

 

Question #149919 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/149919

Johan Hake proposed the following answer:
This should be fixed now.

Johan

On Monday March 21 2011 10:12:52 Christian Clason wrote:
> New question #149919 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/149919
> 
> I am trying to solve a nonlinear pde-constrained optimization problem with
> a reduced Newton method, where instead of constructing the full Hessian, I
> compute the action of the Hessian on a function for use in a Krylov solver
> such as CG.
> 
> I assume that this can be done by constructing a PETScKrylovMatrix and
> defining a suitable mult function. (If there is a more high-level way of
> doing this, I'd be grateful for a hint.) However, I'm a bit stumped by the
> interface between PETSc and Dolfin here. The core step in the matrix
> multiplication would be something like
> 
> def mult(self, *args) :
>     du = Function(V,args[0])
>     L = du*v*dx
>     problem = VariationalProblem(a, L, bc)
>     y = problem.solve()
>     args[1] = y.vector()
> 
> (assume that the function space V, test function v, boundary conditions bc
> and bilinear form a have all been defined previously). This however
> doesn't work, since args[0] and args[1] are not of proper type. How do I
> need to massage args[0] and args[1] to make this work? Any hints would be
> appreciated, especially a template for the use of PETScKrylovMatrix in
> Python.
> 
> (If I can get this working, I'd be happy to turn this into a documented
> demo. I'm sure there are more people interested in using FEniCS as a
> framework for pde-constrained optimization.)

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.



References