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

Build a SubMesh from a FacetFunction?

0 votes

I have a 3D mesh with facets marked specifically for different domains, and would like to solve a 2D problem over the surface of one of the regions,

i.e., I have a FacetFunction "ff" defined over the 3D mesh "mesh", and I'd like to create a SubMesh "submesh" over just the facets marked "3" like this :

submesh = SubMesh(mesh, ff, 3)

But this doesn't work because SubMesh is required to be initialized with a CellFunction

Does anyone know an easy (or hard) way to do this? If you point me to the source code, I could help develop this ability if necessary.

Thanks!

asked Nov 7, 2015 by pf4d FEniCS User (2,970 points)

2 Answers

0 votes

I guess this is similar to BoundaryMesh so you cpuld look at the code for that. There is a plan to implement MeshView soon, which could be the solution.

answered Nov 9, 2015 by chris_richardson FEniCS Expert (31,740 points)

thanks, I'll dig around.

+1 vote

In case it might still be helpful: http://fenicsproject.org/qa/9486/submesh-meshfunction-dirichletbc-meshview-etc

It has some code to rewrite a CellFunction into a FacetFunction. To do the opposite, I figure you can:

initialize a cellfunction, initialize all values to zero
for all cells in the mesh:
    get the facets
    get their value from the facetfunction
    if 2 or 3 facets (in the 2D case) are marked '3':
        mark the cell, too
answered Mar 4, 2016 by maartent FEniCS User (3,910 points)
...