← Back to team overview

dolfin team mailing list archive

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

 

On 21 March 2011 19:33, Johan Hake <question149919@xxxxxxxxxxxxxxxxxxxxx>wrote:

> Question #149919 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/149919
>
> Johan Hake proposed the following answer:
> On Monday March 21 2011 11:24:28 Kent-Andre Mardal wrote:
> > Nice!
> > There may be some SWIG director methods missing for the matrices. I will
> > have a look
> > to check how to do it with or without these director methods.
>
> I think the director methods works fine. These are the guys that reports
> the
> error.
>
> But I think we need to change order of the #includes in dolfin_la.h so
> PETScVector come before PETScKrylovSolver.
>
> Can you check that Kent?
>
> We need some sort of testing for this...
>
> Johan
>
>
Simply changing the order of includes did not fix it.

Kent


> > Kent
> >
> > On 21 March 2011 19:17, Christian Clason <
> >
> > question149919@xxxxxxxxxxxxxxxxxxxxx> wrote:
> > > Question #149919 on DOLFIN changed:
> > > https://answers.launchpad.net/dolfin/+question/149919
> > >
> > >     Status: Answered => Open
> > >
> > > Christian Clason is still having a problem:
> > > Yes, via PETScKrylovSolver. Below is a minimal example for what I'm
> > > trying to do.
> > >
> > > Christian
> > >
> > > 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)
> > >        du.vector()[:] = args[0][:]
> > >
> > >         f = du*v*dx
> > >
> > >        problem = VariationalProblem(a, L, bc)
> > >
> > >         dy = problem.solve()
> > >
> > >        args[1][:] = dy.vector()[:]
> > >
> > > H = NewtonMatrix()
> > >
> > > E = project(Constant('1'),V)
> > > b = PETScVector(E.vector().size())
> > > b.set_local(E.vector().array())
> > >
> > > x = PETScVector(E.vector().size())
> > > x.zero()
> > > NewtonSolver = PETScKrylovSolver('cg', 'none');
> > > NewtonSolver.solve(H, x, b);
> > >
> > > --
> > > 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
>
> --
> 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