Hi there,
I’m new to FEniCS so maybe this question is trivial. In short, what I’m struggling with is the generation of a problem matrix as I need to compute the L^2-projection \Pi_h u of a test/trial function u or the gradient of a testfunction \Pi_h \nabla u onto a coarser mesh. I figured that project(u, V_coase)
would be the L^2-projection in FEniCS-Syntax for a Function
u
but since the computation of such a projection requires a solve-step this is not possible in UFL (this is at least what I understand).
More precisely, I want to generate a matrix from this bilinear form
a = dot(project(u, V_coarse), project(v, V_coarse)) * dx
which results in
..File "...ufl/domain.py", line 133, in _ufl_signature_data_
return ("Mesh", renumbering[self], self._ufl_coordinate_element)
KeyError: Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 11)
. As this doesn’t work I tried to get the matrix P, representing the projection operator, which needs the matrix given by
m = dot(phi_1, v) * dx
for trial function phi_1
w.r.t V_coarse
and u
for V_fine
. But this also does not work and produces:
TypeError: '<' not supported between instances of 'Mesh' and 'Mesh'
The following code shall illustrate what I have tried:
mesh_coarse = UnitTriangleMesh.create()
V_coarse = FunctionSpace(mesh_coarse, "DG", 1)
mesh_fine = refine(mesh_coarse)
V_fine = FunctionSpace(mesh_fine, "Lagrange", 1)
# Define basis and bilinear form
u = TrialFunction(V_fine)
v = TestFunction(V_fine)
a = dot(project(u, V_coarse), project(v, V_coarse)) * dx # does not work
# Alternative: Generate a matrix operator for \Pi_h
phi_1 = TrialFunction(V_coarse)
phi_2 = TestFunction(V_coarse)
m = dot(phi_1, v) * dx # TypeError: '<' ... 'Mesh' and 'Mesh'
How to deal with such a problem in FEniCS in general? I’m very grateful for any help.