I'm trying to construct a discretization of the trace operator that observes functions along a boundary. That is, suppose $\Gamma$ is some subset of the boundary of $\Omega$ - I want to assemble the wide matrix $B$ such that,
$$\vec{v}^TB\vec{u} = \int_\Gamma v(x) u(x) ds,$$
where $u$ lives in a function space with domain $\Omega$, but $v$ lives in a space with domain $\Gamma$. It is not sufficient to simply compute the trace for a given function - I actually need the matrix.
Is this possible in Fenics?
I tried the following, which is clearly wrong but hopefully illustrates what I'm trying to do:
from dolfin import *
import numpy as np
mesh = UnitSquareMesh(10,10)
V = FunctionSpace(mesh, 'Lagrange', 1)
u = TrialFunction(V)
boundary_mesh = BoundaryMesh(mesh,"exterior")
V_boundary = FunctionSpace(boundary_mesh, 'Lagrange', 1)
v_b = TestFunction(V_boundary)
boundary_observation_operator = u*v_b*ds
B = assemble(boundary_test)
This yielded the error:
An Integral without a Domain is now illegal.
ERROR:UFL:An Integral without a Domain is now illegal.