Efficient integration on internal boundary

Hello,
I am working with two subdomains and I need to integrate on the internal boundary. This boundary is already identified as a Measure dS_int(1). I wonder, however, what is the most efficient way to do this.
The integrals are something like:

\int_{\partial \Omega} G g(x) ds, i = 1, \dots, N.

G is computed in terms of the solution u of the linear elastic problem:

G = - 2.0*mu*inner(sym(grad(u)),sym(grad(u))) - lmbda*div(u)*div(u) + Constant(Lag)

Simply integrating \int_{\partial \Omega} G ds seems ok! However, I’m having trouble dealing with g(x). I have the analytical expression for g_i(x), so I tried defining it as an Expression.

g = Expression('(pow(max(0.0, 1.0 -sqrt(pow(x[0] - c1,2) + pow(x[1]-c2,2)+c)/dsp),4))*(4*(sqrt(pow(x[0] - c1,2) + pow(x[1]-c2,2)+c)/dsp)+1.0)', degree = 2, c1 = 0.1, c2 = 0.1, c = 0.1, dsp = 2)

Then, this seems to work:

assemble((G*f)('+')*structure.dS_int(1) + (G*f)('-')*structure.dS_int(1)).

However, it doesn’t seem to be a wise way to do it, specialy beacuse I am working with an iterative algorithm (with fixed mesh) and the nodal values of g(x) function never changes. The only thing that changes is the internal boundary itself - and therefore the knots I will need to evaluate it on. It seems to me that It wouldn’t be efficient to call the expression each iteration. I could have all the values stored in a matrix, but I am not sure how the assemble function would work. Is the assemble function actually the best way to integrate with this measure?

It might be a really simple question, but I’m still new to FEniCS, so I’m having a little trouble with that. I hope my question is clear!

How about projecting g into an appropriate function space, and using it in the assembly?