← Back to team overview

ffc team mailing list archive

Re: [question103102@xxxxxxxxxxxxxxxxxxxxx: Re: [Question #103102]: multiply spatial coordinates x in the variational formulation]

 

On Thu, Mar 04, 2010 at 12:06:15PM -0800, Johan Hake wrote:
> On Thursday 04 March 2010 11:48:03 Kristian Oelgaard wrote:
> > On 4 March 2010 20:45, Anders Logg <logg@xxxxxxxxx> wrote:
> > > On Thu, Mar 04, 2010 at 08:35:49PM +0100, Kristian Oelgaard wrote:
> > >> On 4 March 2010 19:49, Anders Logg <logg@xxxxxxxxx> wrote:
> > >> >Could you add a demo for this?
> > >>
> > >> Sure, to FFC, DOLFIN or both?
> > >> The Poisson demo would be good to do because it has both dx and ds
> > >> integrals.
> > >>
> > >> Kristian
> > >
> > > Both.
> > >
> > > What would the Poisson demo look like with this feature?
> >
> > element = FiniteElement("Lagrange", triangle, 1)
> >
> > v = TestFunction(element)
> > u = TrialFunction(element)
> >
> > x = triangle.x[0]
> > d_x = triangle.x[0] - 0.5
> > d_y = triangle.x[1] - 0.5
> > f = 10.0*exp(-(d_x*d_x + d_y*d_y) / 0.02)
> > g = sin(5.0*x)
> >
> > a = inner(grad(v), grad(u))*dx
> > L = v*f*dx + v*g*ds
>
> Cool!
>
> Who needs Expressions when you can generate code for the above?

Looks very cool. Should we expose x in the interface so it can be used
directly? The advantage with Expression is that one write "sin(x[0])"
without first needing to define what x is (as in x = triangle.x).

After all, we already expose i, j, k, ... as indices so it wouldn't be
that strange.

The problem might be that one needs either triangle.x or tetrahedron.x.

--
Anders

Attachment: signature.asc
Description: Digital signature


References