Subject: [UFL-dev] FiniteElement classes

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Thu, 13 Mar 2008 23:03:14 +0100

Take a look at the file elements2.py in the latest ufl hg repository.
Is this ok?

Instead of

fe = FiniteElement("CG", ...) # scalar element
fe = FiniteElement("Nedelec", ...) # vector element
fe = VectorElement("CG", ...) # vector element
fe = VectorElement("Nedelec", ...) # invalid element

this goes like

fe = ScalarElement("CG", ...) # scalar element
fe = ScalarElement("Nedelec", ...) # invalid element
fe = VectorElement("CG", ...) # vector element
fe = VectorElement("Nedelec", ...) # vector element

It's up to the form compiler to say wether an element family makes
sense as a scalar/vector/tensor element or not, UFL expressions only
care about the polygon and value shape.

--
Martin

---

From: Marie Rognes <[email-masked]>
Date: Thu, 13 Mar 2008 17:46:03 -0400

> fe = VectorElement("Nedelec", ...) # invalid element

Just a comment: I typically want to write something like

    VectorElement("Nedelec", ...)

in order to have a vector of Nedelec elements...!

-- 
Marie E. Rognes
Ph.D Fellow, 
Centre of Mathematics for Applications, 
University of Oslo
http://folk.uio.no/meg

---

From: Anders Logg <[email-masked]>
Date: Fri, 14 Mar 2008 10:36:41 +0100

> in order to have a vector of Nedelec elements...!

Take a look in the new elements.py. I have added some information
about the ranks of different elements and a possibility to register
new elements. I don't think ScalarElement will be needed. Just as
before, we have two things: FiniteElement and MixedElement and then
VectorElement and TensorElement as special cases of MixedElement.

The file ufl_io.py was missing so I couldn't run the code, so it's
probably broken in a few places...

-- 
Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Fri, 14 Mar 2008 19:13:06 +0100

> On Thu, Mar 13, 2008 at 05:46:03PM -0400, Marie Rognes wrote:
'>  > Just a comment: I typically want to write something like
>  > in order to have a vector of Nedelec elements...!

So, does that represent a tensor field? I've implemented value_rank()
in the VectorElement and TensorElement that way, so the value rank of
a VectorElement is the value rank of the subelement (Nedelec) plus
one. Thus each row of the tensor is represented by a Nedelec element.

If you want a set of vector elements instead:
  fe = FiniteElement("Nedelec",...)
  me = MixedElement(fe, fe, fe)
  # or
  me = fe+fe+fe
should also work. The value rank of a MixedElement constructed one of
these ways is undefined, since Functions should be defined over its
subelements anyway.

>  probably broken in a few places...

It works now. I removed the QuadratureElement and made it a family
instead. So we can write:

fe = FiniteElement("Quadrature", "triangle") # degree should be None by default
fe = VectorElement("Quadrature", "triangle")
fe = TensorElement("Quadrature", "triangle")
# or short form
fe = FiniteElement("Q", "triangle")

In addition, we need a quadrature element for functions evaluated only
at the boundary, since quadrature points in a cell may not lie on the
boundary at all:

fe = VectorElement("Boundary Quadrature", "triangle")

I'm not sure wether we need to have one for exterior facets and one
for interior facets though. We'll have to think about it over easter.

--
Martin

---

From: Marie Rognes <[email-masked]>
Date: Fri, 14 Mar 2008 20:42:07 -0400

Martin Sandve Alnæs wrote:
> So, does that represent a tensor field? 

For instance, yes.

> I've implemented value_rank()

I'm sure this works well. It is just a matter of philosophy in the 
naming, I guess. A VectorElement could either represent a vector field 
or a vector of elements... To me, the latter is the most intuitive, but 
that's probably just because that's what I'm used to ;)

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Sat, 15 Mar 2008 11:46:23 +0100

Sorry, missed the list.

---------- Forwarded message ----------
From: Martin Sandve Alnæs <[email-masked]>
Date: 15.mar.2008 11:45
Subject: Re: [UFL-dev] FiniteElement classes
To: Marie Rognes <[email-masked]>

 >  that's probably just because that's what I'm used to ;)

The way I've implemented value_rank() now, VectorElement represents a
 vector of elements which combines into a single field, while
 MixedElement is "only" a list of elements where the element fields are
 distinct.

 The reason value_rank() is important, is that UFL does consistency
 checking as early as possible to give good user feedback. It should be
 very difficult to construct an expression that doesn't make sense and
 get away with it.

 --

Martin

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Tue, 18 Mar 2008 22:31:17 +0100

>  MixedElement is "only" a list of elements where the element fields are

Sounds good to me.

-- 
Anders