Re: [firedrake] Changing a vector valued function in time loop
I'm not sure what error you're seeing (it would help if you'd posted a full stack trace). However, I think the normal way to do this is to declare the expression separately: a_expr = Expression(["0.5*F0*cos(omega*t)*x[1]", "-0.5*F0*cos(omega*t)*x[0]"], F0=F0, omega=omega, t=t) a.interpolate(a_expr) Inside the time loop, you then update any quantities that you need, and reinterpolate: a_expr.t = t (or maybe a_expr.t.assign(t), I've forgotten...) a.interpolate(a_expr) This is better than creating a new Expression object each time you go around the loop, which is what it looks like you are doing at the moment. On 19 March 2017 at 13:27, William Booker <scwb@leeds.ac.uk> wrote:
Dear Firedrakers,
I'm trying to update a vector function in my time loop
a.interpolate(Expression(["0.5*F0*cos(omega*t)*x[1]", "-0.5*F0*cos(omega*t)*x[0]"], F0=F0, omega=omega, t=t))
but if I use assign or interpolate, I get told the form does not have the respective property. How should I go about making this work, such that it'll change the value of a in my solver?
Thanks
will
-- I suspect you used the label 'a' to define a Function, but then reused it to define your bilinear form. This would explain the error you allude to. On 19 March 2017 at 13:36, Andrew McRae <A.T.T.McRae@bath.ac.uk> wrote:
I'm not sure what error you're seeing (it would help if you'd posted a full stack trace).
However, I think the normal way to do this is to declare the expression separately:
a_expr = Expression(["0.5*F0*cos(omega*t)*x[1]", "-0.5*F0*cos(omega*t)*x[0]"], F0=F0, omega=omega, t=t) a.interpolate(a_expr)
Inside the time loop, you then update any quantities that you need, and reinterpolate:
a_expr.t = t (or maybe a_expr.t.assign(t), I've forgotten...) a.interpolate(a_expr)
This is better than creating a new Expression object each time you go around the loop, which is what it looks like you are doing at the moment.
On 19 March 2017 at 13:27, William Booker <scwb@leeds.ac.uk> wrote:
Dear Firedrakers,
I'm trying to update a vector function in my time loop
a.interpolate(Expression(["0.5*F0*cos(omega*t)*x[1]", "-0.5*F0*cos(omega*t)*x[0]"], F0=F0, omega=omega, t=t))
but if I use assign or interpolate, I get told the form does not have the respective property. How should I go about making this work, such that it'll change the value of a in my solver?
Thanks
will
Yep that was it. I feel silly now. Thanks Will ________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Andrew McRae <A.T.T.McRae@bath.ac.uk> Sent: 19 March 2017 13:40:42 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] Changing a vector valued function in time loop -- I suspect you used the label 'a' to define a Function, but then reused it to define your bilinear form. This would explain the error you allude to. On 19 March 2017 at 13:36, Andrew McRae <A.T.T.McRae@bath.ac.uk<mailto:A.T.T.McRae@bath.ac.uk>> wrote: I'm not sure what error you're seeing (it would help if you'd posted a full stack trace). However, I think the normal way to do this is to declare the expression separately: a_expr = Expression(["0.5*F0*cos(omega*t)*x[1]", "-0.5*F0*cos(omega*t)*x[0]"], F0=F0, omega=omega, t=t) a.interpolate(a_expr) Inside the time loop, you then update any quantities that you need, and reinterpolate: a_expr.t = t (or maybe a_expr.t.assign(t), I've forgotten...) a.interpolate(a_expr) This is better than creating a new Expression object each time you go around the loop, which is what it looks like you are doing at the moment. On 19 March 2017 at 13:27, William Booker <scwb@leeds.ac.uk<mailto:scwb@leeds.ac.uk>> wrote: Dear Firedrakers, I'm trying to update a vector function in my time loop a.interpolate(Expression(["0.5*F0*cos(omega*t)*x[1]", "-0.5*F0*cos(omega*t)*x[0]"], F0=F0, omega=omega, t=t)) but if I use assign or interpolate, I get told the form does not have the respective property. How should I go about making this work, such that it'll change the value of a in my solver? Thanks will
participants (2)
- 
                
                Andrew McRae
- 
                
                William Booker