Symmetric tensor function space evaluation and interpolation is wrong

Issue #516 closed
Lizao Li created an issue

It seems the implementation for evaluation and interpolation of symmetric tensor function space is wrong, while its internal quadrature representation is correct.

from dolfin import *
set_log_level(ERROR)

mesh = UnitSquareMesh(10, 10)
SDG = TensorFunctionSpace(mesh, "DG", 0, symmetry = True)
DG = TensorFunctionSpace(mesh, "DG", 0)

print("Given a constant symmetric tensor ((1, 2), (2, 3)).")
g = Constant(((1.0, 2.0), (2.0, 3.0)))

print("Interpolant to SymTensorDG at (0.5, 0.5): {}".format(interpolate(g, SDG)(0.5, 0.5)))

print("Interpolant to TensorDG at (0.5, 0.5): {}".format(interpolate(g, DG)(0.5, 0.5)))

print("Projection to SymTensorDG at (0.5, 0.5): {}".format(project(g, SDG)(0.5, 0.5)))

print("Projection to TensorDG at (0.5, 0.5): {}".format(project(g, DG)(0.5, 0.5)))

u = interpolate(g, SDG)
v = interpolate(g, DG)
print("L2 difference between interpolants to SymTensorDG and TensorDG: {}".format(assemble(inner(u-v, u-v)*dx)))

u = project(g, SDG)
v = project(g, DG)
print("L2 difference between projections to SymTensorDG and TensorDG: {}".format(assemble(inner(u-v, u-v)*dx)))

u = project(g, SDG)
v = interpolate(u, DG)
print("L2 difference between a SymTensorDG and its interpolant to the bigger space TensorDG: {}".format(assemble(inner(u-v, u-v)*dx)))

u = project(g, SDG)
v = project(u, DG)
print("L2 difference between a SymTensorDG and its projection to the bigger space TensorDG: {}".format(assemble(inner(u-v, u-v)*dx)))

Output:

Given a constant symmetric tensor ((1, 2), (2, 3)).
Interpolant to SymTensorDG at (0.5, 0.5): [ 1.  2.  2.  0.]
Interpolant to TensorDG at (0.5, 0.5): [ 1.  2.  2.  3.]
Projection to SymTensorDG at (0.5, 0.5): [ 1.  2.  3.  0.]
Projection to TensorDG at (0.5, 0.5): [ 1.  2.  2.  3.]
L2 difference between interpolants to SymTensorDG and TensorDG: 1.0
L2 difference between projections to SymTensorDG and TensorDG: 0.0
L2 difference between a SymTensorDG and its interpolant to the bigger space TensorDG: 10.0
L2 difference between a SymTensorDG and its projection to the bigger space TensorDG: 6.40949485492e-33

Comments (2)

  1. Jan Blechta

    This combination of failing interpolations/projections resembles me issue #489. It's very probable that nodality of SDG element is not taken into account. I can take care of it when fixing FFC issue 69.

  2. Log in to comment