change function inside compiled form

Asked by Chaffra Affouda

Maybe the answer is trivial but let's say you have two Functions u, v and a form

F(u,v) that you compiled with jit

F, compiled_module, form_data, module_name = jit(F)

is it possible to change the values of u or v inside F? Does any change that you make to u or v gets transmitted to F?

Thanks,
Chaffra

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
Johan Hake (johan-hake) said :
#1

After the compilation F is now a compiled ufc form. It does not carry
any information of the original UFL form that it was created from, more
than being the result of a form compilation. The actual objects within
the forms, the Arguments and/or Coefficients are stored in the form_data
object.

If you would like to compile a UFL form but not assemble it, but keeping
the original data attached to it I would suggest you to create a
dolfin.Form from the ufl form instead of a pure ufc.form. This can be
done by:

   F_dolfin = Form(F)

F_dolfin now has a ufc.form, but also all Coefficients and Arguments,
and it can be assembled, at least in the development version.

Johan

On 03/30/2012 11:20 PM, Chaffra Affouda wrote:
> New question #192191 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/192191
>
> Maybe the answer is trivial but let's say you have two Functions u, v
> and a form
>
> F(u,v) that you compiled with jit
>
> F, compiled_module, form_data, module_name = jit(F)
>
> is it possible to change the values of u or v inside F? Does any
> chnge that you make to u or v gets transmitted to F?
>
> Thanks, Chaffra
>

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

Ok I see how you can access the coefficients in Form. The reason I was asking is because I trying to solve a set of coupled equations.
Let's say I have two forms: F1(u,v) where u is the unknow, and F2(u,v) where v is the unknown. I was able to solve using a mixed function space on u and v although I am getting some non-convergence issues. So I decided to try and solve the problem iteratively:

while tolerance_condition
solve for u in F1
update u in F2
solve for v in F2
update v in F1

how can I implement this in dolfin? If I update u in F2, do I need to recompile or reassemble F2?

Revision history for this message
Johan Hake (johan-hake) said :
#3

It is difficult to follow your logic when there are no code. But solving
a system in a number of steps have been done and maybe the best example
is the Navier Stokes example on the web site.

http://fenicsproject.org/documentation/dolfin/dev/python/demo/pde/navier-stokes/python/documentation.html

Maybe this can help you?

Johan

On 04/02/2012 03:45 PM, Chaffra Affouda wrote:
> Question #192191 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/192191
>
> Status: Answered => Open
>
> Chaffra Affouda is still having a problem: Ok I see how you can
> access the coefficients in Form. The reason I was asking is because I
> trying to solve a set of coupled equations. Let's say I have two
> forms: F1(u,v) where u is the unknow, and F2(u,v) where v is the
> unknown. I was able to solve using a mixed function space on u and v
> although I am getting some non-convergence issues. So I decided to
> try and solve the problem iteratively:
>
> while tolerance_condition solve for u in F1 update u in F2 solve for
> v in F2 update v in F1
>
> how can I implement this in dolfin? If I update u in F2, do I need
> to recompile or reassemble F2?
>

Can you help with this problem?

Provide an answer of your own, or ask Chaffra Affouda for more information if necessary.

To post a message you must log in.