Integrate Torque along a boundary

Hi I am solving some fluid equation with some embedded inclusion, and I would like to find the force and torque on this object. The inclusion is a polygon and the boundary of this inclusion is marked with

s0.mark(boundaries, 0)

ds = Measure(“ds”)[boundaries]

The unit normal vector is denoted by,

I solved the equation

solve(F_nematic==0, wn)

which basically gives me the (2D) stress tensor T.

I know how to find the force on the inclusion, for example the force in x direction is given by

fx = - (Txx * + Txy * * ds(0) + …

solve(F_nematic==0, wn)
Fx = assemble(fx)

However I am not sure how to find the torque on this inclusion with respect to its center of mass(whose coordinate is given) since I am not sure how to include the position vector of the points on boundary in the integral. I wonder what I need to do.


You could compute the center off mass using SpatialCoordinates.
See for instance this shape optimization demo
which computes the barycenter of an obstacle in a channel (0,0)x((L/H) by:

(x,y) = SpatialCoordinate(mesh)
Bc1 = (L**2*H/2 - assemble(x*dx(domain=mesh))) / (L*H - Vol)
Bc2 = (L*H**2/2 - assemble(y*dx(domain=mesh))) / (L*H - Vol)

Then in turn you can compute the torque.