This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

UFL: unsupported operand type(s) for +: 'Measure' and 'MeasureSum'

0 votes

Hello everybody,

My UFL-File is something like:

cell = triangle

CG = FiniteElement("CG", cell, 1)

sigma1 = Coefficient(CG)
sigma2 = Coefficient(CG)
w1 = TrialFunction(CG)
q1 = TestFunction(CG)
w2 = TrialFunction(CG)
q2 = TestFunction(CG)
f = Coefficient(CG)
a1=... (not relevant)
a2=...(not relevant)
L1=...(not relevant)
L2=...(not relevant)

DG = FiniteElement("DG", cell, 0)
u = TrialFunction(DG)
v = TestFunction(DG)
k = Constant(cell) 
g = Coefficient(DG) 


a = u*v*dx
L = v*w1*(dx(1)+(1-k)*(dx(2)+dx(3))+dx(4)) + v*w2*(k*(dx(2)+dx(3))+dx(5)) + u*g*(ds(2)-ds(3))

while compiling it with ffc -l dolfin *.ufl I get the Error

TypeError: unsupported operand type(s) for +: 'Measure' and
'MeasureSum'

caused by the last Line.
Where is the mistake in this case and why?
I just want to integrate over several subdomains and in the subdomains 2 and 3 there should be 1-k timesthe solution of w1 and k times thesolution of w2.

I hope I stated clear, what I need to implement and you have any idea how to fix it.

Sincerely,
Justus

asked Nov 2, 2016 by Pama328 FEniCS Novice (480 points)

1 Answer

0 votes

You need to use the Measure function to redefine dx.

answered Nov 3, 2016 by KristianE FEniCS Expert (12,900 points)

Thanks for the quick reply.

But why? I just thought dx would be defined by the xml-file containing the subdomains and facets as Meshfunctions in my cpp-code?

I never had to redefine anything like that.

Then it might be a bug in FEniCS related to your first term, but it is hard to say. Maybe someone can confirm it, if you post a minimum working example.

Does the error go away, if you manually expand everything?

Unfortunately it does not go away if I expand everything. It just changes to thatever I directly multiply with k.

I did something similar in an UFL File for the convection-diffusion-equation (as a variable time step) and implemented the solver as usual in cpp and it worked by defining dx and ds indirectly in the Meshfunction-XML-files

...