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

assemble() got an unexpected keyword argument 'exterior_facet_domains'

+2 votes

Traceback (most recent call last):
File "upctotal-c.py", line 125, in
problem.solve()
File "/home/anguraj/fenics/paper4/cbc/pdesys/Problem.py", line 54, in solve
%(self.prm['time_integration'], func))
File "", line 1, in
File "/home/anguraj/fenics/paper4/cbc/pdesys/Problem.py", line 147, in solve_Transient_advance
logging=logging)
File "/home/anguraj/fenics/paper4/cbc/pdesys/PDESystem.py", line 327, in solve_inner
logging=max_iter>1)
File "/home/anguraj/fenics/paper4/cbc/pdesys/PDESubSystems.py", line 789, in solve_nonlinear
assemble_b=pdesubsystem.assemble_b)
File "/home/anguraj/fenics/paper4/cbc/pdesys/PDESubSystems.py", line 123, in solve
res, dx = solve(assemble_A, assemble_b)
File "/home/anguraj/fenics/paper4/cbc/pdesys/PDESubSystems.py", line 143, in solve_Picard_system
if assemble_A: self.assemble(self.A)
File "/home/anguraj/fenics/paper4/cbc/pdesys/PDESubSystems.py", line 191, in assemble
exterior_facet_domains=self.exterior_facet_domains)
TypeError: assemble() got an unexpected keyword argument 'exterior_facet_domains'

asked Aug 26, 2015 by palraj j FEniCS Novice (190 points)

Hello Palraj j,

If you got rid of your error, could you also please take a look at my code below, it gives me the very same error. Thanks a lot!

1 Answer

+1 vote

http://fenicsproject.org/qa/7362/computation-outward-boundary-comparison-numerical-solutions

I had a similar issue and the answer to this question helped solve my problem.

answered Aug 27, 2015 by sarah FEniCS Novice (430 points)

Hi Sarah,

I have the following code, which gives me the same error and I am not able to gather the desired result from the link you provided. It's a simple time dependent heat equation with heat source at bottom, convection at top and radiation at bottom. Can you help please?

from dolfin import *
import numpy as np

mesh = UnitCubeMesh(10,10,10)
xmax, ymax, zmax = 1, 1, 1
V = FunctionSpace(mesh, 'Lagrange', 1)
boundary_parts = FacetFunction("size_t", mesh)
boundary_parts.set_all(0) #marks whole cube as domain 0

class Bottom(SubDomain):
   def inside(self, x, on_boundary):
      tol = 1E-14
      return on_boundary and abs(x[2]) < tol
bottom = Bottom()
bottom.mark(boundary_parts, 1) #marks bottom of the cube as 1

class Top(SubDomain):
   def inside(self, x, on_boundary):
      tol = 1E-14
      return on_boundary and abs(x[2] - zmax) < tol
top = Top()
top.mark(boundary_parts, 2) #marks the top of the cube as 2

dx=Measure('dx')[boundary_parts]
ds=Measure('ds')[boundary_parts]

plot(boundary_parts)

u = TrialFunction(V)
v = TestFunction(V)
u0 = Constant("293")
u_1= interpolate(u0, V)
del_t=1
T=10
source=Constant("5")
Fa = (u*v + inner(nabla_grad(u), nabla_grad(v)))*dx() - del_t*(u-u0)*v*ds(1) - del_t*(u-u0)*v*ds(2)
FL= u_1*v*dx() - del_t*source*v*ds(1)

F=Fa-FL

a=lhs(F)
L=rhs(F)

A = assemble(a, exterior_facet_domains=boundary_parts)
b = None
u = Function(V)
t = del_t
dt = 0.5
while t <= T:
   b = assemble(L, tensor=b, exterior_facet_domains=boundary_parts)
   solve(A, u.vector(), b, 'lu')
   t += dt
   u_1.assign(u)

plot(u_1)
interactive ()

I modified four lines to get rid of the 'exterior_facet_domain' and the code should run without an error. I left the original code in a comment on the line before the new code. When defining Fa and FL, when you use ds() you include subdomain_data = boundary_parts in the parentheses and then in the line A = assemble() and b = assemble() you can remove that information.

from dolfin import *
import numpy as np

mesh = UnitCubeMesh(10,10,10)
xmax, ymax, zmax = 1, 1, 1
V = FunctionSpace(mesh, 'Lagrange', 1)
boundary_parts = FacetFunction("size_t", mesh)
boundary_parts.set_all(0) #marks whole cube as domain 0

class Bottom(SubDomain):
   def inside(self, x, on_boundary):
      tol = 1E-14
      return on_boundary and abs(x[2]) < tol
bottom = Bottom()
bottom.mark(boundary_parts, 1) #marks bottom of the cube as 1

class Top(SubDomain):
   def inside(self, x, on_boundary):
      tol = 1E-14
      return on_boundary and abs(x[2] - zmax) < tol
top = Top()
top.mark(boundary_parts, 2) #marks the top of the cube as 2

dx=Measure('dx')[boundary_parts]
ds=Measure('ds')[boundary_parts]

plot(boundary_parts)

u = TrialFunction(V)
v = TestFunction(V)
u0 = Constant("293")
u_1= interpolate(u0, V)
del_t=1
T=10
source=Constant("5")
#Fa = (u*v + inner(nabla_grad(u), nabla_grad(v)))*dx() - del_t*(u-u0)*v*ds(1) - del_t*(u-u0)*v*ds(2)
#FL= u_1*v*dx() - del_t*source*v*ds(1)
Fa = (u*v + inner(nabla_grad(u), nabla_grad(v)))*dx() - del_t*(u-u0)*v*ds(1,  subdomain_data = boundary_parts) - del_t*(u-u0)*v*ds(2,  subdomain_data = boundary_parts)
FL= u_1*v*dx() - del_t*source*v*ds(1,  subdomain_data = boundary_parts)

F=Fa-FL

a=lhs(F)
L=rhs(F)

#A = assemble(a, exterior_facet_domains=boundary_parts)
A = assemble(a)
b = None
u = Function(V)
t = del_t
dt = 0.5
while t <= T:
   #b = assemble(L, tensor=b, exterior_facet_domains=boundary_parts)
   b = assemble(L, tensor=b)
   solve(A, u.vector(), b, 'lu')
   t += dt
   u_1.assign(u)

plot(u_1)
interactive ()

Thanks a lot Sarah. Appreciate your help and time.

...