I’m trying to reproduce the code for Mixed Formulation from the link:
But since it is from an older version, it does not work anymore. Specifically, the class
class BoundarySource(Expression):
def __init__(self, mesh):
self.mesh = mesh
def eval_cell(self, values, x, ufc_cell):
cell = Cell(self.mesh, ufc_cell.index)
n = cell.normal(ufc_cell.local_facet)
g = sin(5*x[0])
values[0] = g*n[0]
values[1] = g*n[1]
def value_shape(self):
return (2,)
Returns some a Recursion error, which I corrected by using the following class:
class BoundarySource(UserExpression):
def __init__(self, mesh):
self._mesh = mesh
self._ufl_shape = (2,)
def eval_cell(self, values, x, ufc_cell):
cell = Cell(self.mesh, ufc_cell.index)
n = cell.normal(ufc_cell.local_facet)
g = sin(5*x[0])
values[0] = g*n[0]
values[1] = g*n[1]
But when I take G
as an instance of the class:
G = BoundarySource(mesh)
And apply it to the Dirichlet Boundary Condition:
# Define essential boundary
def boundary(x):
return x[1] < DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS
bc = DirichletBC(W.sub(0), G, boundary)
It returns the strangest error:
AttributeError: _hash
Can someone please help me?