Subject: [FFC-dev] How to determine the order of function parameters in the Linear/BiLinear form?

From: Chong Luo <[email-masked]>
Date: Wed, 29 Oct 2008 15:45:23 -0700 (PDT)

Hi,

I found the Constant function very convenient, so that we don't have to recompile the form file every time we change a constant. However, this adds many more function parameters to linear/bilinear forms L(v) and a(u,v), and it's a pain to determine the correct order of the function parameters. For example, I spent a lot of time, but still couldn't figure out my linear form should be L(c10, u, alpha, beta, g) or L(c10, alpha, beta, u, g) or something else (the total number of possibilities is 5!=120).

Is there any easy way to figure out the correct order of the function parameters in the linear/bilinear forms?

Thank you!

Best,
Chong Luo

---

From: Johan Hake <[email-masked]>
Date: Thu, 30 Oct 2008 08:26:12 +0100

On Wednesday 29 October 2008 23:45:23 Chong Luo wrote:
> Hi,
>
> I found the Constant function very convenient, so that we don't have to
> recompile the form file every time we change a constant. However, this adds
> many more function parameters to linear/bilinear forms L(v) and a(u,v), and
> it's a pain to determine the correct order of the function parameters. For
> example, I spent a lot of time, but still couldn't figure out my linear
> form should be L(c10, u, alpha, beta, g) or L(c10, alpha, beta, u, g) or
> something else (the total number of possibilities is 5!=120).
>

It is the order they are _defined_ in the form file, that matters. 

element  = SomeElement()
element2 = SomeOtherElement()

  u = TrialFunction(element)
  v = TestFunction(element)

  # This part is cruicial
  f = Function(element)
  c = Constant('triangle')
  q = Funciton(element2)

  # This is not...
  a = c*u*vdx + f*q*u*v*ds

So then you initialize them as:

  YourFormNameBiliniearForm a(f,c,q);

This problem will be addressed with the new function interface.

Johan Hake

---

From: Anders Logg <[email-masked]>
Date: Thu, 30 Oct 2008 08:29:41 +0100

On Wed, Oct 29, 2008 at 03:45:23PM -0700, Chong Luo wrote:
> example, I spent a lot of time, but still couldn't figure out my linear form
> should be L(c10, u, alpha, beta, g) or L(c10, alpha, beta, u, g) or something
> else (the total number of possibilities is 5!=120).
> 

Funny you should ask... In fact, this was  added to FFC and DOLFIN
just two minutes ago. :-)

We're currently doing some major work on the DOLFIN Function classes
and introducing a new FunctionSpace class. As part of this, it is now
possible to have a form and do

  L.alpha = alpha;

in C++.

This only works in the development version which may have some other
bugs but is starting to work again.

-- 
Anders