### using boundary markers NameError: name 'FacetFunction' is not defined​

40
views
0
9 days ago by
Hello,

I'm trying to adapt what is described here: https://fenicsproject.org/pub/tutorial/sphinx1/._ftut1005.html#setting-multiple-dirichlet-neumann-and-robin-conditions

To start, I'm trying with a rectangular domain, Newmann condition  $\frac{\partial u}{\partial n}=g$un =g at the top, and Dirichlet conditions  $u=h$u=h  at the rest of  the boundary.

Next is my code so far:

from fenics import *
from dolfin import *
# parameters["reorder_dofs_serial"] = False
# from fenicstools import *
# from scitools.std import *
import matplotlib.pyplot as plt
# plot = lambda *args, **kwargs: None
import numpy as np
# from boxfield import *

#parameters
x0 = 0.0
xN = 8.0
y0 = -4.0
yM = 0.0
nx = 50
ny = 15
hx = (xN-x0)/(nx-1)
hy = (yM-y0)/(ny-1)

# input and output
in_x = 4.0
in_y = 0.0
out_x = 7.0
out_y = 0.0

d=1

#mesh
mesh = RectangleMesh(Point(x0,y0), Point(xN,yM), nx, ny, "right")
boundary_markers = FacetFunction('size_t', mesh)
V = FunctionSpace(mesh, 'Lagrange', d)

#boundaries
class BoundaryD(SubDomain):
tol = 1E-14
def inside(self, x, on_boundary):
return on_boundary and \
near(x[0], x0, tol) or near(x[0], xN, tol) or near(x[1], y0, tol)

bD = BoundaryD()
bD.mark(boundary_markers, 0)

class BoundaryN(SubDomain):
tol = 1E-14
def inside(self, x, on_boundary):
return on_boundary and near(x[1], yM, tol)

bN = BoundaryN()
bN.mark(boundary_markers, 1)

ds = Measure('ds', domain=mesh, subdomain_data=boundary_markers)​

And i got this error:

NameError: name 'FacetFunction' is not defined​

Community: FEniCS Project

0
9 days ago by
use

boundary_markers = MeshFunction('size_t', mesh, mesh.topology().dim()-1)​

boundary_markers = FacetFunction('size_t', mesh)​