On 25/04/16 09:25, Daniel Ruprecht wrote:
Hi Andrew,
Thanks for clarifying this - I suspected there might be a deeper reason, but could not figure it out. I am quite happy using the second variant, I just wanted to understand why the first one was not working.
For what it's worth, I would recommend always formulating your problem in residual form (even if it is linear). The linear variational solvers just wrap up the nonlinear variational ones anyway (with appropriate options). For a linear problem, newton will converge in one step and you might (depending on what you're monitoring with petsc) pay at most one extra residual evaluation. Writing your formulation in this way makes it much easier to deal with nonlinearities once you have them: no need to go back and turn all TrialFunctions into Functions and so on. To be fair, none of our demos do this! Cheers, Lawrence