Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ft11_magnetostatics.py #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benjaminknebusch
Copy link

Expression needs Cpp code to be provided use UserExpression instead

Expression needs Cpp code to be provided use UserExpression instead
@smartalecH
Copy link

UserExpression throws an error:

AttributeError: 'Permeability' object has no attribute '_ufl_shape'

Any ideas on a fix?

@smartalecH
Copy link

It looks like in addition to changing Expression to UserExpression, you need to initialize the superclass. The child class definition should look like this:

class Permeability(UserExpression):
    def __init__(self, markers, **kwargs):
        super().__init__(**kwargs) # This part is new!
        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

Finally, to get the script to run with 2019.1.0, you also need to remove Interactive() and rely on pyplot (as mentioned in other PRs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants