Cannot create domain-dependent expression
Issue #1056
invalid
Script from the FEniCS tutorial is broken in 2018. Particularly this snippet:
class Permeability(Expression):
def __init__(self, markers, **kwargs):
self.markers = markers
def eval_cell(self, values, x, cell):
if self.markers[cell.index] == 0:
values[0] = 4*pi*1e-7 # vacuum
elif self.markers[cell.index] == 1:
values[0] = 1e-5 # iron (should really be 6.3e-3)
else:
values[0] = 1.26e-6 # copper
When instantiated, it throws a RecursionError on the third line into the Expression.py code.
Comments (3)
-
-
- changed status to invalid
Use
UserExpression
instead (see for example the mixed poisson demo).See also the changelog about deprecating subclassing of
Expression
in Python for the 2017.2.0 release. -
Thanks alot Johannes! Your answer is really appreciated.
- Log in to comment
Hi there
We also ran into the same problem:
https://bitbucket.org/fenics-project/dolfin/src/f8cd6c0b2722bef82f1d429a9e838a4491b30154/python/dolfin/function/expression.py#lines-426
seems bogus, as
__setattr__
and__getattr__
needs to be implemented carefully to prevent infinite recursion. See https://stackoverflow.com/questions/16237659/python-how-to-implement-getattrThe tutorial example ft11_magnetostatics.py also fails:
Is reimplementing
__setattr__
and__getattr__
required, or is our way of using the API wrong/outdated?Best regard ;)