[firedrake] defining an expression piecewise

Francis Poulin fpoulin at uwaterloo.ca
Mon Feb 27 03:05:41 GMT 2017


Hello,

I am trying to define an expression piecewise and see that I need to do that by defining a class.    Below is something that I tried, building on what I read, but it has an error, see below.

class MyExpression(Expression):
    def eval(self, value, x):
        if x[0] <= 0.5:
            value[0] = 1.0
        else:
          value[0] = 0.0

    def value_shape(self):
        return (1,)

f.interpolate(MyExpression())

It fails with the following error:


AttributeError: 'FunctionSpace' object has no attribute 'interpolate'


Can someone maybe point me in the right direction on how to do tis properly?

Cheers, Francis

------------------
Francis Poulin
Associate Professor
Department of Applied Mathematics
University of Waterloo

email:           fpoulin at uwaterloo.ca
Web:            https://uwaterloo.ca/poulin-research-group/
Telephone:  +1 519 888 4567 x32637

-------------- next part --------------
HTML attachment scrubbed and removed


More information about the firedrake mailing list