UFL

Outputting a symbolic jacobian to a file

Asked by Colin McAuliffe

Hello all,

As I understand it, dolfin uses ufl to set up and symbolically differentiate a weak form, which is then passed along to FFC. Instead, I would like to use ufl on its own to differentiate a weak form and output the results to a file in mathematical notation. Would setting up and differentiating the weak form be accomplished with the same commands used in dolfin?

Thanks
Colin

Question information

Language:
English Edit question
Status:
Solved
For:
UFL Edit question
Assignee:
No assignee Edit question
Solved by:
Colin McAuliffe
Solved:
Last query:
Last reply:
Revision history for this message
Marie Rognes (meg-simula) said :
#1

Pretty much with a few exceptions: basically replace FunctionSpace by FiniteElement and Function by Coefficient.

Take a look at

    http://fenicsproject.org/doc/ufl/1.0-beta2/ufl.html#ufl-package

and/or relevant UFL demos, for instance

    ufl/demo/PowAD.ufl

Revision history for this message
Martin Sandve Alnæs (martinal) said :
#2

Also, I recommend looking at the UFL chapter in the FEniCS book for
explanation of implementation details.

By mathematical notation, do you mean latex?

Martin
Den 3. okt. 2011 22.02 skrev "Marie Rognes" <
<email address hidden>> følgende:
> Question #173119 on UFL changed:
> https://answers.launchpad.net/ufl/+question/173119
>
> Status: Open => Answered
>
> Marie Rognes proposed the following answer:
>
> Pretty much with a few exceptions: basically replace FunctionSpace by
FiniteElement and Function by Coefficient.
>
> Take a look at
>
> http://fenicsproject.org/doc/ufl/1.0-beta2/ufl.html#ufl-package
>
> and/or relevant UFL demos, for instance
>
> ufl/demo/PowAD.ufl
>
> --
> You received this question notification because you are a member of UFL
> Team, which is an answer contact for UFL.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~ufl
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~ufl
> More help : https://help.launchpad.net/ListHelp

Revision history for this message
Colin McAuliffe (cjm2176) said :
#3

I meant to say by mathematical was to get rid of the CoefficientDerivative objects to get the resulting derivative. It looks like this is done by preprocess which is what I was looking for.

Thanks

Revision history for this message
Martin Sandve Alnæs (martinal) said :
#4

Ok, that should work. Not sure where you get preprocess from, or which
version you use, but you can also do

fd = a.compute_form_data()
a2 = fd.preprocessed_form

Or
from ufl.algorithms import expand_derivatives
a2 = expand_derivatives(a)

The latter does less processing than preprocess/formdata.

To inspect the form, try str, repr, and ufl.algorithms.tree_format. There is
some latex formatting but I'm not sure what state it us in currently.

Martin
Den 3. okt. 2011 23.59 skrev "Colin McAuliffe" <
<email address hidden>> følgende:
> Question #173119 on UFL changed:
> https://answers.launchpad.net/ufl/+question/173119
>
> Status: Answered => Solved
>
> Colin McAuliffe confirmed that the question is solved:
> I meant to say by mathematical was to get rid of the
> CoefficientDerivative objects to get the resulting derivative. It looks
> like this is done by preprocess which is what I was looking for.
>
> Thanks
>
> --
> You received this question notification because you are a member of UFL
> Team, which is an answer contact for UFL.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~ufl
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~ufl
> More help : https://help.launchpad.net/ListHelp