This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Assembling after mesh refine

+1 vote

Hi there,

I assemble a left hand side by

a = kappa * inner(nabla_grad(u), nabla_grad(v)) * dx
A = assemble(A)

with a random field kappa in form of a fenics function, and solve my system.
After i refine the mesh and do the above again, i get

ufl.log.UFLException: An Integral without a Domain is now illegal.

which happens with dolfin-version 1.5, not with 1.2 or 1.4.
Ok, so i changed to

a = (kappa * inner(nabla_grad(u), nabla_grad(v))) * dx(mesh)

but this leads to

KeyError: Domain(Cell('triangle', 2), label='dolfin_mesh_with_id_952', data='<data with id 952>')

What i'm doing wrong?

asked Nov 3, 2015 by adoll FEniCS Novice (530 points)
edited Nov 3, 2015 by adoll

1 Answer

0 votes

After refining the Mesh, the FunctionSpace and DofMap will be different, you need to redefine:

Q = FunctionSpace(mesh, "CG", 1)
u = TestFunction(Q)
v = TrialFunction(Q)

mesh2 = refine(mesh)
Q2 = FunctionSpace(mesh2, "CG", 1)
u = TestFunction(Q2)
v = TrialFunction(Q2)
answered Nov 3, 2015 by chris_richardson FEniCS Expert (31,740 points)

I see, thanks.
Actually, that's what i'm doing in my code, which confuses me.
Was there in fact a change with version 1.5?
Probably there is something wrong with my code...

...