Subject: [Ffc] Status (again)

From: Marie Rognes <[email-masked]>
Date: Wed, 27 Jan 2010 15:50:00 +0100

FFC compilation fails for

    ElementRestriction.ufl
    QuadratureElement.ufl
    TensorWeightedPoisson.ufl

Running test programs fails for

    P5tet.bin    (Segmentation faults after evaluate_basis(0, ...)

Differences in output

    evaluate_basis*

    FacetIntegrals.out      (missing value in generated code (many))
    SubDomain.out            (missing value in generated code 
(tabulate_tensor))

Others:

    tabulate_entity_dofs     (errors thrown are all wrong. Marie will fix)

--
Marie

---

From: Medhi Nikbakht <[email-masked]>
Date: Wed, 27 Jan 2010 16:40:11 +0100

> FFC compilation fails for

The error message says that "ElementRestriction" is not supported by
FIAT. 
How will the restricted elements be implemented? Wouldn't it be better
to support them inside FFC?

Mehdi 

> _______________________________________________
> Mailing list: https://launchpad.net/~ffc
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~ffc
> More help   : https://help.launchpad.net/ListHelp

---

From: Marie Rognes <[email-masked]>
Date: Wed, 27 Jan 2010 16:51:01 +0100

> to support them inside FFC?

They will be supported inside FFC.  This is just one of items that remains
for the FFC development branch.

--
Marie

---

From: Kristian Oelgaard <[email-masked]>
Date: Wed, 27 Jan 2010 16:54:53 +0100 (CET)

> to support them inside FFC?

There are two types of restrictions supported in UFL (and the old FFC).
1) Restriction onto Measure (like 'dc'), which is what you want.
2) Restriction onto Cell, as for instance restricting a Lagrange element defined on a 'triangle' to its facets.

The third restriction that we might want in the future is restriction onto subdomains possible in UFL but not in FFC.

To implement 1) I think it is enough to just attach the Measure as a member to the fiat_element and the simply look for it in appropriate places when generating the code. That means handle it in FFC.fiatinterface, could that work?

To implement 2) I modified the return value of entity_dofs() and tabulate() accordingly. To do it this way again we will need to make changes in FIAT_NEW.FiniteElement and FFC.MixedElement. I'm not sure it is a good idea to make FIAT_NEW.PolynomialSet aware of restrictions, but I don't know enough about the FIAT internals to back up this claim.

I'm not really sure how to handle the restriction onto subdomains, but it should most likely be implemented in FFC.

Kristian

---

From: Mehdi Nikbakht <[email-masked]>
Date: Wed, 27 Jan 2010 17:36:39 +0100

> To implement 1) I think it is enough to just attach the Measure as a member to the fiat_element and the simply look for it in appropriate places when generating the code. That means handle it in FF…

Yes, it works. In my case just adding these few lines to the beginning
of create_fiat_element is enough,

    domain = ufl_element.domain_restriction()
    if isinstance(domain, Measure):
      if domain.domain_type() == "surface":
        ufl_element = ufl_element._element

Since I have the same properties as non-restricted element.

Mehdi

---

From: Anders Logg <[email-masked]>
Date: Wed, 27 Jan 2010 20:48:10 +0100

Update:

  ElementRestriction.ufl
  QuadratureElement.ufl

GCC compilation works for all forms

  P5tet.bin

Output test fails for all forms

  evaluate_basis_*          3048 errors
  tabulate_tensor             34 errors
  interpolate_vertex_values   12 errors
  value_dimension              2 errors
  num_coefficients             1 error

--
Anders

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 00:10:00 +0100

>   interpolate_vertex_values   12 errors

Good job with evaluate_basis Kristian.

Update:

  evaluate_basis_derivatives* 1517
  tabulate_tensor               45 (worse than before?)
  interpolate_vertex_values     12
  evaluate_basis                 4
  value_dimension                2
  num_coefficients               1

The following can be ignored (not implemented before):

  evaluate_basis_all
  evaluate_dofs
  num_entity_dofs

--
Anders

---

From: Marie Rognes <[email-masked]>
Date: Thu, 28 Jan 2010 10:13:40 +0100

>   interpolate_vertex_values     12

I think these can be ignored as well.

> The following can be ignored (not implemented before):

I made a quick fix in ffc-0.7.1-reference implementing evaluate_dofs,
so you shouldn't get any errors for this one.

--
Marie

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 12:12:36 +0100

New update:

  tabulate_tensor                1

Looks good! It shouldn't be the any problem to fix the last few
errors, but what about evaluate_basis_derivatives? Is it a lot of work
to fix?

--
Anders

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 28 Jan 2010 12:15:46 +0100 (CET)

> errors, but what about evaluate_basis_derivatives? Is it a lot of work

I'm still trying to localise the error.

Kristian

> --
> Anders
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkthcSQACgkQTuwUCDsYZdHqdgCeNpMt+zFG3JdUIsk/Wildvkyd
> IM8AnAubk5KKJRNp1aXbzv5Je3zCdnZk
> =h4Nf
> -----END PGP SIGNATURE-----
>

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 19:18:17 +0100

Update:

  ElementRestriction.ufl
  QuadratureElement.ufl
  evaluate_basis_derivatives* 1510

Everything else seems to be ok. There's one tabulate_tensor reported
in error.log but it's the result of different handling of integrals on
sub domains.

So things are looking good!

--
Anders

---

From: Marie Rognes <[email-masked]>
Date: Thu, 28 Jan 2010 21:14:36 +0100

Kristian Oelgaard wrote:
> 2) Restriction onto Cell, as for instance restricting a Lagrange 
> element defined on a 'triangle' to its facets.
>
> The third restriction that we might want in the future is restriction 
> onto subdomains possible in UFL but not in FFC.
>
> To implement 1) I think it is enough to just attach the Measure as a 
> member to the fiat_element and the simply look for it in appropriate 
> places when generating the code. That means handle it in 
> FFC.fiatinterface, could that work?
>
> To implement 2) I modified the return value of entity_dofs() and 
> tabulate() accordingly. To do it this way again we will need to make 
> changes in FIAT_NEW.FiniteElement and FFC.MixedElement. I'm not sure 
> it is a good idea to make FIAT_NEW.PolynomialSet aware of 
> restrictions, but I don't know enough about the FIAT internals to back 
> up this claim.
>

How about adding a class RestrictedElement that contains an element and 
(based on the restriction)
a list of relevant basis function indices, and overrides the methods as 
FiniteElement/MixedElement?

No need to make FIAT aware of this.

--
Marie

> I'm not really sure how to handle the restriction onto subdomains, but 
> it should most likely be implemented in FFC.
>
> Kristian
>
>> Mehdi
>>
>>>     QuadratureElement.ufl

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 21:24:20 +0100

On Thu, Jan 28, 2010 at 09:14:36PM +0100, Marie Rognes wrote:
> >The third restriction that we might want in the future is
> >restriction onto subdomains possible in UFL but not in FFC.
> >
> >To implement 1) I think it is enough to just attach the Measure as
> >a member to the fiat_element and the simply look for it in
> >appropriate places when generating the code. That means handle it
> >in FFC.fiatinterface, could that work?
> >
> >tabulate() accordingly. To do it this way again we will need to
> >make changes in FIAT_NEW.FiniteElement and FFC.MixedElement. I'm
> >not sure it is a good idea to make FIAT_NEW.PolynomialSet aware of
> >restrictions, but I don't know enough about the FIAT internals to
> >back up this claim.
> >
>
>
> How about adding a class RestrictedElement that contains an element
> and (based on the restriction)
> a list of relevant basis function indices, and overrides the methods
> as FiniteElement/MixedElement?
>

This sounds good. I think I understand (somewhat) what (2) is supposed
to do, but not (1).

And as Garth suggests, I think a better name is FacetElement. Does a
FacetElement know that it can only be integrated over facets, not the
interior, or can it?

--
Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Thu, 28 Jan 2010 20:28:22 +0000

> FacetElement know that it can only be integrated over facets, not the

It's possible that it could be integrated over the interior, but
probably not very sensible.

I think that FacetElement is a bit misleading, since what it does is
just take the dofs of a cell that live on the facets. With FacetElement
I think of an element of topological dim 2 embedded in 3D.

Garth

> --
> Anders
> 
> 
> ------------------------------------------------------------------------
>

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 21:37:22 +0100

> I think of an element of topological dim 2 embedded in 3D.

I thought that was the idea.

Exactly what does it do?

--
Anders

---

From: Marie Rognes <[email-masked]>
Date: Thu, 28 Jan 2010 21:51:35 +0100

> I think of an element of topological dim 2 embedded in 3D.

Agree.

Besides, the concept is more general than just for facets. The idea is 
simply
to take the span of a subset of the basis functions, right. Maybe calling
it a restriction is misleading in the first place...

--
Marie

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 28 Jan 2010 21:56:18 +0100 (CET)

On 28 January 2010 21:14, Marie Rognes <[email-masked]> wrote:
>> The third restriction that we might want in the future is restriction onto
>> subdomains possible in UFL but not in FFC.
>>
>> member to the fiat_element and the simply look for it in appropriate places
>> when generating the code. That means handle it in FFC.fiatinterface, could
>> that work?
>>
>> tabulate() accordingly. To do it this way again we will need to make changes
>> in FIAT_NEW.FiniteElement and FFC.MixedElement. I'm not sure it is a good
>> idea to make FIAT_NEW.PolynomialSet aware of restrictions, but I don't know
>> enough about the FIAT internals to back up this claim.
>>
>
>

Yes, that would be one option and we already have MixedElement and RestrictedElement is much the same thing (we should change the name in UFL). Although, one objective of this re-write of FFC was to remove as much as possible w.r.t. FiniteElement.

We could make the RestrictedElement a child class of FIAT.FiniteElement, that should be OK since FFC uses FIAT as the backend for finite elements. Then we just need to modify a few member functions.

Kristian

>> I'm not really sure how to handle the restriction onto subdomains, but it
>> should most likely be implemented in FFC.
>>
>> Kristian
>>
>>> Mehdi
>>>
>>>>    QuadratureElement.ufl

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 21:59:38 +0100

> We could make the RestrictedElement a child class of FIAT.FiniteElement, that should be OK since FFC uses FIAT as the backend for finite elements. Then we just need to modify a few member functions.

I think Marie's suggestion is cleaner with a the RestrictedElement
class (or whatever it will be named) *has* an element. That element
could perhaps be another mixed element. There are not that many
functions to implement (about 8).

--
Anders

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 28 Jan 2010 22:03:57 +0100 (CET)

> functions to implement (about 8).

Let's make it a new class then.

Kristian

> iEYEARECAAYFAkth+roACgkQTuwUCDsYZdGO8wCfcCoNgO22AeHHGX9crxLkznt7
> H4MAn0krAMrRmtTq3keqPazWWmRPqvdT
> =2ipj

---

From: "Garth N. Wells" <[email-masked]>
Date: Thu, 28 Jan 2010 21:11:09 +0000

> I thought that was the idea.

I use it for functions that live on cell facets only. Nothing special is
required for k <= 2, but it's needed for k > 2 to eliminate internal dofs.

Garth

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 22:20:55 +0100

> Let's make it a new class then.

ok. I'll add a sketch but I'm not sure what should happen so I'll need
help filling out the details.

--
Anders

---

From: Anders Logg <[email-masked]>
Date: Thu, 28 Jan 2010 22:30:19 +0100

I have added a sketch of RestrictedElement but there is some weird
nesting of mixed and restricted elements that I couldn't figure out a
nice way to handle. Try the ElementRestriction.ufl demo and see what
happens.

--
Anders