This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

SubMesh of two subdomains

+7 votes

When extracting a submesh of a Dolfin mesh, I usually do something like
submesh = SubMesh(mesh, subdomains, 24)
Is it possible to extract the subdomain that is constituted by two or more subdomains, i.e.,
submesh = SubMesh(mesh, subdomains, [24, 25])
?

asked Jul 11, 2013 by nschloe FEniCS User (7,120 points)

1 Answer

+3 votes
 
Best answer

No you need to combine the two subdomains into one:

combined_subdomains = CellFunction("size_t", mesh, 0)
combined_subdomains.array()[subdomains.array()==24] = 1
combined_subdomains.array()[subdomains.array()==25] = 1
submesh = SubMesh(mesh, combined_subdomains, 1)

But it looks like a neat feature! Maybe you should consider implementing it and submit a pull request?

answered Jul 12, 2013 by johanhake FEniCS Expert (22,480 points)
selected Jul 12, 2013 by nschloe

Yes, that would be a nice feature.

I filed a feature request for this at https://bitbucket.org/fenics-project/dolfin/issue/87/submesh-of-multiple-subdomains so we don't lose track.

Analogical feature would be useful also for DirichletBC.

...