Skip to content
Discussion options

You must be logged in to vote

I think you can use UFL replace with as_vector:

from firedrake import *


mesh = UnitIntervalMesh(1)
V0 = FunctionSpace(mesh, "DG", 0)
V1 = FunctionSpace(mesh, "DG", 1)
V = V0 * V1
v = TestFunction(V)
v0, v1 = split(v)
F = Constant(10.) * v0 * dx + Constant(11.) * v1 * dx
F0 = replace(F, {v: as_vector([v0, zero()])})
print(F0)  # { v_0[0] * [10.] } * dx(<Mesh #0>[everywhere], {})
F1 = replace(F, {v: as_vector([zero(), v1])})
print(F1)  # { v_0[1] * [11.] } * dx(<Mesh #0>[everywhere], {})
val = assemble(F0 + F1 - F)
print(val.dat.data_ro)  # (array([0.]), array([0., 0.]))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmbigman
Comment options

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