Error when attempting to create a Dirichlet and Neumann boundary condition on cube

that will partially resolve your issue, as it will then use the subdomain data supplied in:

However, I would probably use a DG-0 function to indicate different materials rather than different constants. Then you could do:

Q = FunctionSpace(mesh, "DG",0)
k = Function(Q)

# assign data to k, see and use `dx` measure.

See

A motivation for doing it this way is to avoid extra generated code, which happens often in ufl:

1 Like