Material property depending on solution

Hi Rem,

I’m really not an expert but have you tried a UserExpression?
Something like

class CoeffClass(UserExpression):
    def __init__(self, temp, **kwargs):
        super().__init__(kwargs)
        self.temp = temp
    def eval(self, values, x):
        values[0] = ... 2*self.temp(x) ...
        if x[0] > 0.5:
            values[1] = 1
        else:
            ...
            values[1] = 0
    def value_shape(self):
        return ()

Indexing needs to match your function space dimensions, of course.
Then

D = CoeffClass(temp=temp)
...
# Update coefficient D
D.temp = temp

The update step might not even be necessary.
Conditional statements from the UFL Package might even be a much better/faster solution but I never used them in combination with spatial coordinates and your kinds of function spaces.

Hope it helps at least a little :sweat_smile: