# Measure triggers recompile with subdomain data

**URL:** <https://fenicsproject.discourse.group/t/measure-triggers-recompile-with-subdomain-data/9107>\
**Category:** Uncategorized\
**Created:** [August 24, 2022, 3:06pm UTC](https://fenicsproject.discourse.group/t/measure-triggers-recompile-with-subdomain-data/9107 "2022-08-24T15:06:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johannes\_Neumann](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/johannes_neumann/32/449_2.png) [@Johannes\_Neumann](https://fenicsproject.discourse.group/u/Johannes_Neumann)\
**Post date:** [August 24, 2022, 3:06pm UTC](https://fenicsproject.discourse.group/t/measure-triggers-recompile-with-subdomain-data/9107/1 "2022-08-24T15:06:54Z")

</div>

Hello,

I just stumbled across something (for me) unexpected in 2019.2.0.dev0 (so I don’t know if it is still relevant in DolfinX).

I have a domain with a lot of subdomains defined via a mesh function. Integrating over each of these subdomains always triggers an ffc recompile while I would not expect that. More specifically I define my measure as below and with that I can integrate over a subdomain with id subdomain\_id via

```auto
ds = df.Measure("ds")(subdomain_data=mesh_function, domain=mesh)
df.assemble(df.Constant(1) * ds(subdomain_id))

```

but this will trigger a new compiliation for each new subdomain\_id as the ID goes into the form signature as can be seen [here in the UFL source code](https://bitbucket.org/fenics-project/ufl/src/a6e889ca592d5dd2304ceb6afb82d09e3569968c/ufl/algorithms/signature.py#lines-166).

As a workaround I now create a subdomain mask mesh function that is 1 inside the subdomain and 0 outside which triggers the jit only once as the ID doesn’t change anymore. This creates some overhead but is fast enough for me.

I found an older related question [here](https://fenicsproject.discourse.group/t/form-compilation-on-subdomains/4516). I would however expect that the jit does not run again just because the ID changed. Is there a reason it is like that or is there a better way as a work around?

Many thanks,  
Jo

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [August 24, 2022, 4:00pm UTC](https://fenicsproject.discourse.group/t/measure-triggers-recompile-with-subdomain-data/9107/2 "2022-08-24T16:00:56Z")

</div>

I’ve fixed this in; [Group integrals with common integrand in IntegralData by jorgensd · Pull Request #92 · FEniCS/ufl · GitHub](https://github.com/FEniCS/ufl/pull/92)  
However, we are waiting for firedrake to propagate this change through their code.

It is not likely that this will be fixed for legacy DOLFIN, but hopefully it will be fixed in DOLFINx soon.

---

<div class="post-metadata">

**Author:** ![Johannes\_Neumann](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/johannes_neumann/32/449_2.png) [@Johannes\_Neumann](https://fenicsproject.discourse.group/u/Johannes_Neumann)\
**Post date:** [August 24, 2022, 4:23pm UTC](https://fenicsproject.discourse.group/t/measure-triggers-recompile-with-subdomain-data/9107/3 "2022-08-24T16:23:24Z")

</div>

Nice. Thanks a lot for the confirmation. I don’t expect a back port of this and I’m looking forward to adopt DOLFINx in the future!
