← Back to team overview

dolfin team mailing list archive

Re: [FEniCS-users] "Expecting integrand to be an Expr instance." error

 

Quoting phil marinier <lonewolf_13p@xxxxxxxxxxx>:

>
> > Date: Tue, 17 Nov 2009 01:05:17 +0100
> > From: murtazo@xxxxxxxxxx
> > To: lonewolf_13p@xxxxxxxxxxx; fenics-users@xxxxxxxxxx
> > Subject: Re: [FEniCS-users] "Expecting integrand to be an Expr instance."
> error
> >
> >
> > phil marinier wrote:
> > > **I need to define a neumann bc on one edgeof a 2d rectangular domain.
> > > When I try to compile my .ufl file, I get this error message:
> > >
> > >
> > > This is FFC, the FEniCS Form Compiler, version 0.6.2.
> > > For further information, visit http://www.fenics.org/ffc/.
> > >
> > > Preprocessing form file: Laplace.ufl --> Laplace.py
> > >
> > > Expecting integrand to be an Expr instance.
> > >
> > > *** FFC: Expecting integrand to be an Expr instance.
> > > *** FFC: To get more information about this error, rerun FFC with --debug
> > >
> > >
> > > My .ufl file is as follows:
> > >
> > >
> > > element = FiniteElement("Lagrange", triangle, 1)
> > >
> > > v = TestFunction(element)
> > > u = TrialFunction(element)
> > > f = Function(element)
> > > g = Function(element)
> > >
> > > ds0 = Integral("exterior facet", 0)
> > >
> > > a = inner(grad(v), grad(u))*dx + v*g*ds0
> > > L = v*f*dx

There seems to be some syntax confusion here.
An Integral consists of an Integrand (here v*g) and a Measure so if you define

from ufl.integral import *
ds0 = Measure(Measure.EXTERIOR_FACET, 0)

a = inner(grad(v), grad(u))*dx
L = v*f*dx + v*g*ds0

it works. In fact the default ds is equal to ds0 as defined above.
Calling a Measure with an integer (e.g.,  ds8 = ds(8) )will return a new Measure
defined on the same domain type but on a different subdomain.

> > >
> > > I explicity defined ds0 so that I can specify which subdomain to
> > > define the BC on. I assumed that if I used the default "ds" it would
> > > define the BC over the entire circumferance.
> > > Any help would be appreciated. Thank you
> > >
> > > Phil
> > >
> > You can you the default "ds" only for the subdomain you want to impose
> > the BC. Take a look to this demo:
> >
> > demo/pde/elastodynamics/cpp
> >
> > or this thread:
> >
> > http://www.fenics.org/pipermail/fenics-users/2009-October/000169.html
> >
> > murtazo
> >
> >
> >
>
>
>
> Ok so I looked at that demo, very helpful thank you, I was going to try
> to use Assemble, but instead I can just create my VariationalProblem
> and pass in the MeshFunctions as arguments. And for ds(0), ds(1), etc, the
> number in the bracket is the marker that you give the subdomain. I got my
> .ufl file to compile by using ds(0) instead of defining a ds0, so that fixes
> my problem. Thank you again.

Yes, this is the best way of solving your problem.

Kristian

> In case you guys would like the information about the error message, I had
> originally tried compiling the above form file with the boundary term in L
> instead of in a, but I got the same error message, so I assumed I was doing
> it wrong and tried putting it in "a" instead, since an example I saw had
> something like that. I seems like I can't compile anything that uses
> "Integral." I used the command "ffc -l dolfin Laplace.ufl" to compile.
>
> Thank you again
>
> Phil
>
>
>
>
>
>