Gradient of a function on a subdomain

Hi!

My question is related to the computation of the gradient of a function on a certain subdomain. Let’s say I have a function defined on the whole domain, which is divided into two subdomains. I’d like to compute the gradient of that function taking only into account the nodes of a certain subdomain. This is easy with the dx term in the variational form. However, in an internal boundary integral I have not been able to reproduce that without using a projection on the subdomain. However, this cannot be applied in a non-linear variational form, which is my main objective.
Is it possible to do so and be able to apply this on a non-linear variational form?

Thanks in advance.

Note that gradients of CG functions are discontinuous at internal boundaries, and has to be restricted to either side on the by using the ("+") or ("-") operation. See Integrating over an interior surface

For non-linear problems, please provide a minimal example that shows what you would like to do, as it is not clear to me what the issue is.

Thanks for the quick response!

So, let’s say I have a function phi defined on a whole subdomain. Then, in the non-linear form I have a term like this:

(I am handling Lagrange multipliers with multiphenics). Note that the differential corresponds to an internal boundary.

The term appearing on the previous image is phi_v, which is the part of phi evaluated on a specific subdomain. Then, the gradient is applied. Thus, I should be able to compute the gradient of phi_v by only taking into account the nodes of that subdomain, that is, I should somehow isolate the information of phi on that specific subdomain and compute the gradient. Hope now is clearer.

As i said earlier, using the restriction operator consistently will make it possible to evaluate the gradient from one side of the interior surface.

Thanks. So, if I understood correctly, the ‘+’ and ‘-’ are defined by the subdomain id provided that a MeshFunction with the correct data is given right?

Yes, that is correct