Assign between difefferent meshes but same domains

Hi, everyone, I have a quick question. Is there a way to assign values between different meshes but same domains? See the following simple example:

from dolfin import *
mesh1=UnitSquareMesh(1,1)
mesh2=UnitSquareMesh(5,5)
V1=FunctionSpace(mesh1,'CG',1)
V2=FunctionSpace(mesh2,'CG',1)
u1=interpolate(Constant(0),V1)
u2=Function(V2)
# Then how to assign the value of u1 to u2 without changing u2's FunctionSpace?
1 Like

Ok, I guess I have figured it out:

from dolfin import *
mesh1=UnitSquareMesh(1,1)
mesh2=UnitSquareMesh(5,5)
V1=FunctionSpace(mesh1,'CG',1)
V2=FunctionSpace(mesh2,'CG',1)
u1=interpolate(Constant(0),V1)
ex=Expression('u',degree=1,u=u1)
u2=interpolate(ex,V2)

look into dolfin::fem::PETScDMCollection::create_transfer_matrix.

1 Like