Integration on part of multimesh

Dear all,

I tried to modify the demo demo_multimesh-poisson.py to integrate only in one part of the Multimesh, but I could not find how to do this.

Here is the demo:
https://code.ascee.nl/ASCEE/dolfin/src/commit/132dca639e20e0a6b198c624c5ab0167c7b42767/demo/undocumented/multimesh-poisson/python/demo_multimesh-poisson.py

a = inner(u,v) * dX with A = assemble_multimesh(a) is working well.

But neither a = inner(u.part(0),v.part(0)) * dX
nor inner(u,v)*dX(0) would work.

Could you point me out to the right syntax?

Thank you

Dear @IUF,
What do you mean when you say one part of the multimesh? Do you want to integrate over just the i-th grid?.
If so you should do something like this:

V = MultiMeshFunctionSpace(multimesh, "DG", 0)
f = MultiMeshFunction(V)
j = 2 # Mesh you would like to integrate over.
for i in range(multimesh.num_parts()):
            Vi = FunctionSpace(multimesh.part(i), "DG", 0)
            if i==j:
                 f.assign_part(i, project(Constant(1), Vi))
            else:
                 f.assign_part(i, project(Constant(0), Vi))
a = f*inner(u,v)*dX
A = assemble_multimesh(a)

However, what is the reasoning for doing so?
For more examples using multimesh see: Shape optimization with MultiCables and Navier-Stokes with multimesh using splitting schmes

Dear Dokken,

Thank you for your answer. This already helps me a lot.
However, I. also would like to integrate say the second variable on the first mesh for instance.
The reasoning behind would be for instance a porous media in a fluid domain.
mesh1 = fluid domain
mesh2 = porous media domain

Then the variables on the first mesh corresponds say to the velocity and the “pressure” of the fluid and on the second mesh to the displacements and “pressure”.
My variational formulation then contains scalar products on the first mesh and on the second mesh, and one additional mixed term.

Thank you

Dear @IUF,
We are developing a framework dedicated to mixed-domains problems that might be appropriate for what you would like to do. It is not yet in the main branch of FEniCS, but if you are interested, you can have a look to the dedicated mixed-dimensional branch.
If you want to avoid installing from source, there is also a Docker container with a basic demo.