← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Work on some python demos.

 

On Tuesday 06 October 2009 23:10:50 Garth N. Wells wrote:
> Johan Hake wrote:
> > On Tuesday 06 October 2009 22:49:02 Garth N. Wells wrote:
> >> Johan Hake wrote:
> >>> On Tuesday 06 October 2009 22:25:12 Garth N. Wells wrote:
> >>>> DOLFIN wrote:
> >>>>> One or more new changesets pushed to the primary dolfin repository.
> >>>>> A short summary of the last three changesets is included below.
> >>>>>
> >>>>> changeset:   7277:056daa74d8c6
> >>>>> tag:         tip
> >>>>> user:        "Johan Hake <hake@xxxxxxxxx>"
> >>>>> date:        Tue Oct 06 15:26:02 2009 +0200
> >>>>> files:       demo/function/eval/python/demo.py
> >>>>> demo/function/nonmatching-interpolation/python/demo.py
> >>>>> demo/function/projection-interpolation/python/demo.py
> >>>>> demo/pde/adaptive-poisson/python/demo.py
> >>>>> demo/pde/advection-diffusion/python/demo.py
> >>>>> demo/pde/cahn-hilliard/python/demo.py description:
> >>>>> Work on some python demos.
> >>>>>   - We need to solve the issue with Form of only coeffcients
> >>>>>   - CahnHilliard demo still complains of gather not work, will look
> >>>>> into it later
> >>>>
> >>>> I'm running into the gather function too. Why is SWIG not seeing
> >>>> GenericFunction::gather()?
> >>>
> >>> Have you pulled?
> >>>
> >>> I should have fixed this in my last push.
> >>>
> >>> The problem is with how SWIG handles director functions. Previously did
> >>> not Function inherit a class with virtual functions. Now Expression
> >>> does. I just ignored the generation of director output for all but the
> >>> eval function. See the
> >>
> >> Now I get
> >>
> >> Exception: Swig director method error. Error detected when calling
> >> 'Expression.eval'
> >
> > Strange.
> >
> > Which demo are you trying to get working?
> 
> It's a piece of my own code. Here's an extract:
> 
> class BoundaryFlux(Expression):
>      def eval(self, values, x):
>          if abs(x[0]) < DOLFIN_EPS and x[1] > 0.2:
>              values[0] = 1.0
>          else:
>              values[0] = 0.0
> 
> g = BoundaryFlux( V = V_cg)
> bc = DirichletBC(V_cg, g, DirichletBoundary())
> 
> A = assemble(a)
> b = assemble(L)
> bc.apply(A, b)
> 
> The error is at 'bc.apply(A, b)'.

It errors in the call to eval through the 
  
  GeneicFunction.restriction->
  ...
  GenericFunction.evaluate->
  Expression.eval(values,data)->
  Expression.eval(values,x)

Right?

It looks like it works when I substitute a the constant in poisson demo with a 
pure Python expression. So something is obviously working also for 
DirichletBC.

We might consider turning on directors for GenericFunction too. I have tried 
to avoid it.

Johan

Johan

> > Does CahnHilliard work for you?
> 
> Yes.
> 
> Garth
> 
> > Johan
> >
> >> Garth
> >>
> >>>   swig/directors.i
> >>>
> >>> file.
> >>>
> >>> Johan
> >>>
> >>>> Garth
> >>>>
> >>>>> changeset:   7276:9c11cb5fde78
> >>>>> parent:      7275:a165fa7ed868
> >>>>> parent:      7273:8e585111ca80
> >>>>> user:        "Johan Hake <hake@xxxxxxxxx>"
> >>>>> date:        Tue Oct 06 14:47:04 2009 +0200
> >>>>> description:
> >>>>> merge
> >>>>>
> >>>>>
> >>>>> changeset:   7275:a165fa7ed868
> >>>>> user:        "Johan Hake <hake@xxxxxxxxx>"
> >>>>> date:        Tue Oct 06 14:46:54 2009 +0200
> >>>>> files:       demo/pde/poisson/python/demo.py
> >>>>> dolfin/swig/function_pre.i dolfin/swig/std_vector_typemaps.i
> >>>>> site-packages/dolfin/__init__.py site-packages/dolfin/constant.py
> >>>>> site-packages/dolfin/expression.py site-packages/dolfin/form.py
> >>>>> site-packages/dolfin/function.py
> >>>>> site-packages/dolfin/variationalproblem.py
> >>>>> test/unit/function/python/test.py description:
> >>>>> Function in PyDOLFIN is now up and running
> >>>>>   - Poisson demo works :)
> >>>>>   - function unittest passes
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>>- For more details, visit http://www.fenics.org/hg/dolfin
> >>>>> _______________________________________________
> >>>>> DOLFIN-dev mailing list
> >>>>> DOLFIN-dev@xxxxxxxxxx
> >>>>> http://www.fenics.org/mailman/listinfo/dolfin-dev
> >>>>
> >>>> _______________________________________________
> >>>> DOLFIN-dev mailing list
> >>>> DOLFIN-dev@xxxxxxxxxx
> >>>> http://www.fenics.org/mailman/listinfo/dolfin-dev
> 


References