Same time dependent temperature problem in two different ways: one works, one doesn't. Why?

I just figured it out! I didn’t define the InitialConditions class, therefore my u0, p0, T0, were not of the right form. I am still new at FEniCS so unfortunately I don’t know why it works one way and not the other… But I do know that adding

class InitialConditions(UserExpression):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def eval(self, values, x):
        values[0] = 0.0
        values[1] = 0.0
        values[2] = 0.0
        values[3] = 0.0
    def value_shape(self):
        return (4,)

to the above, and then

w0 = Function(W)
w = Function(W)
u0, p0, T0 = split(w0)
u, p, T    = split(w)
#Interpolate the initial conditions
w_init = InitialConditions(degree=1)
w.interpolate(w_init)
w0.interpolate(w_init)

for w and w0 (instead of what I wrote above), everything works! I don’t know why… I will mark this subject as closed to not waste anyone’s time, but if you read this and know why that fixed it, I would be really grateful if you could reply.

1 Like