Integrating over surface fails with JIT error (AssertionError expr.ufl_is_terminal_modifier)

Hi, another note is that you mixed up the internal and exterior measure. ds is exterior, dS is interior.
The problem with your code is that you are trying to restrict the integral over the outer boundary to one side. The problem is fixed by:

J = Jin-Jip
Jx = dot(J,nx)

I1 = Jx("+") * dMeas_int(1)+Jx * dMeas_ext(1)    # integrationver Boundary1  
I2 = Jx("+") * dMeas_int(2)+Jx * dMeas_ext(2)    # integration over Boundary2
I3 = Jx("+") * dMeas_int(3)+Jx * dMeas_ext(3)    # integration over Boundary3

However, note that the positive restriction is arbitrary, but consistent. See Integrating over an interior surface for a fix for this.

1 Like