How to restrict a Function to a part of a mesh given by a MeshFunction?
Hello,
I would like to restrict an existing function to only a part of the mesh. The wanted part is given by a MeshFunction. Simply project the function to a submesh doesn't work in parallel. I did some experimentation with Restriction() but this led to nothing.
Here a minimal example to explain what I'm trying to do:
from dolfin import *
mesh = UnitCubeMesh( 10, 10, 10 )
V0 = VectorFunctionS
v0 = project( Constant( ( 1, 1, 1 ) ), V0 )
plot( v0 )
domains = CellFunction( "size_t", mesh )
for cell in cells( mesh ):
p = cell.midpoint()
if p.x() < p.y():
domains[ cell ] = 1
else:
domains[ cell ] = 2
plot( domains )
v0_vec = v0.vector().array()
for cell in cells( mesh ):
if domains[ cell ] == 1:
print( cell ) # dummy line to make the code executable
# v0_vec[ k ] = 0 for the correct k
v0.vector(
interactive()
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Heinz Zorn
- Solved:
- Last query:
- Last reply: