Yes, have a look at the demo for the advection-diffusion equation.
/Carl
If you have to update something in every time-step then there's no way around it that I know of.
But perhaps you could see if there are some things that you can move outside the time-stepping loop. There are usually more alternatives than "have all forms outside the time-stepping loop" OR "have all forms inside the time-stepping loop".
Some tips:
Having an assembly of a matrix at every time-step can be quite costly. Ideally you would like to just assemble the matrix once before the time-stepping and reuse the factorization as you've seen in the advection-diffusion demo. If the time-dependency in the matrix just concerns a spatially invariant parameter then the update should just concern a scalar-matrix multiplication. You should try to move out as much as possible from the time-stepping, e.g., your L_u is just constantly = 0 since it contains a factor Constant(0.0) so there's no need to assemble it in the time-stepping. Perhaps there's more?
/Carl
Yes, have a look at the demo for the advection-diffusion equation.
/Carl
To unsubscribe from this group and stop receiving emails from it, send an email to fenics-support+unsubscribe@googlegroups.com.
To post to this group, send email to fenics-support@googlegroups.com.
No problem and take a look at the the advection diffusion demo if you haven't. There they have the costly assembly of the system matrix outside the time-stepping. Maybe that can help.
/Carl
If you have to update something in every time-step then there's no way around it that I know of.
But perhaps you could see if there are some things that you can move outside the time-stepping loop. There are usually more alternatives than "have all forms outside the time-stepping loop" OR "have all forms inside the time-stepping loop".
Some tips:
Having an assembly of a matrix at every time-step can be quite costly. Ideally you would like to just assemble the matrix once before the time-stepping and reuse the factorization as you've seen in the advection-diffusion demo. If the time-dependency in the matrix just concerns a spatially invariant parameter then the update should just concern a scalar-matrix multiplication. You should try to move out as much as possible from the time-stepping, e.g., your L_u is just constantly = 0 since it contains a factor Constant(0.0) so there's no need to assemble it in the time-stepping. Perhaps there's more?
/Carl
Från: Bo Wang <bw...@mst.edu>
Skickat: den 22 maj 2018 22:32:06
Till: Carl Lundholm
Ämne: Re: [fenics-support] How to update the variables in the variational form object
Thanks. But my problem is if there is a simpler way to update the variables in the bi-linear form (a) and linear form (l).
On Tue, May 22, 2018 at 2:44 PM, Carl Lundholm <car...@chalmers.se> wrote:
Yes, have a look at the demo for the advection-diffusion equation.
/Carl
To unsubscribe from this group and stop receiving emails from it, send an email to fenics-support+unsubscribe@googlegroups.com.