← Back to team overview

dolfin team mailing list archive

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

 

Christian,

For now, you should write your Newton solver in Python. It shouldn´t be many
extra lines.
This would not require that cross language inheritance works properly for
matrices
and vectors, which there is no easy fix for at the moment.
Please tell me if this is not a feasible approach for you.

Kent



On 21 March 2011 18:12, Christian Clason <
question149919@xxxxxxxxxxxxxxxxxxxxx> 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.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References