ufl form data

Asked by Chaffra Affouda

I am trying to understand form data.

Let' say i have

mesh = UnitInterval(10)
Q = FunctionSpace(mesh,'CG',1)
f = Function(Q)
f.rename('function','function')

F= f*dx

print F.compute_form_data().coefficient_names # returns a different name. How can I test that f is a coefficient of F and have its name displayed in F?

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Sandve Alnæs
Solved:
Last query:
Last reply:
Revision history for this message
Johan Hake (johan-hake) said :
#1

On Nov 20, 2012 6:35 PM, "Chaffra Affouda" <
<email address hidden>> wrote:
>
> New question #214775 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/214775
>
> I am trying to understand form data.
>
> Let' say i have
>
> mesh = UnitInterval(10)
> Q = FunctionSpace(mesh,'CG',1)
> f = Function(Q)
> f.rename('function','function')

Rename is an attribute of Function as a dolfin object, more precise, as
part of the Variable interface. F is a ufl form and has nothing to do with
the name of the dolfin Function.

> F= f*dx
>
> print F.compute_form_data().coefficient_names # returns a different name.
How can I test that f is a coefficient of F and have its name displayed in
F?

Try:
f in F.compute_form_data().coefficients

Johan

> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

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

Note that compute_form_data is considered part of the internal
implementation details and may change any time.

The names in form data are only used for loading forms from ufl files.

There is no official way to check if f is in a, but check
original_coefficients in form data.

Martin
Den 20. nov. 2012 23:11 skrev "Johan Hake" <
<email address hidden>> følgende:

> Question #214775 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/214775
>
> Status: Open => Answered
>
> Johan Hake proposed the following answer:
> On Nov 20, 2012 6:35 PM, "Chaffra Affouda" <
> <email address hidden>> wrote:
> >
> > New question #214775 on DOLFIN:
> > https://answers.launchpad.net/dolfin/+question/214775
> >
> > I am trying to understand form data.
> >
> > Let' say i have
> >
> > mesh = UnitInterval(10)
> > Q = FunctionSpace(mesh,'CG',1)
> > f = Function(Q)
> > f.rename('function','function')
>
> Rename is an attribute of Function as a dolfin object, more precise, as
> part of the Variable interface. F is a ufl form and has nothing to do with
> the name of the dolfin Function.
>
> > F= f*dx
> >
> > print F.compute_form_data().coefficient_names # returns a different name.
> How can I test that f is a coefficient of F and have its name displayed in
> F?
>
> Try:
> f in F.compute_form_data().coefficients
>
> Johan
>
> > --
> > You received this question notification because you are a member of
> > DOLFIN Team, which is an answer contact for DOLFIN.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Revision history for this message
Chaffra Affouda (chaffra) said :
#3

Thanks Martin Sandve Alnæs, that solved my question.