Is it possible to apply assembler in some specific entities

Hello,

I’m wondering that is it possible to apply the assembler over specific entities instead of the whole domain
For example, if I define the form:

a = f * dx

Then I can compute the integral of the function f over the mesh it is defined in using assemble_scalar, but if I want to compute its integral only in some specific cells, is there any way to do that?

Thanks in advance!

That is what subdomain_data and subdomain_id is for. See Integration over sub-domains — FEniCS Workshop