Allocating different variables to different subdomains

I would like to solve a problem with two subdomains. In subdomain 1, there are two variables c and phi. In subdomain 2 there is only one variable phi. The variable phi actually exists in both subdomains, and its values in each subdomain can be linked by imposing, for example, continuity of both phi and its normal derivative at the boundary between the subdomains. The variable c seems to pose a problem because it is only defined in one subdomain. An easy way to handle the variable c would be to define it in both subdomains, but ignore its values in the subdomain where it doesn’t really exist. This seems to be rather inefficient. Is there some way in dolfinx to restrict variables to specific subdomains and not have them defined in others?

1 Like

Using @jpdean’s implementation of mixed assembly this is very doable.

I have an example of this kind of setup at:

Although I do admit that it is not the easiest example to start with. There will be more demos of this in the future.

I have also covered a similar example at:

1 Like

As an alternative to @dokken’s suggestion, @francesco-ballarin’s multiphenicsx code (here is the associated website) provides functionality for restricting variables to specific subdomains.

Cheers, Halvor

Thanks to both of you for the suggestions. I will look into them and get back with questions.