projecting grad onto submesh: `error: redeclaration`

Issue #869 closed
Nico Schlömer created an issue

When projecting a grad object onto a submesh, jit bails out with error messages of the kind

/path/to/abc.cpp: In member function ‘virtual void ffc_form_b8497bca813e4cb501abd
48ee283d0b9e759e0ab_cell_integral_main_otherwise::tabulate_tensor(double*, const double* const*, const double*, int) const’:
/path/to/abc.cpp:95:18: error: redeclaration of ‘const double J_c0’
     const double J_c0 = coordinate_dofs[0] * FE10_C0_D01_Q1[0][0][0] + coordinate_dofs[2] * FE10_C0_D01_Q1[0][0][1];
                  ^~~~

MWE:

from dolfin import *


# Create mesh, submesh
class Structure(SubDomain):
    def inside(self, x, on_boundary):
        return x[0] > 1.4 - DOLFIN_EPS and x[0] < 1.6 \
            + DOLFIN_EPS and x[1] < 0.6 + DOLFIN_EPS
mesh = RectangleMesh(Point(0.0, 0.0), Point(3.0, 1.0), 60, 20)
sub_domains = MeshFunction("size_t", mesh, mesh.topology().dim())
sub_domains.set_all(0)
structure = Structure()
structure.mark(sub_domains, 1)
submesh = SubMesh(mesh, sub_domains, 1)

V = FunctionSpace(mesh, 'CG', 1)
f = project(Expression('x[0] * exp(x[1])', degree=3), V)
gfp = grad(f)

W = VectorFunctionSpace(submesh, 'CG', 1)
project(gfp, W)

Comments (3)

  1. Nico Schlömer reporter

    Workaround: First project onto the entire mesh, then onto the submesh.

    W = VectorFunctionSpace(mesh, 'CG', 1)
    pgfp = project(gfp, W)
    W2 = VectorFunctionSpace(submesh, 'CG', 1)
    project(pgfp, W2)
    
  2. Log in to comment