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

How to get meshfunctions for a submesh

0 votes

I have:

cellMeshFunction, defined upon a mesh
sigmaFunctionSpace, defined upon a submesh of that mesh

When I try:

sigmaFunctionSpace = FunctionSpace (subMesh, 'DG', 0)
sigma = Function(sigmaFunctionSpace)
choices = [segmentsOnIndex[index].sigma for index in sigmaIndices]
sigma.vector()[:] = numpy.choose (cellMeshFunction.array().astype(int), choices)

I get the following error:

RuntimeError: non matching dimensions on input

I think that instead of cellMeshFunction, defined on the original whole mesh I need a function (to be called cellSubMeshFunction), defined only on the subMesh, but with the same values on the submesh that the original cellMeshFunction had. How can I obtain such a function cellSubMeshFunction, given cellMeshFunction that is defined on the whole mesh?

Kind regards
J. de Hooge

asked Dec 28, 2013 by jacdeh FEniCS Novice (120 points)
edited Dec 30, 2013 by johanhake
...