Another question about piecewise defined function
Asked by
cutejeff
I have taken a look at Achim Schroll's question and the answers. But I still have trouble to make it run.
My problem is a little different, I need to apply an expression instead of constants in the piecewise function.
e.g.
alpha = Expression("1 + x[0]*x[0] + 3*x[1]*x[1] + 1.2*t")
class Alpha(Expression):
def eval(self, v, x):
v[0] = 0
if x[0] > 0.5: v[0] = alpha
u0 = Alpha()
u_prev = interpolate(u0, V)
When I interpolate u0 to apply initial condition, the system gave me error like:
line 28, in interpolate
Pv.
Exception: Swig director method error. Error detected when calling 'Expression.
I tried to use just constants, it ran well. but it failed for the expressions. Anyone knows why? Thank you.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Johan Hake
- Solved:
- Last query:
- Last reply:
To post a message you must log in.