Skip to content

Assign function from one space into mixed space #3322

Closed Answered by dham
Hasupama asked this question in Firedrake support
Discussion options

You must be logged in to vote

Here is a minimal example:

mesh = UnitSquareMesh(10, 10)
x = SpatialCoordinate(mesh)

Space_phi = FunctionSpace(mesh, 'CG', 1)
phi1 = Function(Space_phi)

scalar_lin_space = FunctionSpace(mesh, 'CG', 1)
Space = MixedFunctionSpace([scalar_lin_space,scalar_lin_space])
u = Function(Space)
phi,c = u.subfunctions
phi.assign(phi1)

I have verified that this works.

If you then need to use phi in a weak form then you should redefine it using split before you do so.

Assign only works between matching function spaces. If you need to transfer Function data between different function spaces then you either need to interpolate or project.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Hasupama
Comment options

@dham
Comment options

Answer selected by Hasupama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants