Taking the adjoint of a non-linear form

Asked by Douglas Brinkerhoff

I'd like to get the adjoint of a non-linear Form that is calculated by taking the first variation of a Lagrangian. The problem is that the adjoint() function in FEniCs expects a bilinear form, and the nonlinear form is obviously a vector, since the variables of interest are specified as Functions rather than TrialFunctions. Is there a way to algorithmically replace every instance of a Function (u, say) with a TrialFunction (u_trial, say) in a given Form, such that the form becomes bilinear?

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Martin Sandve Alnæs (martinal) said :
#1

If you know it is linear in u, you can use replace(F, {u:ut}), or you can use derivative(F, u, ut) to get the Jacobi in the general case.

You can also start with the Lagrangian as a functional, to do that just let the Lagrange multiplier be a Coefficient w, and apply derivative w.r.t. w to get F and w.r.t u to get the adjoint. Apply derivative again to both w.r.t. opposite arguments to get their Jacobians.

Note that adjoint() in UFL is really only the transpose, be careful if you have e.g. time dependency or non symmetric discretization like upwinding.

Martin

Den 11. okt. 2011 kl. 21:35 skrev Douglas Brinkerhoff <email address hidden>:

> New question #173964 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/173964
>
> I'd like to get the adjoint of a non-linear Form that is calculated by taking the first variation of a Lagrangian. The problem is that the adjoint() function in FEniCs expects a bilinear form, and the nonlinear form is obviously a vector, since the variables of interest are specified as Functions rather than TrialFunctions. Is there a way to algorithmically replace every instance of a Function (u, say) with a TrialFunction (u_trial, say) in a given Form, such that the form becomes bilinear?
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

Can you help with this problem?

Provide an answer of your own, or ask Douglas Brinkerhoff for more information if necessary.

To post a message you must log in.